Results 1 to 3 of 3
- 06-15-2011, 01:48 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
Hi! lil help? paintcomponent() and text displayed in same window?
Hi,
I'm not great at programming yet, so i'll cut to the chase
i have a box class that takes in height, length, width and calculates surface area and volume.
I just wanted to show off and draw the cubes and boxes and display their dimensions in a window.
I'm pretty sure you can display text in a JPanel but i really don't know which components to use.
I'd have a JFrame... with a JPanel? split it in two and have one side the text dimensions, on the other side a representation of the cuboid.
Could i pass the measurements taken in as doubles to paintcomponent() and draw the rectangle in proportion to its measurements?
It's a pipe dream seeing as i have like two days to do this but it would be really satisfying.
Any ideas people can give me would be great !
Please ask me to clarify any points to understand my problem, i'd ask my brother he's an IT guy but he's just started a new job for the govt that he has to drive 2 hours to.
Thanks !!
- 06-15-2011, 02:43 PM #2
Sounds like a job for a JLabel or a JTextField.
No, but you're on the right track. Extend JPanel and override paintComponent(Graphics g). You can't pass anything as parameters to that method, but you can pass them into the constructor (or a setter) in that class, then access them that way.
Recommended reading: Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)
Painting in AWT and SwingHow to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 06-15-2011, 05:52 PM #3
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Help with paintComponent!
By joeyea in forum Java 2DReplies: 6Last Post: 12-27-2010, 01:59 PM -
paintComponent vs paintComponents
By alacn in forum New To JavaReplies: 5Last Post: 07-26-2010, 03:33 AM -
Need to pass a value from a parent window to a pop up or child window
By blackpanther in forum Advanced JavaReplies: 4Last Post: 01-10-2010, 07:48 AM -
paintComponent is not working
By spazattack in forum New To JavaReplies: 1Last Post: 12-18-2009, 03:48 AM -
change url in parent window from child window
By rakesh_n_mehta in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 07-09-2009, 12:17 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks