Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

can not resolve symbol in method showMessageDialog

843810Apr 15 2006 — edited Oct 16 2006
I 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();
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 13 2006
Added on Apr 15 2006
2 comments
1,000 views