Results 1 to 2 of 2
  1. #1
    MR bruto's Avatar
    MR bruto is offline Senior Member
    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    130
    Rep Power
    0

    Default i got it! but i need help with this little thing.

    so i made a little program that lets you fill in "account information" such as username and password.
    there is a button "OK" in the bottom, when you click it it pops up a windows with "Account information:".

    but i really want to show the account information after that, the username and passwords you filled in.
    i don't really know how to do that, can you guys give me a hand?

    the code:

    Java Code:
    import java.awt.event.ActionEvent;
    import javax.swing.JLabel;
    import javax.swing.JFrame;
    import javax.swing.JButton;
    import javax.swing.JTextField;
    import javax.swing.JPasswordField;
    public class LogIn extends JFrame{
    	
    	private JTextField txt1;
    	private JPasswordField ps1;
    	private JPasswordField ps2;
    	private JLabel label1;
    	private JLabel label2;
    	private JLabel label3;
    	private JButton b1;
     
    	
    	
    
    
    public LogIn(){
    	super("Account");
    	setLayout (new FlowLayout());
    	label1 = new JLabel("Enter your username: ");
    	txt1 = new JTextField(10);
    	label2 = new JLabel("Enter your password: ");
    	ps1 = new JPasswordField(10);
    	label3 = new JLabel("Confirm your password: ");
    	ps2 = new JPasswordField(10);
    	b1 = new JButton("OK");
    	add(label1);
    	add(txt1);
    	add(label2);
    	add(ps1);
    	add(label3);
    	add(ps2);
    	add(b1);
    	
    	
    	thehandler handler = new thehandler();
    	b1.addActionListener(handler);
    	
    	
    }
    public class thehandler implements ActionListener{
    	public void actionPerformed(ActionEvent event){
    		
    		JOptionPane.showMessageDialog(null, "Account information: ", "Account Information", JOptionPane.INFORMATION_MESSAGE);
    		
    	
    		
    			
    			
    		
    	}
    }
    }

  2. #2
    monkeyjr97 is offline Senior Member
    Join Date
    Nov 2012
    Posts
    258
    Rep Power
    2

    Default Re: i got it! but i need help with this little thing.

    just add this in underneath

    JOptionPane.showMessageDialog(null, "Account information: User: " + txt1.getText() + " Password: " + ps1.getPassword(), "Account Information", JOptionPane.INFORMATION_MESSAGE);

    getPassword returns an array of char[] so you may need to handle that.
    Last edited by monkeyjr97; 05-08-2013 at 03:53 PM.

Similar Threads

  1. Need help with this whole thing :(
    By cvt in forum New To Java
    Replies: 2
    Last Post: 10-17-2012, 09:33 PM
  2. Very important thing for me.
    By Kukkurloom in forum Jobs Offered
    Replies: 5
    Last Post: 08-01-2012, 09:40 PM
  3. Goto like thing
    By EStrike in forum New To Java
    Replies: 22
    Last Post: 12-27-2011, 06:01 PM
  4. about static thing
    By ryozkidz in forum New To Java
    Replies: 8
    Last Post: 07-08-2011, 08:44 PM
  5. PLz i really need help on this final thing
    By jason27131 in forum New To Java
    Replies: 2
    Last Post: 08-03-2007, 03:31 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
  •