I had a problem in netbeans That is passing valus from one form to another form.....Lets do it now
i want to get user name from this form and pass it to another form let go on
In the login button type this chord
String user = jTextField1.getText();
String pw = new String(jPasswordField1.getPassword());
if(user.equals("akila")&& pw.equals("akila")){
this.setVisible(false);
new voteing(user).setVisible(true);
}
else {
JOptionPane.showMessageDialog(null, "Incorrect user name or password","Error",3);
}
now we are passing String user to the another form called voteing ,,,You can also pass double int or anything like this ....In net beans now you will get a error.......now netbeans will ask you to creaTE A CONSTRUCTOR in next form ........Let netbeans to do that
this is my next form you can see at the bottem user akila has benn passed to this form..Lets see how to create a constructor in this form .....Go to sourcr and type in the bottem in jFrame
voteing(String user) {
username = user;
initComponents();
}
Now, right click your welcome form and go to>Events>Window>windowOpened and use the username variable set it wherever you want!
Example:-
label.setText(username);Now, go back to login form and press Shift + F6 to run your file. Enter your username and password and click login to see your name on the next screen.
I THINK YOU HAVE GAINED SOMETHING IN THIS TUTORIAL..CU GUYS FROM THE NEXT TUTORIAL.................................................................


please comment your ideas about this
ReplyDeleteblog