我有一個有三個狀態(三個項目,從0到2)的jcmbobox的jframe。在jcombobox中選擇一個項目時顯示jlabel
我想當用戶選擇第二項(1)我的jlabel應顯示!
但現在,當我選擇第二項,不要顯示它!在我的IDE菜單
public class LoginFrame extends javax.swing.JFrame {
public LoginFrame() {
initComponents();
this.setTitle("Library Management System Login");
this.setLocation(300, 50);
this.setResizable(false);
if (jComboBox1.getSelectedIndex() == 1) {
jLabel4.setVisible(true);
}
else{
jLabel4.setVisible(false);
}
}
我選擇的索引號爲0
RTFM:http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html – keuleJ