how can link two jframe
843805Feb 17 2006 — edited Feb 17 2006helo sir,
i am doing ME in anna university. i am doing project using java swing.i have doubt about how to link two jframes. my two jframes have separate class.
jframe1.java:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class jframe1 extends JFrame
{
JButton ok,cancel;
JRadioButton fsd,fmd;
Font ft;
Color bgclr;
Container con;
jframe1(String str)
{
super(str);
con = getContentPane();
setSize(305,280);
setLocation(270,130);
con.setLayout(null);
//bgclr = new Color(80,120,190);
con.setBackground(Color.gray);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
fsd = new JRadioButton("Full Subunit Design",false);
fmd = new JRadioButton("Full Main Unit Design",false);
ok = new JButton("Ok");
ok.setFont(ft);
cancel = new JButton("Cancel");
cancel.setFont(ft);
fsd.setBounds(75,70,150,20);
fmd.setBounds(75,110,170,20);
ok.setBounds(70,200,70,20);
cancel.setBounds(170,200,80,20);
con.add(fsd);
con.add(fmd);
//con.add(ptn);
ButtonGroup bg = new ButtonGroup();
bg.add(fsd);
bg.add(fmd);
con.add(ok);
con.add(cancel);
setVisible(true);
}
public static void main(String args[])
{
jframe1 jf1 = new jframe1("What would you like to design");
}
}
jframe2.java:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class jframe2 extends JFrame
{
JButton back,next,cancel;
JRadioButton edfdf,edge;
Container con;
jframe2(String str)
{
super(str);
con = getContentPane();
setSize(400,280);
setLocation(200,180);
con.setLayout(null);
con.setBackground(Color.blue);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
edfdf = new JRadioButton("Emitter discharge from design factors");
edge = new JRadioButton("Emitter discharge for a given emitter");
back = new JButton("<<Back");
next = new JButton("Next>>");
cancel = new JButton("Cancel");
JPanel ptn = new JPanel();
ptn.setBorder(BorderFactory.createLineBorder(Color.green,2));
ptn.setBounds(50,40,300,130);
edfdf.setBounds(70,70,250,20);
edge.setBounds(70,110,250,20);
back.setBounds(60,200,80,20);
next.setBounds(170,200,75,20);
cancel.setBounds(270,200,75,20);
con.add(edfdf);
con.add(edge);
con.add(ptn);
ButtonGroup bg = new ButtonGroup();
bg.add(edfdf);
bg.add(edge);
con.add(back);
con.add(next);
con.add(cancel);
setVisible(true);
}
public static void main(String args[])
{
jframe2 jf2 = new jframe2("Emitter Discharge Selection");
}
}
above jframe1 & jframe2 my two classes.i will click ok button means that will go to jframe2 at same time i want hide jframe1 .
in my jframe2 class i have two button(back & next):
suppose, i will click back button means that will go to jframe1.at same time i want hide jframe2.at that time i want the already selected radiobutton in jframe1 is in selected state.
suppose, i will click next button means that will go to jframe3(i am not included code here).this way want work my jframes.
thanks....................
by
bakki