Friday, July 26, 2013

Java Swing note

Swing provides three generally useful top-level container classes: JFrame, JDialog, and JApplet
•Each top-level container has a content pane that, generally speaking, contains (directly or indirectly) the visible components in that top-level container's GUI.
The menu bar is by convention positioned within the top-level container, but outside the content pane.
Although JInternalFrame mimics JFrame, internal frames aren't actually top-level containers.
With the exception of top-level containers, all Swing components whose names begin with "J" descend from the JComponent class.
An opaque component fills its background with its background color.
The z-order determines the order that components are painted. The component with the highest z-order paints first and the component with the lowest z-order paints last. Where components overlap, the component with the lower z-order paints over the component with the higher z-order.
repaint(): Request that all or part of the component be repainted.
void revalidate(): Request that the component and its affected containers be laid out again. You should not generally need to invoke this method unless you explicitly change a component's size/alignment hints after it's visible or change a containment hierarchy after it is visible. Always invoke repaint after revalidate.
void paintComponent(Graphics) Paint the component. Override this method to implement painting for custom components.

No comments:

Post a Comment