Java 如何使按钮可见?

Java 如何使按钮可见?,java,Java,我通过自定义代码使按钮默认不可见。 但现在我的问题是我不能让按钮可见!我想要的是,当用户登录时,意味着注销按钮应该可见。 我如何使用netbeans实现它?有人能帮我吗?我是JAVA GUI新手。我应该在这里添加什么条件 JLabel j1; public NewJFrame() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc=

我通过自定义代码使按钮默认不可见。 但现在我的问题是我不能让按钮可见!我想要的是,当用户登录时,意味着注销按钮应该可见。 我如何使用netbeans实现它?有人能帮我吗?我是JAVA GUI新手。我应该在这里添加什么条件

 JLabel j1;

public NewJFrame() {
    initComponents();
}

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jTextField1 = new javax.swing.JTextField();
    jButton4 = new javax.swing.JButton();
    jLabel5 = new javax.swing.JLabel();
    jLabel1 = new javax.swing.JLabel();
    jComboBox1 = new javax.swing.JComboBox();
    jButton1 = new javax.swing.JButton();
    jTextField3 = new javax.swing.JTextField();
    jButton2 = new javax.swing.JButton();
    jPasswordField1 = new javax.swing.JPasswordField();
    jButton3 = new javax.swing.JButton();
    jButton5 = new javax.swing.JButton();
    jLabel6 = new javax.swing.JLabel();
    jComboBox2 = new javax.swing.JComboBox();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    jTextField2 = new javax.swing.JTextField();
    jComboBox3 = new javax.swing.JComboBox();
    jLabel9 = new javax.swing.JLabel();
    jLabel10 = new javax.swing.JLabel();
    jButton6 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jLabel2.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N
    jLabel2.setForeground(new java.awt.Color(102, 255, 0));
    jLabel2.setText("EMAIL");

    jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N
    jLabel3.setForeground(new java.awt.Color(102, 255, 0));
    jLabel3.setText("PASSWORD");

    jTextField1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 153), 2, true));
    jTextField1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField1ActionPerformed(evt);
        }
    });

    jButton4.setBackground(new java.awt.Color(0, 153, 255));
    jButton4.setFont(new java.awt.Font("Times New Roman", 1, 36)); // NOI18N
    jButton4.setText("Log In");
    jButton4.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(0, 153, 255), null, null)));
    jButton4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
        }
    });

    jLabel5.setBackground(new java.awt.Color(255, 153, 102));
    jLabel5.setFont(new java.awt.Font("Rockwell Extra Bold", 3, 24)); // NOI18N
    jLabel5.setForeground(new java.awt.Color(255, 0, 204));
    jLabel5.setText("SELECT TYPE");

    jLabel1.setBackground(new java.awt.Color(153, 102, 255));
    jLabel1.setFont(new java.awt.Font("Bookman Old Style", 3, 48)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(255, 0, 204));
    jLabel1.setText("SHOPPERS BAY...");
    jLabel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(255, 102, 102), new java.awt.Color(255, 255, 102), null));
    jLabel1.setIconTextGap(2);

    jComboBox1.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
    jComboBox1.setForeground(new java.awt.Color(0, 0, 51));
    jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "CLOTHES", "ACCESSORIES", "SHOES" }));
    jComboBox1.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createCompoundBorder(), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));

    jButton1.setBackground(new java.awt.Color(0, 153, 255));
    jButton1.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
    jButton1.setText("OK");
    jButton1.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(0, 153, 255), new java.awt.Color(0, 153, 255), null, null)));
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    jTextField3.setForeground(new java.awt.Color(153, 153, 153));
    jTextField3.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 255), 1, true));
    jTextField3.setDisabledTextColor(new java.awt.Color(0, 0, 0));
    jTextField3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField3ActionPerformed(evt);
        }
    });

    jButton2.setBackground(new java.awt.Color(255, 51, 51));
    jButton2.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
    jButton2.setText("SEARCH");
    jButton2.setBorder(javax.swing.BorderFactory.createCompoundBorder(null, javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });

    jPasswordField1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 153), 2, true));

    jButton3.setBackground(new java.awt.Color(0, 153, 255));
    jButton3.setFont(new java.awt.Font("Times New Roman", 1, 36)); // NOI18N
    jButton3.setText("Register");
    jButton3.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(0, 153, 255), null, null)));
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });

    jButton5.setFont(new java.awt.Font("Stencil", 3, 14)); // NOI18N
    jButton5.setForeground(new java.awt.Color(204, 0, 0));
    jButton5.setText("ACCOUNTS");
    jButton5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(102, 204, 0), null, new java.awt.Color(102, 51, 0)));
    jButton5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton5ActionPerformed(evt);
        }
    });

    jLabel6.setFont(new java.awt.Font("Tahoma", 3, 24)); // NOI18N
    jLabel6.setForeground(new java.awt.Color(255, 0, 204));
    jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel6.setText("New User?");

    jComboBox2.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
    jComboBox2.setForeground(new java.awt.Color(0, 0, 51));
    jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "VISITOR", "ACCOUNTANT", "ADMINISTRATOR" }));
    jComboBox2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(102, 255, 0), null, null));
    jComboBox2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jComboBox2ActionPerformed(evt);
        }
    });

    jLabel7.setFont(new java.awt.Font("SimSun-ExtB", 1, 11)); // NOI18N
    jLabel7.setForeground(new java.awt.Color(102, 255, 0));
    jLabel7.setText("PRICE:");

    jLabel8.setText("to");

    jTextField2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 255), 1, true));

    jComboBox3.setBackground(new java.awt.Color(255, 204, 204));
    jComboBox3.setFont(new java.awt.Font("Stencil", 1, 12)); // NOI18N
    jComboBox3.setForeground(new java.awt.Color(51, 51, 255));
    jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "CLOTHES", "ACCESSORIES", "SHOES" }));
    jComboBox3.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(255, 0, 204)));

    jLabel9.setFont(new java.awt.Font("SimSun-ExtB", 1, 12)); // NOI18N
    jLabel9.setForeground(new java.awt.Color(102, 255, 0));
    jLabel9.setText("CATEGORY:");

    jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/finalproject/Collages - Copy1.png"))); // NOI18N

    jButton6.setText("LOGOUT");
    jButton6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton6ActionPerformed(evt);
        }
    });
    jButton6.setVisible(false);
    if(jComboBox2.getSelectedItem()=="ADMINISTRATOR")
    jButton6.setVisible(true);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(30, 30, 30)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel1)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(59, 59, 59)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(69, 69, 69)
                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(107, 107, 107)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jButton6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(58, 58, 58)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(4, 4, 4)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(10, 10, 10)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(10, 10, 10)
                            .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addGap(79, 79, 79)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 8, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(184, 184, 184))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(168, 168, 168))))))
                .addComponent(jLabel10))
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jLabel3)
                .addComponent(jLabel2))
            .addGap(18, 18, 18)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(67, 67, 67))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(33, 33, 33)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel9)
                            .addGap(14, 14, 14)
                            .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(1, 1, 1)
                            .addComponent(jLabel7)
                            .addGap(14, 14, 14)
                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(28, 28, 28)
                            .addComponent(jLabel8))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(27, 27, 27)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(24, 24, 24)
                            .addComponent(jButton2)))
                    .addGap(33, 33, 33))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
            .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(3, 3, 3)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2))
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel3)))
                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(20, 20, 20)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(80, 80, 80))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))))
            .addGap(7, 7, 7)
            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE))
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(48, 48, 48)))
            .addComponent(jButton5))
    );

    pack();
}// </editor-fold>                        

private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
    // TODO add your handling code here:
}                                                                             
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         

        Connection conn=null;
    try{
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
        conn =DriverManager.getConnection(DB_URL, USER, PASS);
        Statement stmt=conn.createStatement();

        String S1 = jTextField1.getText();
        String S2 = jPasswordField1.getText().toString();
        String S3=jComboBox2.getSelectedItem().toString();
       // System.out.println("User: "+userName + " Password: "+ passWord);

        // if user name is blank, warning message shown
        if(S1.isEmpty() || S1 == null){
            JOptionPane.showMessageDialog(null, "Please insert a valid user name", "Warning", JOptionPane.WARNING_MESSAGE);
            return;
        }
        // if password is blank, warning message shown
        if(S2.isEmpty() || S2 == null){
            JOptionPane.showMessageDialog(null, "Password field is empty", "Warning", JOptionPane.WARNING_MESSAGE);
            return;
        }

        int flag=0;
        String sql;
        sql="SELECT * from member where EMAIL='"+S1+"'";
        ResultSet rs=stmt.executeQuery(sql);
        //System.out.println(rs.next());
        String uname="",pw="",category="";
        while(rs.next()){                       
        uname=rs.getString("EMAIL");
        pw=rs.getString("PASSWORD");
        category=rs.getString("CATEGORY");

        if(uname.matches(S1) && pw.equals(S2)==true && category.matches(S3))
        {
            flag=1;
            /*setVisible(false);
    Congrats J7=new Congrats();
    J7.getContentPane().setBackground(Color.green);
    J7.setVisible(true); */
          if(jComboBox2.getSelectedItem()=="VISITOR")
    {
        setVisible(false);
    NewJFrame f1=new NewJFrame();
    f1.setVisible(true);
    jButton6.setVisible(true);
    }
    else if(jComboBox2.getSelectedItem()=="ACCOUNTANT")
    {
         setVisible(false);
    inter4 f=new inter4();
    f.setVisible(true);
    }
    else if(jComboBox2.getSelectedItem()=="ADMINISTRATOR")
    {
      setVisible(false);
    NewJFrame f1=new NewJFrame();
    f1.setVisible(true);
    }
         }
        } 
        if(flag==0)
            JOptionPane.showMessageDialog(null,"login failed");      
        stmt.close();
        conn.close();
        }
    catch(SQLException ss){
      ss.printStackTrace(); 
}   

}                                        

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    setVisible(false);
    NewJFrame21 fF=new NewJFrame21();
    fF.getContentPane().setBackground(Color.magenta);
    fF.setVisible(true);
}                                        

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    setVisible(false);
    inter4 J1=new inter4();
    J1.getContentPane().setBackground(Color.green);
    J1.setVisible(true);

}                                        


// Variables declaration - do not modify                     
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JComboBox jComboBox3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPasswordField jPasswordField1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
// End of variables declaration                   

private ImageIcon format=null;
}
JLabel j1;
公共NewJFrame(){
初始化组件();
}
@抑制警告(“未选中”)
//                           
私有组件(){
jLabel2=newjavax.swing.JLabel();
jLabel3=newjavax.swing.JLabel();
jTextField1=newjavax.swing.JTextField();
jButton4=newjavax.swing.JButton();
jLabel5=newjavax.swing.JLabel();
jLabel1=newjavax.swing.JLabel();
jcombox1=newjavax.swing.JComboBox();
jButton1=newjavax.swing.JButton();
jTextField3=newjavax.swing.JTextField();
jButton2=newjavax.swing.JButton();
jPasswordField1=newjavax.swing.JPasswordField();
jButton3=newjavax.swing.JButton();
jButton5=newjavax.swing.JButton();
jLabel6=newjavax.swing.JLabel();
jcombox2=newjavax.swing.JComboBox();
jLabel7=newjavax.swing.JLabel();
jLabel8=newjavax.swing.JLabel();
jTextField2=newjavax.swing.JTextField();
jcombox3=newjavax.swing.jcombox();
jLabel9=newjavax.swing.JLabel();
jLabel10=newjavax.swing.JLabel();
jButton6=newjavax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel2.setFont(新的java.awt.Font(“SegoeUI”,1,24));//NOI18N
set前台(新java.awt.Color(102255,0));
jLabel2.setText(“电子邮件”);
jLabel3.setFont(新的java.awt.Font(“SegoeUI”,1,24));//NOI18N
setForeground(新java.awt.Color(102255,0));
jLabel3.setText(“密码”);
jTextField1.setboorder(新的javax.swing.border.LineBorder(新的java.awt.Color(255,0153),2,true));
jTextField1.addActionListener(新java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
JTextfield1执行的操作(evt);
}
});
setBackground(新java.awt.Color(0153255));
jButton4.setFont(新java.awt.Font(“Times new Roman”,1,36));//NOI18N
jButton4.setText(“登录”);
jButton4.setboorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.border.BevelBorder.RAISED),javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED,null,new java.awt.Color(0,153,255),null));
jButton4.addActionListener(新java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
jButton4ActionPerformed(evt);
}
});
jLabel5.setBackground(新java.awt.Color(255153102));
jLabel5.setFont(新的java.awt.Font(“Rockwell额外加粗”,3,24));//NOI18N
setForeground(新java.awt.Color(255,0204));
jLabel5.setText(“选择类型”);
setBackground(新java.awt.Color(153102255));
jLabel1.setFont(新java.awt.Font(“Bookman Old Style”,3,48));//NOI18N
setForeground(新java.awt.Color(255,0204));
jLabel1.setText(“购物者湾…”);
jLabel1.setboorder(javax.swing.BorderFactory.createBevelOrder(javax.swing.border.BevelOrder.RAISED,null,新java.awt.Color(255,102,102),新java.awt.Color(255,255,102),null));
jLabel1.setIconTextGap(2);
jComboBox1.setFont(新java.awt.Font(“Times new Roman”,1,18));//NOI18N
set前台(新java.awt.Color(0,0,51));
setModel(新的javax.swing.DefaultComboxModel(新的字符串[]{“衣服”、“附件”、“鞋子”}));
jcombox1.setBorder(javax.swing.BorderFactory.CreateComoundBorder(javax.swing.BorderFactory.CreateComoundBorder(),javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelOrder.RAISED));
setBackground(新java.awt.Color(0153255));
jButton1.setFont(新java.awt.Font(“Times new Roman”,1,24));//NOI18N
jButton1.setText(“OK”);
jButton1.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.border.BevelBorder.RAISED),javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED,new java.awt.Color(0,153,255),new java.awt.Color(0,153,255),null,null));
jButton1.addActionListener(新java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
jButton1ActionPerformed(evt);
}
});
jTextField3.set前台(新java.awt.Color(153153153));
jTextField3.setboorder(新的javax.swing.border.LineBorder(新的java.awt.Color(255,0255),1,true));
setDisabledTextColor(新java.awt.Color(0,0,0));
jTextField3.addActionListener(新java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
JTextField3执行的操作(evt);
}
});
setBackground(新java.awt.Color(255,51,51));
jButton2.setFont(新java.awt.Font(“Times new Roman”,1,14));//NOI18N
jButton2.setText(“搜索”);
jButton2.setboorder(javax.swing.BorderFactory.createCompoundBorder(null,javax.swing.BorderFactory.createBevelOrder(javax.swing.border.BevelOrder.RAISED));
jButton2.addActionListener(新java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt){
jButton2ActionPerformed(evt);
}
});
jPasswordField1.setboorder(新的javax.swing.border.LineBorder(新的java.awt.Color(255,0,153),2,true));
setBackground(新java.awt.Color(0153255));
jButton3.setFont(新java.awt.Font(“Times new Roman”,1,36));//NOI18N
jButton3.setText(“寄存器”);
setboorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.Bor
class GUIExample implements ActionListener{
JButton logIn, logOut;
JFrame frame;    //the application main frame
GUIExample(){
    frame = new JFrame("GUI Example in Swing");    //frame's head text
    logIn = new JButton("LOG IN");
    logOut = new JButton("LOG OUT");
    frame.setSize(300,400);
    frame.setVisible(true);
    frame.add(logIn);
    logIn.setVisible(true);
    frame.add(logOut);
    logOut.setVisible(false);        //The LOG OUT is invisible now!
    logIn.addActionListener(this);        //this tells the JVM to keep an eye on this
                                          // button and run the actionPerformed method
                                          // if it gets pushed!
}
    public void actionPerformed(ActionEvent e){

        JButton src = (JButton) e.getSource()    //get the objectthat triggered the event
        if (src.equals(logIn))        //if the source is the LOG IN button (in our case it is the only thing that can trigger an event)
            logOut.setVisible(true);    ///finally! make the LOG OUT visible!
    }
public static void main (String args[]){
    new GUIExample();
}
 import javax.swing.*;
 import java.awt.event.*;