Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java Sing Problems - JFrame constructor/class not found

Status
Not open for further replies.

plotzer

Programmer
Aug 28, 2001
35
US
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
 
if other apps are doing it to, and they previously compiled then I think you are correct to assume that it is a path issue.

Just as a matter of interest, are you coding this in an IDE or just typing code into a text editor? If the former, you may have somehow messed up your configuration.
 
pipk,

Thanks for your input. I used a text editor for these programs, but I do have Forte installed on my computer and I was playing around with it recently doing some gui sstuff. You might be right, that could be the root of my problem. I tinker with it and let you know.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top