Look and feel string
import java.awt.BorderLayout;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class MainClass {
final static JLabel l = new JLabel();
public static void main(String[] args) {
selectLookAndFeel();
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
pane.setLayout(new BorderLayout());
JButton b = new JButton("Press Me!");
b.setMnemonic(KeyEvent.VK_P);
b.setToolTipText("Click this button to see a message.");
pane.add("North", b);
l.setLabelFor(b);
pane.add("South", l);
f.setContentPane(pane);
f.setSize(300, 100);
f.setVisible(true);
}
private static void selectLookAndFeel() {
String actualName = UIManager.getCrossPlatformLookAndFeelClassName();
//actualName = UIManager.getSystemLookAndFeelClassName();
//actualName = "com.sun.java.swing.plaf.mac.MacLookAndFeel";
//actualName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
//actualName = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
try {
UIManager.setLookAndFeel(actualName);
} catch (Exception e) {
System.err.println("Could not get " + actualName + " look and feel for some reason.");
}
}
}
Related examples in the same category