can not resolve symbol in method showMessageDialog
843810Apr 15 2006 — edited Oct 16 2006I tried to dispaly a mesg using JOptionPane, it gives error mesg like
HWS.java:27: cannot resolve symbol
symbol : method showMessageDialog (<anonymous java.awt.event.ActionListener>,j
ava.lang.String,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog (this, "The","Exit", JOptionPane.INFORMATION_M
ESSAGE);
^
pls help.
Sabarish
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class HWS extends JFrame{
public HWS() {
super("Learning...");
setSize(300,300);
JLabel label2 = new JLabel("Jegan Rao");
JButton button = new JButton("Click here");
Container pane = getContentPane();
pane.setLayout(new FlowLayout());
pane.add(button);
pane.add(label2);
ActionListener al = new ActionListener(){
public void actionPerformed (ActionEvent ae){
JOptionPane.showMessageDialog (this, "The","Exit", JOptionPane.INFORMATION_MESSAGE);
}
};
button.setHorizontalAlignment(JButton.CENTER);
button.addActionListener(al);
button.setVerticalAlignment(JButton.CENTER);
label2.setHorizontalAlignment(JLabel.CENTER);
label2.setVerticalAlignment(JLabel.CENTER);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}
public static void main(String [] args){
HWS h = new HWS();
}
}