falkenberg_cph
February 13th, 2007, 03:41 PM
Hi
I have a problem with this program from Cay Horstmans "Java Concepts" - Project 2.2 (page. 62).
If i execute the program as mr. Horstman has written it, without "import java.awt.Color;" - i get a compiler error.
On the other hand, if i add "Import java.awt.Color;", i dont get a compile error, but eclipse gives me an error when i run the program. I am not at home right now, but when i am, i will post the eclipse error message.
Thanks
Carsten
import javax.swing.JFrame;
import javax.swing.JTextField;
// This is what i have added to the program
import java.awt.Color;
public class FrameTester
{
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setSize(200, 200);
JTextField text = new JTextField("Hello, World!");
text.setBackground(Color.PINK);
frame.add(text);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.setVisible(true);
}
}
I have a problem with this program from Cay Horstmans "Java Concepts" - Project 2.2 (page. 62).
If i execute the program as mr. Horstman has written it, without "import java.awt.Color;" - i get a compiler error.
On the other hand, if i add "Import java.awt.Color;", i dont get a compile error, but eclipse gives me an error when i run the program. I am not at home right now, but when i am, i will post the eclipse error message.
Thanks
Carsten
import javax.swing.JFrame;
import javax.swing.JTextField;
// This is what i have added to the program
import java.awt.Color;
public class FrameTester
{
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setSize(200, 200);
JTextField text = new JTextField("Hello, World!");
text.setBackground(Color.PINK);
frame.add(text);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.setVisible(true);
}
}