
I have two JFrame,built by using the GUI Editor netbeans 6.9.i have to pass a data from a Jtextfield in the first Jframe to another JLabel in the other JFrame.Can you please help me,how can i do so?PLease,i made lots of search but yet i can't do it...

Hi Friend,
Try this:
1)PassData.java:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class PassData extends JFrame
{
JTextField text;
PassData(){
JLabel l=new JLabel("Name: ");
text=new JTextField(20);
JButton b=new JButton("Send");
setLayout(null);
l.setBounds(10,10,100,20);
text.setBounds(120,10,150,20);
b.setBounds(120,40,80,20);
add(l);
add(text);
add(b);
setVisible(true);
setSize(300,100);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String value=text.getText();
NextPage page=new NextPage(value);
page.setVisible(true);
}
});
}
public static void main(String[] args)
{
new PassData();
}
}
2)NextPage.java:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class NextPage extends JFrame
{
NextPage(String st)
{
setLayout(null);
setDefaultCloseOperation(javax.swing. WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Welcome");
JLabel lab=new JLabel("Welcome "+st);
lab.setBounds(10,10,500,20);
add(lab);
setSize(300, 100);
}
}
Thanks

thanks for your answer. but when i close nextpage window, passdata window also is closed. how can i provide that passdata window is not close?

Thanks.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.