AWT Section Index | Page 2
How can I control the Z-order that my overlapping components are drawn in?
When components overlap, be sure their container returns false from the isOptimizedDrawingEnabled() method that is inherited from JComponent. This ensures that lower z-order components are not dra...more
To understand z-order, think first of x and y positioning. The x-y coordinate space places position (0, 0) at the top-left corner of the screen. Increasing the x value moves the position to the ri...more
The width and height are actually very easy. All you need to do is get a FontMetrics object for the font you used to draw the string, and ask it:
FontMetrics fm = getFontMetrics(getFont());
The "trick" is to create a new thread that performs the task while the normal event thread watches for the mouse release.
If you perform the mouse-pressed action inside your mousePressed() method...more
The basic idea is to print the GUI to an offscreen image, then encode that image as a JPEG.
The initial answer is "you don't; AWT does".
Graphics objects are your "window" into an image, whether that image is onscreen or offscreen.
If you're looking to paint onscreen, the only way you ...more
The java.awt.EventQueue javadocs say:
It encapsulates asynchronous event
dispatch machinery which extracts events
from the queue and dispatches them by
calling dispatchEvent method
on this Eve...more
printerJob.printDialog() method which pops up the print options dialog returns boolean true or false.
If user clicks cancel button it returns false and you can trap it by declaring and checking a ...more
The Component class has a getInsets() method that returns an
Insets object. The Insets object has four public fields:
top, bottom, left and right.
These insets define the area a container is r...more
AWT uses the Checkbox class for both check boxes and radio buttons.
To create a radio button, you need to create check boxes, and add them to a checkbox group. For example
The Component class defines several size accessor methods to
assist the layout process. Each of these methods returns a
Dimension object describing the requested size.
These methods are as foll...more
GridLayout respects the first non-zero row or column parameter passed to its constructor. The other value is computed based on the number of components in the container.
Because the preferred size of a component is usually dependent on fonts and decorations used for a specific platform, you need to "realize" the component before you can ask.
To realize a componen...more
SWT (Standard Widget Toolkit) is a completely independent Graphical User
Interface (GUI) toolkit from IBM. They created it for their new Eclipse
Integrated Development Environment (IDE).