wood burning stoves
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic

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?


Michael Dunn
Ranch Hand

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

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

Joined: Oct 27, 2005
Posts: 20271

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
It's not a secret anymore!