import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public abstract class login extends JFrame implements ActionListener {
public static void main(String[] args) {
JTextField firstField = new JTextField(10);
JPasswordField middleField = new JPasswordField(10);
JButton b1=new JButton("ok");
JLabel firstLabel = new JLabel("username", JLabel.RIGHT);
firstLabel.setDisplayedMnemonic('F');
firstLabel.setLabelFor(firstField);
JLabel middleLabel = new JLabel("password", JLabel.RIGHT);
middleLabel.setDisplayedMnemonic('I');
middleLabel.setLabelFor(middleField);
JPanel p = new JPanel( );
p.setLayout(new GridLayout(3, 2, 5, 5));
p.add(firstLabel);
p.add(firstField);
p.add(middleLabel);
p.add(middleField);
p.add(b1);
b1.addActionListener(this);
JFrame f = new JFrame("login");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setContentPane(p);
f.pack( );
f.setVisible(true);
public void actionperformed(ActionEvent e)
{
Object firstField;
Object middleField;
if((firstField.equals("r"))&&middleField.equals("r "))
{
Object b1;
if((e.getSource()==b1))
{
form form1= new form();
}
}
}
}
}
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public abstract class form extends JFrame implements ActionListener{
form()
{
JFrame f1=new JFrame();
JRadioButton r1=new JRadioButton("candidate");
JRadioButton r2=new JRadioButton("public");
JButton b2=new JButton("ok");
JPanel p1=new JPanel();
p1.setLayout(new GridLayout(3,2,5,5));
p1.add(r1);
p1.add(r2);
p1.add(b2);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f1.setContentPane(p1);
f1.pack();
f1.setVisible(true);
r1.addActionListener(this);
r2.addActionListener(this);
b2.addActionListener(this);
f1.setVisible(true);
public actionperformed(ActionEvent e){
if((e.getSource()==r1)&&(e.getSource()==b2))
{
candidate1 can=new candidate1();
}
else
if((e.getSource()==r2) && (e.getSource()==b2))
{
public1 pub=new public1();
}
}
}
}
i use eclipse in first tab i run that login form and when i enter text and password field as r and click button it should enter new form how can i do that