Results 1 to 5 of 5
- 02-22-2012, 12:10 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 71
- Rep Power
- 0
question on arguments for painting components
Hi folks, been a while. Here's my question. I want to paint components onto a JPanel that I can make their behaviour independent. I want to use different methods to do this. Here's an example code:
Question is what do I pass as an argument on the line:Java Code:package myPaCKAGE; import java.awt.Color; import java.awt.Graphics; public class image { private int width, height; private Object square; public Picture(int width, int height) { this.width = width; this.height = height; this.square(); } } public void square(Graphics g) { g.drawRect(10, 10,10, 10); g.setColor(Color.red); } }
so that I can invoke the method to create the object?Java Code:this.square();
Thanks
- 02-22-2012, 12:40 AM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,606
- Rep Power
- 5
Re: question on arguments for painting components
Recommend you read the following:
Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)
- 02-22-2012, 12:44 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 71
- Rep Power
- 0
Re: question on arguments for painting components
Thanks doWhile, just the job.
- 02-22-2012, 07:50 PM #4
Member
- Join Date
- Jan 2011
- Posts
- 71
- Rep Power
- 0
Re: question on arguments for painting components
doWhile
If you do happen across this thread again, can I just say a hugh thank you. That tutorial is just the ticket and I've managed to do more in the last 15 minutes than the whole of last night. Is your google foo strong or do you know the tuorials that well? I searched and searched last night and didn't come across this. I'll leave this thread open for another hour or so to see if you return before marking as closed. Once again I can't thank you enough.
Cheers
- 02-22-2012, 10:37 PM #5
Re: question on arguments for painting components
Search this forum for "Performing Custom Painting"Is your google foo strong or do you know the tuorials that well?
Spend a little time each day reading the forums and you may never have to ask a question of your own. It's all there, several times over.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
A question on components without references and for loop.
By fatabass in forum New To JavaReplies: 2Last Post: 02-22-2012, 09:43 AM -
New To Java: Question about arguments
By Humphrey Bogart in forum New To JavaReplies: 5Last Post: 02-10-2012, 06:27 PM -
Sorting objects with 2 strings arguments and 2 int arguments
By tirwit in forum New To JavaReplies: 8Last Post: 09-23-2010, 12:07 AM -
question about painting efficiently
By gib65 in forum AWT / SwingReplies: 16Last Post: 07-04-2010, 08:18 PM -
Swing components vs. custom painting
By Cruncher in forum New To JavaReplies: 6Last Post: 05-06-2010, 07:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks