
Hi, I want 2 separate windows,when i click on a 1st window submit btn then it will show 2nd window. In 2nd window i want 1 textbox.i entered some text on that text box and when i close the 2nd window then the text in textbox displayed in 1st window test field.plzzzzz provide the code in swings.
Thanks in advance

1)Frame1.java:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Frame1{
public static void main(String[] args){
Frame1 sr = new Frame1("");
}
public Frame1(String st){
final JFrame frame = new JFrame("Frame1");
frame.setLayout(null);
JTextField text=new JTextField(20);
text.setText(st);
JButton b = new JButton("Submit");
b.setBounds(20,20,80,20);
text.setBounds(20,50,100,20);
frame.add(b);
frame.add(text);
frame.setSize(400,200);
frame.setVisible(true);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Frame2 f=new Frame2();
frame.setVisible(false);
f.setVisible(true);
f.setSize(300,100);
}
});
}
}
2)Frame2.java:
import javax.swing.*;
import java.awt.event.*;
class Frame2 extends JFrame
{
Frame2()
{
setTitle("Frame2");
JLabel lab=new JLabel("Enter text: ");
final JTextField text=new JTextField(20);
JButton b=new JButton("Click");
setLayout(null);
lab.setBounds(10,10,150,20);
text.setBounds(170,10,100,20);
b.setBounds(10,40,100,20);
add(lab);
add(text);
add(b);
setVisible(true);
setSize(400,200);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setVisible(false);
new Frame1(text.getText());
}
});
}
}
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.