Results 1 to 2 of 2
  1. #1
    bbq
    bbq is offline Senior Member
    Join Date
    Jun 2007
    Posts
    132
    Rep Power
    0

    Default problems with jDialog in a JFrame

    I have a JFrame in which when I click in JButton appears a JDialog.

    The problem is that doesn’t do anything when I click register button
    my code is:
    Java Code:
    public class recordpage extends JDialog{ 
         
        private Container contain; 
        private JLabel Nick,  Pass,  ConfimPass,  Mail; 
        private JTextField textNick, textMail; 
        private JPasswordField textPass, textConfirmPass; 
        private JButton register; 
         
         public recordpage  (){ 
              
            super(); 
            Container contain =getContentPane(); 
            contain.setLayout(new FlowLayout()); 
            JLabel Nick =new JLabel("Nick "); 
            JLabel Pass =new JLabel ("password "); 
            JLabel ConfimPass new JLabel ("Confirm your password"); 
            JLabel Mail =new JLabel ("your email: "); 
            JTextField textNick =new JTextField ("", 10); 
            JPasswordField textPass =new JPasswordField("", 10); 
            JPasswordField textConfirmPass=new JPasswordField("", 10); 
            JTextField textMail =new JTextField("", 10); 
            JButton register=new JButton ("Log in"); 
            contain.add(Nick); 
            contain.add(textNick); 
            contain.add(Pass); 
            contain.add(textPass); 
            contain.add(ConfirmPass); 
            contain.add(textConfirmPass); 
            contain.add(Mail); 
            contain.add(textMail); 
            contain.add(register); 
            this.setTitle("Register"); 
            this.setModal(true); 
            this.setLocation(200, 150); 
            this.setSize(new Dimension(300, 180)); 
            this.setVisible(true); 
            registrar.addActionListener ( 
                new ActionListener(){ 
                    public void actionPerformed(ActionEvent ae){ 
                        dispose(); 
                    } 
                } 
            ); 
             
        } 
           
    }
    thanks

  2. #2
    Jack is offline Senior Member
    Join Date
    Jun 2007
    Posts
    130
    Rep Power
    0

    Default

    You're declaring JButton 2 times. One as class attribute and other as local variable of the method

Similar Threads

  1. Replies: 1
    Last Post: 03-28-2008, 11:26 AM
  2. help with jdialog
    By leonard in forum AWT / Swing
    Replies: 1
    Last Post: 08-05-2007, 06:37 AM
  3. Close a JDialog Programmatically
    By Marcus in forum Advanced Java
    Replies: 1
    Last Post: 07-06-2007, 05:06 PM
  4. Help with JFrame
    By Albert in forum AWT / Swing
    Replies: 2
    Last Post: 07-04-2007, 05:44 AM
  5. Replies: 1
    Last Post: 04-09-2007, 01:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •