JAVA用JComboBox,Java JComboBox.setAlignmentX方法代码示例

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();

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值