File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes about drawing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about drawing" Watch "about drawing" New topic

about drawing

Aimin Fei

Joined: Aug 11, 2001
Posts: 2
Hello evrybody!
I want to draw a shape on a panel inside an applet. How can it be done?
class A extends JApplet
JPanel myPanel = new JPanel();
public void init()
add the myPanel to north of the applet;
public void paint(Graphics g)
// all drawing here are on applet. How can I draw on
// myPanle
Suma MM
Ranch Hand

Joined: Apr 30, 2001
Posts: 31
< html >
< applet code=A.class height=400 width=800>
< /applet>
< /body>< /html>

-----------------------------------------------------------------import java.awt.*;
import javax.swing.*;
public class A extends JApplet
JPanel myPanel;
Container c;
public void init()
myPanel = new JPanel();
c = getContentPane();
public void paint(Graphics g)
I don't understand why u would want to draw a shape on a panel because even without a panel, u would be getting the same output; the reason being that both JApplet and JPanel inherit (directly/indirectly) from the class "Container".
[This message has been edited by Suma MM (edited August 12, 2001).]
[This message has been edited by Suma MM (edited August 12, 2001).]
I agree. Here's the link:
subject: about drawing
Similar Threads
more tabbedpane - panel questions
How to launch a webpage from a browser from an application and an applet
How do I draw .JPG Image to JPanel?
How to Add Graphics to Jpanel
Problem with custom painting and multiple JPanel