How to hide tabs in a TabbedPan layout?

P

Phrank

Hello,

I've got a TabbedPane gui with two tabs. Is it possible to hide
the second tab until/unless a certain radio button is clicked on the
first tab? I'm building a small program that allows users to order
books, and they have a choice as to whether or not they want to have
it shipped to them or not. If they want to have it shipped, then they
have to enter their address, and I have my second tab set up with
Address/City/State/Zip Code text boxes laid out. But I don't want
this tab even seen unless the buyer selects the YES radio button for
shipping. I've searched high and low for any documentation or
examples on how to do this, but I can't seem to find any. I'd
appreciate any guidance. Thanks!

Frank
 
S

Steven J Sobol

Phrank said:
Hello,

I've got a TabbedPane gui with two tabs. Is it possible to hide
the second tab until/unless a certain radio button is clicked on the
first tab?

Have you tried setVisible() ?

--
JustThe.net Internet & New Media Services, Apple Valley, CA PGP: 0xE3AE35ED
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / (e-mail address removed)
Domain Names, $9.95/yr, 24x7 service: http://DomainNames.JustThe.net/
"someone once called me a sofa, but i didn't feel compelled to rush out and buy
slip covers." -adam brower * Hiroshima '45, Chernobyl '86, Windows 98/2000/2003
 
P

Phrank

Have you tried setVisible() ?

I've been looking some more and still cannot find how to do this. Ok,
if that can't be done, how would I go about having the 2nd tab
automatically selected when the appropriate radio button is selected
on Tab 1?

Frank
 
L

Liz

How about using card layout instead? How about setting the color of the
tab to be the same as the color behind it (maybe you have to do the same
to the borders if there are any.)
 
S

Steven J Sobol

Phrank said:
I've been looking some more and still cannot find how to do this. Ok,
if that can't be done, how would I go about having the 2nd tab
automatically selected when the appropriate radio button is selected
on Tab 1?

Hm, I'm going to play around and see what I can find out... will have
to do it tomorrow, it's late...

--
JustThe.net Internet & New Media Services, Apple Valley, CA PGP: 0xE3AE35ED
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / (e-mail address removed)
Domain Names, $9.95/yr, 24x7 service: http://DomainNames.JustThe.net/
"someone once called me a sofa, but i didn't feel compelled to rush out and buy
slip covers." -adam brower * Hiroshima '45, Chernobyl '86, Windows 98/2000/2003
 
R

Rogan Dawes

Phrank said:
Hello,

I've got a TabbedPane gui with two tabs. Is it possible to hide
the second tab until/unless a certain radio button is clicked on the
first tab? I'm building a small program that allows users to order
books, and they have a choice as to whether or not they want to have
it shipped to them or not. If they want to have it shipped, then they
have to enter their address, and I have my second tab set up with
Address/City/State/Zip Code text boxes laid out. But I don't want
this tab even seen unless the buyer selects the YES radio button for
shipping. I've searched high and low for any documentation or
examples on how to do this, but I can't seem to find any. I'd
appreciate any guidance. Thanks!

Frank

How about adding and removing the second tab depending on the selection
state of the radiobutton?

i.e. add a radiobutton listener that does:

if (radiobutton.isSelected()) {
tabbedPane.add(secondPanel);
} else {
tabbedPane.remove(secondPanel);
}

methods and arguments for add and remove are most likely incorrect, but
you get the idea, I think.

Rogan
 
P

Phrank

How about using card layout instead? How about setting the color of the
tab to be the same as the color behind it (maybe you have to do the same
to the borders if there are any.)

I think the CardLayout approach seems the best. I'm trying to convert
my TabbedPane to CardLayout now. Thanks!

Frank
 
S

Sudsy

Phrank said:
Hello,

I've got a TabbedPane gui with two tabs. Is it possible to hide
the second tab until/unless a certain radio button is clicked on the
first tab? I'm building a small program that allows users to order
books, and they have a choice as to whether or not they want to have
it shipped to them or not. If they want to have it shipped, then they
have to enter their address, and I have my second tab set up with
Address/City/State/Zip Code text boxes laid out. But I don't want
this tab even seen unless the buyer selects the YES radio button for
shipping.

Perhaps you need to take a step back and ask yourself (and perhaps
others) whether this makes for an inutitive GUI. From what you've
described, I know that I wouldn't like it. To me it would make more
sense to collect the shipping and billing information at the same
time, namely at check-out. Unless you're giving the books away for
free, I'm assuming that you're going to support credit-card payment.
In that case you'll certainly want to use AVS (Address Validation
Service). You need the billing address to validate, don't you know.
Take you cues from other websites. The work flow in some has been
engineered by professionals. Don't be using a tabbed-pane "just
because".
 
P

Phrank

Perhaps you need to take a step back and ask yourself (and perhaps
others) whether this makes for an inutitive GUI. From what you've
described, I know that I wouldn't like it. To me it would make more
sense to collect the shipping and billing information at the same
time, namely at check-out. Unless you're giving the books away for
free, I'm assuming that you're going to support credit-card payment.
In that case you'll certainly want to use AVS (Address Validation
Service). You need the billing address to validate, don't you know.
Take you cues from other websites. The work flow in some has been
engineered by professionals. Don't be using a tabbed-pane "just
because".

I appreciate all the input and advice; it's got me going in the right
direction...with this project anyway. The primary purposes of this
project was to solve a problem and to use different java classes and
tools. I wanted to try something different, so that's why I went with
the tabbed pane. From another response earlier, I thought that I
would go the route of the CardLayout, but I then to a second look at
Mr. Dawes' input of adding and removing the second panel based on the
radio button state, and that's the way I went. It works well, by the
way Mr. Dawes! Thanks! As for your input, Sudsy, I absolutely agree
with you; I wouldn't really care for it as a user interface. However,
my thoughts and approach will be consolidated with others to come up
with the best of all worlds, kind of like a think tank where there are
no stupid ideas, even if we all know there really are. My approach
may very well be one of those stupid ideas, but it may trigger a
thought from someone else in the group. Thanks again everyone!

Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top