Results 1 to 2 of 2
- 05-05-2011, 03:38 PM #1Member
- Join Date
- May 2011
- Rep Power
Prevent re-arrangement of component's position if some are invisible.
When making a dice game, I used a JPanel on which I placed 7 disabled radio buttons. Like this:
(I'm not sure how to display it with a courrier new font in this message).
My plan was for example if I roll a 1, I hide all radio buttons except the center one. If I roll a 2, I make visible the NW and SE button. If I roll a 6, I hide the center button and make the other buttons visible.
The problem I am having is that when I make my radio buttons invisible, the position of my radio buttons get re-arranged on my JPanel so that for example if I roll a 1, the middle Radio button finds itself completly in the top middle part of my panel. If I roll a 3 I don't get a nice diagonal line, the center button gets moved out of alignment.
How do I fix the position of my Radio buttons on the panel so that they never move regardless of if they are visible or not ?
I suppose I could use graphics function to draw the dice, but it seems to me that using radio buttons would be simpler.
Last edited by Acteon; 05-05-2011 at 03:42 PM. Reason: Trying to align the buttons
- 05-05-2011, 04:23 PM #2
To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
Use code tags to post codes -- [code]CODE[/code] will display asJava Code:
I would use JLabels in a GridLayout(3, 3) and set the text to "o" or ""
edit: Better than "o" could be "●" (\u25CF)
Last edited by DarrylBurke; 05-05-2011 at 04:51 PM.
- By sudhakar reddy in forum Java AppletsReplies: 2Last Post: 06-03-2010, 04:58 PM
- By banhbaochay in forum NetBeansReplies: 8Last Post: 04-12-2010, 05:15 AM
- By helloworld111 in forum AWT / SwingReplies: 5Last Post: 02-19-2009, 02:36 AM
- By masa in forum AWT / SwingReplies: 7Last Post: 12-12-2008, 11:17 AM
- By am17mu in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 05-16-2008, 06:44 PM