本文整理汇总了Java中javax.swing.JComboBox.setAlignmentX方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.setAlignmentX方法的具体用法?Java JComboBox.setAlignmentX怎么用?Java JComboBox.setAlignmentX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.setAlignmentX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateControl
import javax.swing.JComboBox; //导入方法依赖的package包/类
@Override
public JComponent generateControl()
{
combobox = new JComboBox(items);
combobox.setAlignmentX(Component.LEFT_ALIGNMENT);
Iterator i = items.iterator();
while( i.hasNext() )
{
Item item = (Item) i.next();
if( item.isSelected() )
{
combobox.setSelectedItem(item);
}
}
return combobox;
}
示例2: initDialog
import javax.swing.JComboBox; //导入方法依赖的package包/类
public void initDialog() {
try {
testBox = Box.createHorizontalBox();
System.out.println(name);
testDialog = new JDialog(((haxby.map.MapApp)customDB.map.getApp()).getFrame(),name);
testDialog.addWindowListener(this);
JPanel selectSedimentPanel = new JPanel( new BorderLayout() );
selectSedimentPanel.setBorder( BorderFactory.createEmptyBorder( 10, 10, 10, 10 ) );
JPanel sedimentDialogBottomPanel = new JPanel( new GridLayout(0,1) );
JPanel sedimentDialogSouthPanel = new JPanel( new FlowLayout());
columnCB = new JComboBox();
JLabel sedimentLabel = new JLabel("");
saveDataB = new JButton("Save Data");
columnCB.addItemListener(this);
columnCB.setAlignmentX(Component.LEFT_ALIGNMENT);
saveDataB.addActionListener(this);
testDialog.setLayout( new BorderLayout() );
testDialog.getContentPane().add( selectSedimentPanel, "North" );
sedimentDialogSouthPanel.add(saveDataB);
sedimentDialogBottomPanel.add(sedimentDialogSouthPanel);
sedimentDialogBottomPanel.add( sedimentLabel);
testDialog.getContentPane().add( sedimentDialogBottomPanel, "South" );
CustomBRGTable testPts;
testPts = new CustomBRGTable(urlString);
String[] columnHeadings = null;
columnHeadings = testPts.getColumnHeadings();
for ( int i = 1; i < columnHeadings.length; i++ ) {
columnCB.addItem(columnHeadings[i]);
}
if ( columnCB.getItemCount() > 1 ) {
selectSedimentPanel.add(columnCB, BorderLayout.WEST );
}
testGraph = new CustomXYGraph( testPts, 0 );
selectAddColumnCB = new JComboBox();
selectAddColumnCB.addItem("Add Graph");
for ( int i = 1; i < ((CustomBRGTable)testGraph.getPoints()).getColumnHeadings().length; i++ ) {
selectAddColumnCB.addItem(((CustomBRGTable)testGraph.getPoints()).getColumnHeadings()[i]);
}
selectAddColumnCB.addActionListener(this);
sedimentDialogSouthPanel.add(selectAddColumnCB);
flipYAxisCB = new JCheckBox("Flip Y-Axis", CustomBRGTable.REVERSE_Y_AXIS );
ignoreZerosCB = new JCheckBox("Ignore 0's", CustomBRGTable.IGNORE_ZEROS );
flipYAxisCB.addActionListener(this);
ignoreZerosCB.addActionListener(this);
sedimentDialogSouthPanel.add(flipYAxisCB, "East");
sedimentDialogSouthPanel.add(ignoreZerosCB);
Zoomer z = new Zoomer(testGraph);
testGraph.setScrollableTracksViewportWidth(true);
testGraph.setScrollableTracksViewportHeight(true);
testGraph.setMinimumSize(new Dimension(300, min_Height));
testGraph.setPreferredSize(new Dimension( 300, preferred_Height));
testGraph.setMaximumSize(new Dimension( 300, max_Height));
testGraph.setAlignmentX(Component.TOP_ALIGNMENT);
testGraph.addMouseListener(z);
testGraph.addKeyListener(z);
testGraph.addMouseMotionListener(this);
testBox.add(testGraph);
testBox.setMinimumSize(new Dimension( 400, min_Height));
testBox.setPreferredSize(new Dimension( 10000, preferred_Height));
testBox.setMaximumSize(new Dimension( 10000, max_Height));
JScrollPane sedimentSP = new JScrollPane( testBox, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
testDialog.getContentPane().add( sedimentSP, "Center" );
testDialog.pack();
testDialog.setLocation( 500, 500 );
testDialog.setSize( 600, 400 );
testDialog.setVisible(true);
} catch (IOException e) {
e.printStackTrace();
}
}