Results 1 to 4 of 4
Thread: How to use graphics
- 03-18-2010, 01:36 PM #1
Member
- Join Date
- Aug 2009
- Location
- South Sweden
- Posts
- 24
- Rep Power
- 0
How to use graphics
Hey all
Can I get some help how to call a graphics-method?
I mean, how to make it run in a good way?
Is there any other way to do this than in an applet?
Drawing Geometric Primitives (The Java™ Tutorials > 2D Graphics > Working with Geometry)
^ I mean this code:
How to call it so it will run? (Ok, the one that i quoted isn't a visible object(?), but if it was, how to run it?)Java Code:public void paint (Graphics g) { Graphics2D g2 = (Graphics2D) g; ... }
Sorry for messy post
But I'm in school, and this is a lesson where we aren't doing anything ^^
Still I wouldn't want the teacher to see
///M~
- 03-18-2010, 01:47 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
I have no idea with what you mean by "how to run it". If you mean how would you execute that method, then all I can say is, you don't. That is done by the framework itself (Swing or AWT), when the GUI is drawn. And if you're using Swing, you don't override that method, at all, you override paintComponent.
- 03-18-2010, 01:59 PM #3
Member
- Join Date
- Aug 2009
- Location
- South Sweden
- Posts
- 24
- Rep Power
- 0
- 03-18-2010, 02:10 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Well, go through the rest of that tutorial Trail: 2D Graphics (The Java™ Tutorials)
If it uses Applets the entire time then simply change JApplet to JPanel, wrap it in a JFrame and include the "init" and "start" actions in the main method.
Similar Threads
-
Help me with graphics
By 7oclock in forum New To JavaReplies: 12Last Post: 04-04-2009, 11:20 PM -
Help with 2d graphics please
By xbox_nutter in forum New To JavaReplies: 0Last Post: 04-02-2009, 11:48 AM -
SWT Graphics Example
By Java Tip in forum SWTReplies: 0Last Post: 06-28-2008, 09:28 PM -
graphics
By Joe2003 in forum Advanced JavaReplies: 4Last Post: 01-18-2008, 07:44 PM -
Graphics
By feniger in forum New To JavaReplies: 1Last Post: 12-29-2007, 04:22 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks