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

sir i dont understand make a clear statement

iam new to this

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

}

please help me sir

You need to get those classes to the point you can even run them first. You have most of the code in "login" in your main() method. Obviously it won't even compile. And why have you declared them abstract?

I think you are way too far ahead of yourself with this. Learn basic Java fundamentals before you try to hack together Swing code.

ok iam using this in eclipse .but b1.addactionlistener(this); shows as an error what is the reason sir???

Read the error message. I am guessing that it is reporting that class "login" does not implement ActionListener - because the whole class is broken. You can't put all that code inside main(). You also have to spell the methods correctly when overriding.

The errors in your current classes are numerous and you need to at least get the basic structures of them to a point that they will compile.

sir iam searching for login action program in google iam not getting it can u show or guide to my requirement????

hmmm excelent thread,

@ rithish

if you are using Eclipse then you can see red ocean, on both classes you totally ignore how to use braces for code folds

1/ 1st. character from ClassName should be UpperCase (both clasess)
2/ rename form to MyForm or whatewer, because Form (or form) is reserved for one Java.Method
3 - 25 later

edit: I spent 10min for that and that's pretty runnable (if I removed newbee mistakes)

thank u sir

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.