Not sure why this happened. I've made no change to my computer, yet today I am unable to
compile the following code, when I was able to do it the day before. The code is a sample program I downloaded, compiled and ran the day before. For some reason JFrame is
not understood. Not sure if this is a Classpath issue. I have some other sample swing apps that give the same error too:
My Code:
import javax.swing.*;
import java.awt.*;
public class HelloWorld extends JApplet {
SwingHelloWorldPanel m_Panel;
public void init() {
m_Panel = new SwingHelloWorldPanel();
getContentPane().add("Center", m_Panel);
m_Panel.init();
}
public void start() {
m_Panel.start();
}
static class SwingHelloWorldPanel extends JPanel {
public void paint(Graphics g) {
super.paint(g);
Dimension size = getSize();
g.setColor(Color.lightGray);
g.fillRect(0,0,size.width,size.height);
g.setColor(Color.red);
g.drawString("Hello World",50,50);
}
// Override to do more interesting work
public void init() {
}
public void start() { }
// end inner class SwingHelloWorldPanel
}
public static void main(String args[]) {
JFrame f = new JFrame("SwingHelloWorld"
;
// Create the panel and p*** init and start to it
SwingHelloWorldPanel hello = new SwingHelloWorldPanel();
// NOTE the call to getContentPane - this is important
f.getContentPane().add(hello);
hello.init();
hello.start();
f.setSize(300, 300);
f.show();
}
}
The error:
C:\java_dev>javac HelloWorld.java
HelloWorld.java:71: cannot resolve symbol
symbol : constructor JFrame (java.lang.String)
location: class JFrame
JFrame f = new JFrame("SwingHelloWorld"
;
^
1 error
Thanks in advance
compile the following code, when I was able to do it the day before. The code is a sample program I downloaded, compiled and ran the day before. For some reason JFrame is
not understood. Not sure if this is a Classpath issue. I have some other sample swing apps that give the same error too:
My Code:
import javax.swing.*;
import java.awt.*;
public class HelloWorld extends JApplet {
SwingHelloWorldPanel m_Panel;
public void init() {
m_Panel = new SwingHelloWorldPanel();
getContentPane().add("Center", m_Panel);
m_Panel.init();
}
public void start() {
m_Panel.start();
}
static class SwingHelloWorldPanel extends JPanel {
public void paint(Graphics g) {
super.paint(g);
Dimension size = getSize();
g.setColor(Color.lightGray);
g.fillRect(0,0,size.width,size.height);
g.setColor(Color.red);
g.drawString("Hello World",50,50);
}
// Override to do more interesting work
public void init() {
}
public void start() { }
// end inner class SwingHelloWorldPanel
}
public static void main(String args[]) {
JFrame f = new JFrame("SwingHelloWorld"
// Create the panel and p*** init and start to it
SwingHelloWorldPanel hello = new SwingHelloWorldPanel();
// NOTE the call to getContentPane - this is important
f.getContentPane().add(hello);
hello.init();
hello.start();
f.setSize(300, 300);
f.show();
}
}
The error:
C:\java_dev>javac HelloWorld.java
HelloWorld.java:71: cannot resolve symbol
symbol : constructor JFrame (java.lang.String)
location: class JFrame
JFrame f = new JFrame("SwingHelloWorld"
^
1 error
Thanks in advance