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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java Applet- - Adding Componets to GUI-- 1.5sdk

Status
Not open for further replies.

biglurch

Programmer
Aug 25, 2005
35
US
I cannont figure out how to add components to my applet gui. I remember doing it with getContentPane(), but whenever i use that i get cannot resolve symbol, however it still is on the java api list. I am just attempting to add a jlabel to the gui, any help would be appreciated. Hers my code:
import java.awt.*;
import java.applet.*;
import javax.swing.*;

public class SubmitProject extends Applet {



public void init() {
JPanel panel = new JPanel();
Container container = new getContentPane();
JLabel companyName = new JLabel("Company Name: ");
panel.add(companyName);



}

public void paint(Graphics g) {
g.drawString("test text", 50, 60 );

}
}
 
Try extending JApplet instead.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
I get the error that cannot find sypbol class, getContentPane. Any suggestions?

Live by the code, Die by the code!!
 
new getContentPane();

is only used if there is a constructor getContentPane ().
But by convention, constructors are Capitalized.

getContentPane is a method, and was used in JFrame/ (Frame?) but is obsolet for java-5.

For (J)Panels, you added and add components directly.


seeking a job as java-programmer in Berlin:
 
thanks dude

Live by the code, Die by the code!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top