本文整理汇总了Java中javax.swing.JComboBox.setAction方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.setAction方法的具体用法?Java JComboBox.setAction怎么用?Java JComboBox.setAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.setAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SpecialGraphWindow
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* Creates an instance of this class.
*/
public SpecialGraphWindow () {
setTitle("Create special graph");
setBounds(50,50,700,500);
wkPreview = new GraphWorkspace(new GTCGraph(),false);
typeOptions = PluginController.getInstance().getFactories();
layoutOptions = PluginController.getInstance().getLayouts(null,wkPreview);
// Create Center, South, and West and South
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel,BoxLayout.X_AXIS));
JPanel southPanel = new JPanel(new BorderLayout());
JPanel westPanel = new JPanel(new BorderLayout());
// Create and set properties panel
propertiesPanel = new JPanel();
propertiesPanel.setLayout(new BoxLayout(propertiesPanel,BoxLayout.Y_AXIS));
propertiesPanel.setBorder(BorderFactory.createTitledBorder("Properties"));
// Create ComboBox wirh Graph Factory options
bType = new JComboBox(typeOptions);
bType.setAction(COMBO_GRAPH_TYPE_ACTION);
buildPropertiesMembersInterface(bType);
// Create and set a Graph Type panel and add a ComboBox type
JPanel graphTypePanel = new JPanel();
graphTypePanel.setLayout(new BoxLayout(graphTypePanel,BoxLayout.Y_AXIS));
graphTypePanel.setBorder(BorderFactory.createTitledBorder("Graph Type"));
graphTypePanel.add(bType);
// Create ComboBox wirh Graph Factory options
bLayout = new JComboBox(layoutOptions);
bLayout.setAction(COMBO_GRAPH_LAYOUT_ACTION);
// Create and set a Graph Layout panel and add a ComboBox layout
JPanel graphLayoutPanel = new JPanel();
graphLayoutPanel.setLayout(new BoxLayout(graphLayoutPanel,BoxLayout.Y_AXIS));
graphLayoutPanel.setBorder(BorderFactory.createTitledBorder("Graph Layout"));
graphLayoutPanel.add(bLayout);
// Create a combos` panel
JPanel comboPanel = new JPanel(new BorderLayout());
comboPanel.add(graphTypePanel,"North");
comboPanel.add(graphLayoutPanel,"South");
// Add graph type panel and properties panel in West Panel
westPanel.add(comboPanel,"North");
westPanel.add(propertiesPanel,"Center");
// Add preview workspace in Center Panel
centerPanel.add(wkPreview);
centerPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
// Create buttons and buttons panel
JPanel buttonsPanel = new JPanel(new FlowLayout());
buttonsPanel.add(new JButton(PREVIEW_ACTION));
buttonsPanel.add(new JButton(RESTORE_DEFAULT_ACTION));
buttonsPanel.add(new JButton(OK_ACTION));
buttonsPanel.add(new JButton(CANCEL_ACTION));
// Add buttons panel in South Panel
southPanel.add(buttonsPanel,BorderLayout.EAST);
// Add panels in Main Panel (SpecialGraphWindow Content Panel)
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(southPanel,BorderLayout.SOUTH);
this.getContentPane().add(westPanel,BorderLayout.WEST);
this.getContentPane().add(centerPanel,BorderLayout.CENTER);
}