120 likes | 244 Vues
This guide provides an overview of Java user interface toolkits, including AWT, Swing, JavaFX, and SWT (Eclipse). It delves into the Look and Feel options available, such as Cross Platform Look and Feel, System Look and Feel, and Synth Look and Feel (Nimbus). The document also outlines example code snippets demonstrating how to set different Looks using UIManager, handling exceptions, and creating a simple "Hello, World!" application with Swing components. A concise exploration for developers looking to enhance their Java UI knowledge.
E N D
Widget toolkits • AWT • Swing • JavaFX • SWT (Eclipse) • ...
Look&Feel • CrossPlatformLookAndFeel • SystemLookAndFeel (Windows, Motif/GTK) • Synth (Nimbus)
Look&Feel try { UIManager.setLookAndFeel( "javax.swing.plaf.metal.MetalLookAndFeel"); // UIManager.setLookAndFeel( // UIManager.getSystemLookAndFeelClassName()); // SwingUtilities.updateComponentTreeUI(this); } catch (Exception e){ //Exception handle }
Hello, World! import javax.swing.*; public final class HelloWorld implements Runnable { public static void main(String[] args) { SwingUtilities.invokeLater(new HelloWorld()); } public void run() { JFrame f = new JFrame("Hello, World!"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JLabel("Hello World")); f.pack(); f.setVisible(true); } }