Hello, I've written a fairly simple program to print a string in a window...But my Java compiler (JGrasp) will not compile it. It says:
JDemoGraphics.java:7: cannot find symbol
symbol : method String(java.lang.String)
location: class JDemoGraphics
String companyName = String("Event Handlers Incorporated");
^
I've checked my capitalization, run a debugging program, and even added another import function.
I'm sure the answer is obvious, but I'm new enough to programming that I can't figure it out.
Thanks in advance for the help.
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class JDemoGraphics extends JFrame
{
String companyName = String("Event Handlers Incorporated");
public JDemoGraphics()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint(Graphics gr)
{
super.paint(gr);
gr.drawString(companyName, 30, 100);
}
public static void main(String[] args)
{
JDemoGraphics frame = new JDemoGraphics();
frame.setSize(300, 200);
frame.setVisible(true);
}
}