public static void main(String arg[]) { SwingMacOSXUISetter.setNativePlatformUI("Test MAC OS", true); JFrame f = new JFrame("test"); JMenuBar mbar = new JMenuBar(); f.setJMenuBar(mbar); JMenu menu = new JMenu("File"); mbar.add(menu); menu.add(new JMenuItem("Open")); menu.add(new JMenuItem("Exit")); menu = new JMenu("Actions"); mbar.add(menu); menu.add(new JMenuItem("Do Something")); Container pane = f.getContentPane(); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); JPanel xpane = new JPanel(); pane.add(xpane); xpane.setLayout(new BoxLayout(xpane, BoxLayout.X_AXIS)); xpane.add(Box.createHorizontalStrut(5)); xpane.add(new JFileSelector()); xpane.add(Box.createHorizontalStrut(5)); xpane.add(Box.createHorizontalGlue()); pane.add(Box.createVerticalStrut(5)); xpane = new JPanel(); pane.add(xpane); xpane.setLayout(new BoxLayout(xpane, BoxLayout.X_AXIS)); xpane.add(Box.createHorizontalStrut(5)); xpane.add(new JButton("Click Me!")); xpane.add(new JColorSelector()); xpane.add(Box.createHorizontalGlue()); pane.add(LayoutUtils.createGreedyVerticalGlue()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(400, 300); f.setVisible(true);Has the following result on Mac OS X:
Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences