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

    Default login action to anotherform

    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

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

Similar Threads

  1. Replies: 3
    Last Post: 08-19-2010, 09:27 AM
  2. Replies: 7
    Last Post: 04-21-2009, 07:00 AM
  3. login.jsp
    By roo7 in forum Enterprise JavaBeans (EJB)
    Replies: 5
    Last Post: 12-02-2008, 04:58 PM
  4. Login page
    By banie in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-03-2008, 03:05 PM
  5. Replies: 0
    Last Post: 06-25-2008, 01:41 PM

Posting Permissions

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