newbie problem: "cannot resolve symbol"
I'm working through some tutorials but I get errors even if i get the code CORRECT or I should say identical to the source code displayed on the web. For instance i get this:
****
E:\Java\New>javac SwingUI.java
SwingUI.java:41: not a statement
WindowListener 1 = new WindowAdapter() {
^
SwingUI.java:41: ';' expected
WindowListener 1 = new WindowAdapter() {
^
SwingUI.java:4: cannot resolve symbol
symbol : class ActionListener
location: class SwingUI
class SwingUI extends JFrame implements ActionListener {
^
SwingUI.java:25: cannot resolve symbol
symbol : class ActionEvent
location: class SwingUI
public void actionPerformed(ActionEvent event){
^
SwingUI.java:15: addActionListener(java.awt.event.ActionListener) in javax.swing.AbstractButton cannot be applied to (SwingUI)
button.addActionListener(this);
^
SwingUI.java:18: cannot resolve symbol
symbol : class Borderlayout
location: class SwingUI
panel.setLayout(new Borderlayout());
^
SwingUI.java:46: addWindowListener(java.awt.event.WindowListener) in java.awt.Window cannot be applied to (int)
frame.addWindowListener(1);
^
SwingUI.java:48: cannot resolve symbol
symbol : variable set
location: class SwingUI
frame.set.Visible(true);
^
8 errors
*******
The beginning of the code is:
*******
import java.awt.Color;
import java.awt.BorderLayout;
import java.awt.event.*;
import javax.swing.*;
class SwingUI extends JFrame implements ActionListener {
JLabel text, clicked;
JButton button, clickButton;
JPanel panel;
private boolean _clickMeMode = true;
SwingUI(){
text=new JLabel("I'm a simple program");
button= new JButton("Click here!");
button.addActionListener(this);
panel =new JPanel();
panel.setLayout(new Borderlayout());
panel.setBackground(Color.white);
getContentPane().add(panel);
panel.add(BorderLayout.CENTER, text);
panel.add(BorderLayout.SOUTH, button);
}
...
*******
To me it seems as if there is a problem with my environmental settings and/or with the "import" files, but wouldn't that yield different error messages?
I'm running j2sdk1.4.0_01 on windows2000 professional
I should say that simple programs compile without errors.
thx
/Hans

