Results 1 to 4 of 4
- 03-06-2011, 04:16 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 3
- Rep Power
- 0
Adding multiple components to 1 container index
Ok so i'm new to GUI's in java basically what i'm trying to accomplish:
I'm drawing a screen that has objects oriented to a grid, displaying numbers in JLabels and Graphics over the numbers.
for example, the issue i'm having currently is i have a container and i'm using setLayout(new GridLayout)
which gives me a grid. in 1 of the grids i have a JLabel displaying a number 85% and behind that number i want to draw a rectangle only 85% full. I have the JLabel displaying the number and I have the rectangle, but i do not know how to put them in the same square on the grid. I tried looking into LayeredPanes but i think i just didn't understand it, Does anyone have an idea on what would be the easiest way to do this? I'm not asking for someone to do the work, just simply what would be the best way to put 2 objects in the same grid square?
I add them by using contentPane.add(JLabel) i also tried giving both objects the same index but that didn't work. any help is greatly appreciated
this is what i'm trying to make it look like, black is background orange is the drawing and 100% is the JLabel
Last edited by mmcnitt; 03-06-2011 at 04:24 PM. Reason: add pic
- 03-07-2011, 05:57 AM #2
Just setBackground(...) of the JLabel and setOpaque(true)
db
- 03-07-2011, 03:41 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 3
- Rep Power
- 0
set.Background just sets a color, i need to actually draw a rectangle behind it, the reasoning being that i only want the rectangle to be as full as the JLabels percentage
- 03-07-2011, 03:59 PM #4
Member
- Join Date
- Mar 2011
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Help with adding a Container within a Container
By JoKeR313 in forum New To JavaReplies: 4Last Post: 01-02-2011, 04:59 AM -
Adding and removing components from a GridBagLayout
By peterhabe in forum New To JavaReplies: 4Last Post: 09-19-2010, 10:13 PM -
Trying to Draw Multiple Components
By habester in forum New To JavaReplies: 1Last Post: 11-09-2009, 11:06 PM -
Adding components to a panel
By jboy in forum New To JavaReplies: 1Last Post: 10-10-2009, 01:02 PM -
adding components to frame
By roaan in forum New To JavaReplies: 4Last Post: 07-05-2009, 03:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks