This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Redrawing the UI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic
Author

Redrawing the UI

D Preethi
Ranch Hand

Joined: May 24, 2008
Posts: 68
Hi All,

I have a requirement in which I want to redraw a gridbaglayout panel based on a radio button selection. Can someone suggest me how to achieve this? Initially, the screen will look like this -

<Radio button 1>
<Radio button 2>
<Radio button 3>

On selection of radio button 2, I should show -
<Radio button 1>
<Radio button 2>
<JPanel 1>
<Radio button 3>

On selection of radio button 3, I should show -
<Radio button 1>
<Radio button 2>
<Radio button 3>
<JPanel 2>

On selection of radio button 1, I should show -
<Radio button 1>
<Radio button 2>
<Radio button 3>


What is the best way to achieve this? I was thinking of card layout for the entire screen (and switch between 3 UIs based on button selection), but that requires me to maintain 3 different instances of the 3 radio buttons (since the button click can happen in any order). Can someone please suggest me better method?


Thanks,
Preethi

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
here's one way

[edit]
deleted - cross-posted at java.forums.org
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
I don't know what some people call 'redrawing'. I'd simply place the JPanel components in the layout and only set one of them (corresponding to the selected JRadioButton) visible (and all others invisible). Wouldn't that be a simple and operative approach?


Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Michael Dunn wrote:deleted - cross-posted at java.forums.org

Not just at java.forums.org - here as well.

D Preethi, please UseOneThreadPerQuestion, and BeForthRightWhenCrosspostingToOtherSites. This thread is closed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Redrawing the UI
 
Similar Threads
slow loading of JPanel
Pass radio button to servlet
need to display description with h:selectOneRadio
One form, multiple radio button groups
JOptionPane with lable and textfield