import java.awt.*; import java.awt.event.*; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JCheckBoxMenuItem; import javax.swing.JRadioButtonMenuItem; import javax.swing.ButtonGroup; import javax.swing.JMenuBar; import javax.swing.KeyStroke; import javax.swing.ImageIcon; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JScrollPane; import javax.swing.JFrame; public class MenuLookDemo { protected static ImageIcon createImageIcon(String path) { java.net.URL imgURL = MenuLookDemo.class.getResource(path); if(imgURL != null) { return new ImageIcon(imgURL); } else { System.err.println("Couldn't find file: " + path); return null; } } private static void createAndShowGUI() { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = frame { title = "MenuLookDemo" menubar = { menu { text = "A Menu" mnemonic = a items = { label { text = "A text-only menu item" mnemonic = t accelerator = alt - 1 } label { text = "Both text and icon" icon = "images/middle.gif" mnemonic = b } label { icon = "images/middle.gif" mnemonic = d } seperator radiobutton { text = "A radio button menu item" group = a selected = true mnemonic = r } radiobutton { text = "Another one" mnemonic = o group = a } seperator checkbox { text = "A check box menu item" mnemonic = c } checkbox { text = "Another one" mnemonic = h } seperator menu { text = "A submenu" mnemonic = s items = { label { text = "An item in the submenu" accelerator = alt - 2 } label { text = "Another item" } } } } } menu { text = "Another Menu" mnemonic = n } } content = panel { opaque = true layout = border layout { center = scrollpane of textarea { columns = 30 rows = 5 } } } }; frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(450, 260); frame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } }