Thread: JApplet Problem
View Single Post
  #2 (permalink)  
Old 07-26-2008, 11:08 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
// <applet code="NewClassApplet" width="400" height="400"></applet> import java.awt.*; import javax.swing.*; public class NewClassApplet extends JApplet { public void init() { JButton jb = new JButton("Send"); // This is useless here. //jb.setVisible(true); JPanel panel = new JPanel(); panel.add(jb); getContentPane().add(panel); // An alternate approach: //getContentPane().add(panel, "Last"); } public void paint(Graphics g) { // One of the few times you need to call // "super" in a paint method is if // the container has light-weight children. // This method will draw on top of children. super.paint(g); g.drawString("Hello",10,10); } }
Reply With Quote