The Java Foundation Classes (JFC) are a set of Java class libraries provided as part of Java 2 Platform, Standard Edition (J2SE) to support building graphics user interface (GUI) and graphics functionality for client applications that will run on popular platforms such as Microsoft Windows, Linux, and Mac OSX
Swing Interviews are getting tough these days as the technology grows faster. To get through the Swing interview one needs to update him/herself in a regular manner. Having said that, just before the interview, it is very important to have a quick glance of the reputed Swing questions and answers to make yourself comfortable during the interview process. This is where DoAnswers.com helps you in renewing yourself on Swing and various other technologies interview preparation.
11. How are the elements of a GridBagLayout organized?
The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.
12. How can a GUI component handle its own events?
A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.
13. How can the Checkbox class be used to create a radio button?
By associating Checkbox objects with a CheckboxGroup
14. How do the Java Foundation Classes make developers' lives easier?
The Java Foundation Classes substantially reduces the amount of programming needed by providing many reusable and cross-platform UI components. In addition, foundation services offered in JFC enable developers to build richer solutions with fewer lines of code. The last and most important point is that developers don't have to worry that their application will only perform well on one platform. JFC is designed to be 100% cross-platform.
15. How is JFC different from other framework classes from third parties?
There are six main differences:No need to bundle. Java Foundation classes are core to the Java 2 Platform. JavaBeans components. All JFC components are JavaBeans components. JFC components have all the benefits that JavaBeans components offer -- reusability, interoperability, and portability. For more information on JavaBeans visit http://java.sun.com/beans. There is no framework lock-in. Developers can easily bring in other third-party JavaBeans components to enhance their applications written using JFC. JFC offers an open architecture. Truly cross-platform. Being part of the Java Platform, all JFC components and services are designed to work everywhere. For example, Drag and Drop services within JFC work the same between the Java Platform and all operating systems. While third-party vendors might be able to implement certain components to be cross-platform, only Sun can make sure that foundation services behave consistently across all Java-Compatible Platforms. Fully customizable. Developers can easily extend these components to create other more customized components. In addition, even the look and feel of these components can be change by either developers or users through the Pluggable Look and Feel architecture in JFC. Not just components. In addition to components, Java Foundation Classes include foundation services such as Java 2D. These services significantly enhance the type of applications developers can build.
16. How Struts relates to J2EE?
Struts framework is built on J2EE technologies (JSP, Servlet, Taglibs), but it is itself not part of the J2EE standard.
17. how to execute the business operation associated with the requested action.
In the Struts framework this helper class is descended of org.apache.struts.action.Action class. It acts as a bridge between a client-side user action and business operation. The Action class decouples the client request from the business model. This decoupling allows for more than one-to-one mapping between the user request and an action. The Action class also can perform other functions such as authorization, logging before invoking business operation. the Struts Action class contains several methods, but most important method is the execute() method. public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception; The execute() method is called by the controller when a request is received from a client. The controller creates an instance of the Action class if one doesn?t already exist. The strut framework will create only a single instance of each Action class in your application. Action are mapped in the struts configuration file and this configuration is loaded into memory at startup and made available to the framework at runtime. Each Action element is represented in memory by an instance of the org.apache.struts.action.ActionMapping class . The ActionMapping object contains a path attribute that is matched against a portion of the URI of the incoming request. path= "/somerequest" type="com.somepackage.someAction" scope="request" name="someForm" validate="true" input="somejsp.jsp" Once this is done the controller should determine which view to return to the client. The execute method signature in Action class has a return type org.apache.struts.action.ActionForward class. The ActionForward class represents a destination to which the controller may send control once an action has completed. Instead of specifying an actual JSP page in the code, you can declaratively associate as action forward through out the application. The action forward are specified in the configuration file. path= "/somerequest" type="com.somepackage.someAction" scope="request" name="someForm" validate="true" input="somejsp.jsp" The action forward mappings also can be specified in a global section, independent of any specific action mapping. public interface RequestDispatcher
18. How to get data from the velocity page in a action class?
We can get the values in the action classes by using data.getParameter(\"variable name defined in the velocity page\");
19. How would you create a button with rounded edges?
There are 2 ways. The first thing is to know that a JButton?s edges are drawn by a Border. so you can override the Button?s paintComponent(Graphics) method and draw a circle or rounded rectangle (whatever), and turn off the border. Or you can create a custom border that draws a circle or rounded rectangle around any component and set the button?s border to it.
20. How would you detect a keypress in a JComboBox?
Add a KeyListener to the JComboBox?s editor component instead of adding a KeyListener to the JComboBox itself