所以,我的问题是:当从JComboBox中选择“Perimeter”时,我将如何进行制作以使标签(保存在JTabbedPane中)出现在前面?同样有区域或其他标签。
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
String selectedItem = jComboBox1.getSelectedItem().toString();
if(selectedItem != null)
{
//if perimeter option selected, show the tab for it
if(selectedItem.equals("Perimeter"))
{
//bring the permeter tab to the front, all contained within a tabbedPane
}
if(selectedItem.equals("Area"))
{
//bring the area tab to the front, all contained within a tabbedPane
}
}
}
答案 0 :(得分:0)
您可以将它用作show而不是show选项,这样如果他们选择了周边,它会在选项卡式窗格中显示周边信息。
frame.setVisible(true);
或者如果您希望将此选项卡式窗格放在另一个上面,可以尝试: Java Swing - how to show a panel on top of another panel?
答案 1 :(得分:0)
我想你可能正在寻找这个: http://download.oracle.com/javase/6/docs/api/javax/swing/JTabbedPane.html#setSelectedIndex%28int%29
TabbedPane .setSelectedIndex(int)