How do I get the system look and feel?
Category: javax.swing, viewed: 934 time(s).
The UIManager.getSystemLookAndFeelClassName() return the current system look and feel for swing application. Don't forget to call the SwingUtilities.updateComponentTreeUI(frame) after setting the LAF.
package org.kodejava.example.swing; import javax.swing.*; public class SystemLAFDemo { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(300, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("System LAF Demo"); try { // // Use the system look and feel for the swing application // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } SwingUtilities.updateComponentTreeUI(frame); frame.setVisible(true); } } |
Related Examples
- How do I right justified JTextField contents?
- How do I format JLabel using HTML?
- How do I display an image in JButton?
- How do I use JFormattedTextField to format user input?
- How do I handle mouse button click event?
- How do I handle mouse wheel event?
- How do I handle mouse motion event?
- How do I handle mouse event in swing?
- How do I set the look and feel for swing application?
- How do I get the available swing look and feel?
|
|