package com.explodingpixels.macwidgets; import com.explodingpixels.macwidgets.MacButtonFactory; import com.explodingpixels.macwidgets.MacUtils; import com.explodingpixels.macwidgets.MacWidgetFactory; import com.explodingpixels.macwidgets.UnifiedToolBar; import com.explodingpixels.widgets.WindowUtils; import javax.swing.AbstractButton; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JToggleButton; import javax.swing.JToolBar; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.awt.BorderLayout; import java.awt.Insets; public class DUnifiedToolBarButtonUITest { private JFrame frame; @Before public void setUp() throws Exception { } @Test public void doTest() throws Exception { Icon preferences = new ImageIcon(DUnifiedToolBarButtonUITest.class.getResource( "/com/explodingpixels/macwidgets/icons/PreferencesGeneral.png")); UnifiedToolBar unifiedToolBar = new UnifiedToolBar(); AbstractButton macWidgetsButton = MacButtonFactory.makeUnifiedToolBarButton( new JButton("Preferences", preferences)); // macWidgetsButton.setEnabled(false); unifiedToolBar.addComponentToLeft(MacWidgetFactory.createSpacer(0, 0)); unifiedToolBar.addComponentToLeft(macWidgetsButton); JToolBar regularToolBar = new JToolBar(); JToggleButton javaPreferencesButton = new JToggleButton("Preferences", preferences); // javaPreferencesButton.setEnabled(false); javaPreferencesButton.setHorizontalTextPosition(AbstractButton.CENTER); javaPreferencesButton.setVerticalTextPosition(AbstractButton.BOTTOM); javaPreferencesButton.setIconTextGap(0); javaPreferencesButton.setMargin(new Insets(0, 0, 0, 0)); regularToolBar.add(javaPreferencesButton); frame = new JFrame(); unifiedToolBar.installWindowDraggerOnWindow(frame); MacUtils.makeWindowLeopardStyle(frame.getRootPane()); WindowUtils.createAndInstallRepaintWindowFocusListener(frame); frame.add(unifiedToolBar.getComponent(), BorderLayout.NORTH); frame.add(regularToolBar, BorderLayout.SOUTH); frame.pack(); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); } @After public void tearDown() throws Exception { frame.dispose(); } }