1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
package com.explodingpixels.macwidgets;
import com.explodingpixels.widgets.PopupMenuCustomizer;
import javax.swing.*;
import java.awt.*;
public class DSourceListControlBar {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SourceList sourceList = DSourceListMail.createSourceList();
SourceListControlBar controlBar = new SourceListControlBar();
sourceList.installSourceListControlBar(controlBar);
controlBar.hideResizeHandle();
controlBar.createAndAddButton(MacIcons.PLUS, null);
controlBar.createAndAddButton(MacIcons.MINUS, null);
controlBar.createAndAddPopdownButton(MacIcons.GEAR,
new PopupMenuCustomizer() {
public void customizePopup(JPopupMenu popup) {
popup.removeAll();
popup.add(new JMenuItem("Item One"));
popup.add(new JMenuItem("Item Two"));
popup.add(new JMenuItem("Item Three"));
}
});
JSplitPane splitPane =
MacWidgetFactory.createSplitPaneForSourceList(sourceList, new JTextArea());
splitPane.setDividerLocation(200);
controlBar.installDraggableWidgetOnSplitPane(splitPane);
JFrame frame = new JFrame();
// frame.add(splitPane, BorderLayout.CENTER);
frame.add(sourceList.getComponent(), BorderLayout.CENTER);
// frame.setSize(500,275);
frame.setSize(225, 275);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
}
});
}
}
|