Swing
Swing Java. Swing Sun Microsystems. (. Swing widgets), , , . .
Swing JFC, . Java 2D, Accessibility-API, Drag & Drop-API AWT.
|
|
[]
Java 1.2 (1998 ) Swing Java Runtime Environment.
[]
- Look and Feel
Swing , «look and feel» (L&F) . «Look» , «Feel» . Suns JRE L&F[1]:
- CrossPlatformLookAndFeel L&F Java- ( Metal). , , , .
- SystemLookAndFeel L&F, , . L&F . Windows «Windows» L&F, , Windows, XP, Vista. Linux Solaris «GTK+», GTK+ 2.2 , «Motif».
- Synth L&F.
- Multiplexing L&F .
[] AWT
Swing , AWT. AWT, Swing - , AWT . AWT , (), , AWT ( ), AWT Swing- ( Swing ).
Swing (. plugable look-and-feel), ( , , ). , , Swing, . «» (. Lightweight) . .
[] Lightweight
«Lightweight» , Swing , . «» AWT, Swing , , (, JFrame). Swing AWT , , AWT Swing , JPopupMenu JComboBox. , setLightWeightPopupEnabled(boolean), «» . true (setLightWeightPopupEnabled(true)), AWT .
[] SWT
| .
, .
, . |
[]
«Hello World» Swing:
import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; public final class HelloWorld implements Runnable { public static void main(String[] args) { // Swing (.. dispatching thread), // (, main()) // . ( main ), // Swing- . // , // ( , ). Java 6, , // . // // , , , : SwingUtilities.invokeLater (new HelloWorld()); } public void run() { // "Hello, World!" JFrame f = new JFrame ("Hello, World!"); // : listener // , windowClosing() // System.exit() // "" . // , . // . f.setDefaultCloseOperation (JFrame.DISPOSE_ON_CLOSE); // : // f.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // . //f.getContentPane().add (new JLabel("Hello, World!")); - f.add(new JLabel("Hello World")); // pack() "" , // . f.pack(); // f.setVisible(true); } }
Look-And-Feel:
try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); SwingUtilities.updateComponentTreeUI(this); } catch (Exception e){ System.out.println(" Metal-Look-And-Feel"); }
Look-And-Feel:
// , L&F // - Swing, //Java L&F, , L&F . public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { //Exception handle }
[] .
[]
- Swing (.)
- JDK 6 Swing APIs & Developer Guides from Oracle Coorp (.)
- Creating a GUI with JFC/Swing: Examples (.)
- A Swing Architecture Overview (.)
- Swing Sightings: Swing (.)
[]
- How to Set the Look and Feel (The Java Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)
[]
- Swing: , 2- = Swing: , 2- . 2-. -: «», 2011. . 600. ISBN 978-5-85582-305-9
- SWING: = SWING: A BEGINNER'S GUIDE. .: «», 2007. . 704. ISBN 0-07-226314-8
- Swing: = Swing: . 1-. -: «», 2005. . 523. ISBN 5-469-00005-2
| . , . . |
|
|
|||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
||||||||||||||||||||||||||||