|
-
Nov 23rd, 2003, 11:41 AM
#1
Thread Starter
Frenzied Member
drawing on my swing window
ok i have my swing window...but now i'd like to draw shapes on it, like i've done in applets. i've been trying some different combinations of stuff, but they dont' seem to work, is it a different process with a window?
Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class window
{
public static void main(String [] args)
{
JFrame frame = new JFrame("Ants");
Dimension WindowSize = new Dimension(200, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setSize(400,400);
frame.setVisible(true);
}
}
thanks guys
-
Nov 24th, 2003, 05:35 AM
#2
You should place some kind of JPanel in the frame's content pane. This panel ought to be of your own class (derived from JPanel). Then you can override the paint method.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 25th, 2003, 01:22 AM
#3
Dazed Member
You can override the paint() method with any class that you create that is a subclass of the following.
[list=a][*]Canvas class[*]Subclasses of the Component class that are not part of the AWT[*]Container class and it's subclasses: Window, Frame, Dialog, Panel, Applet[/list=a]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|