Because an applet, resident on a Web server, is invoked by a browser on a client machine, most browsers place security restrictions on what ...
Showing posts with label Developing GUIs. Show all posts
Showing posts with label Developing GUIs. Show all posts
Applet Life Cycle Methods
Because applets are run from browsers, they differ from applications in that they do not have a main method. Instead, applets hav...
Swing Applets
The applet described in the previous section was a subclass of java.applet.Applet and as such did not use any Swing features. The...
Applets
In this section, we describe a simple applet, MultiplyApplet.java. This applet performs the same function , to output the product o...
Painting with Swing
With Swing, we do not draw text or images directly onto a frame or applet. A component subclass is created, usually a subclass of JPa...
Adapters in Event Handling
All the listener interfaces we have described so far have just one associated method. Many other interfaces have several associated ...
ListSelectionListener
The ListSelectionListener interface is used to handle list selection events. These occur whenever the selection in a lis...
ItemListener
ItemListeners are used to respond to item events. These are generated whenever an item's state changes. Typically, this occur...
ActionListener
ActionListeners are used to respond to action events. Action events are typically created by clicking a button or pressing ...
Event Handling
All of our examples have been write only: displaying GUI objects on a window or panel, but with no means of the user communicating back to t...
Specifying Look and Feel
Swing graphical user interfaces (GUIs) takes Java look and feel by default. However, it is possible to specify a windowing system look a...
GridLayout
In a GridLayout container, components are placed in a grid of cells. The statement cp.setLayout(new GridLayout(r, c)); specifies a GridLayou...
BorderLayout
In the BorderLayout type, the container is divided into five sections, namely, north, west, center, east, and south. When adding a component...
FlowLayout
This is the simplest type of layout. Components are added to a container from left to right.If no horizontal space is available for a compon...
Swing Containers : Intermediate-Level Containers
Intermediate-level containers contain Swing components, but themselves will be contained within one of the two top-level containers, applet ...
Swing Containers : Dialogues
Apart from frames, there is one other specialized window subclass, namely, Dialog. Dialogues typically provide messages withi...
Swing Containers : Top-Level Containers
There are two types of top-level containers in Swing: applets and windows . An applet in Swing is a subclass of JApplet , as indicated by t...
How to Enabling and Disabling Components in Java
By default, all components are enabled. However, we may wish to disable a component. A disabled component cannot respond when clic...
How to set Fonts in Java
The javax.swing.JComponent.setFont method is used to set fonts for text associated with a component. This method requires a...
How to create Background and Foreground Colors in Java
The javax.swing.JComponent.setBackground and javax.swing.JComponent.setForeground methods can be used to set background and foreground colo...