Results 1 to 2 of 2
  1. #1
    rithish is offline Member
    Join Date
    Apr 2011
    Posts
    39
    Rep Power
    0

    Angry login action to anotherform swing help

    hello please view my code and say what mistake i have done


    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();


    }

    }


    }

    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. login action to anotherform
    By rithish in forum AWT / Swing
    Replies: 3
    Last Post: 04-21-2011, 05:36 AM
  2. login action to anotherform
    By rithish in forum SWT / JFace
    Replies: 1
    Last Post: 04-21-2011, 03:11 AM
  3. login action to anotherform swing
    By rithish in forum AWT / Swing
    Replies: 15
    Last Post: 04-20-2011, 10:01 PM
  4. Java Swing Login Form
    By sehudson in forum Advanced Java
    Replies: 5
    Last Post: 06-01-2010, 11:53 AM
  5. Replies: 7
    Last Post: 04-21-2009, 06:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •