hello i use eclipse when i add action listener for button it marks as redline iam using swing component what is the problem ?what is the actual problem in that

Recommended Answers

All 7 Replies

The real answer is: if you're asking this sort of question, you shouldn't be using Eclipse yet.
That's not the answer you want, though. There's probably something wrong with the way you're doing it, but since we can't see what you're doing, there's no way to know what you're doing wrong. If you post the relevant code, someone will probably be able to help you out.

import java.awt.*;
import javax.swing.*;

import java.awt.event.*;


public class MoveFrame extends JFrame{
JLabel label=new JLabel();
JTextField text=new JTextField(20);
JPanel panel=new JPanel(new GridLayout(2,2));
JButton button1 =new JButton("OK");
JButton button2 =new JButton("Next");
JPanel p1=new JPanel();
JButton b3=new JButton("next1");
JPanel p2=new JPanel();
JButton b4=new JButton("next2");
public MoveFrame(){
label.setText("Enter Name:");
panel.add(label);
panel.add(text);
panel.add(button1);
panel.add(button2);
add(panel,BorderLayout.CENTER);
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
JOptionPane.showConfirmDialog(null, "Are you Confirm?");
}
});
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
JFrame f1=new JFrame();
p1.add(b3);
f1.add(p1);
f1.setVisible(true);

}

});
b3.addActionListener(new ActionListener()  {
	public void actionperformed(ActionEvent ae){
		JFrame f2=new JFrame();
		p2.add(b4);
		f2.add(p2);
		f2.setVisible(true);


	}
});




}
public static void main(String arg[]){
MoveFrame frame=new MoveFrame();
frame.setSize(300,100);
frame.setVisible(true);
}
}

my code sir

i dont understand where is the error every thing i have written correctly please sort my problem sir

Typo. "actionperformed" should be actionPerformed.

As I say, you really need to learn to code by hand before you start using power tools.

Ezzaral sir extremely thanks code is working perfectly.the reason i use eclipse is beacuse of case sensitive sir .if i use notepad each and everything i have to check .in eclipse if i give quickfix many errors get solved

It's your choice. "Quickfix" is a useful tool if you already know the language, but all it's doing for you now is preventing you from learning java.

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.