Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / August 2005

Tip: Looking for answers? Try searching our database.

JButton question

Thread view: 
Ed - 20 Aug 2005 00:24 GMT
What's a good way to indicate that one of several JButtons is recommended in
a given situation?  I tried changing the background color, but I don't like
the results.  Is there an API method to "highlight" the button?

I considered setting the button as the default button.  But if the button
changes frequently, will that be a hassle?

Simplified example: blackjack game,  with 2 buttons to Hit or Stay.  How to
implement a player coach to tell you which gameplay choice is justified by
your hand?

TIA
Sean - 20 Aug 2005 07:35 GMT
> What's a good way to indicate that one of several JButtons is recommended in
> a given situation?  I tried changing the background color, but I don't like
[quoted text clipped - 8 lines]
>
> TIA

Maybe you could give the button a border and change its color?
Ed - 21 Aug 2005 04:15 GMT
> Maybe you could give the button a border and change its color?

I tried changing the background color, but I didn't like the results because
it overrides the metal shading L&F and gives the button a solid color.  Plus
I discovered that there's no consensus on  what a particular color means.
For instance, I shaded the suggested button PINK, and several folks told me
they interpreted PINK to mean "don't click here."  :/

I'll play with the foreground color ... maybe going to a darker gray will do
the trick.  I'll try adding a border too.  Doesn't a button already have a
border, though?  If so, I'd  be overriding the default border with a new
one, and I'd have to get the default one so I could set it back, right?

I was hoping there was something in the API explicitly for this purpose,
like button.setHighlighted() or something.  Oh well, thanks for the help.
Sean - 21 Aug 2005 10:22 GMT
>>Maybe you could give the button a border and change its color?
>
[quoted text clipped - 11 lines]
> I was hoping there was something in the API explicitly for this purpose,
> like button.setHighlighted() or something.  Oh well, thanks for the help.

I'm not talking about the background color, I'm talking about creating a
border around the button with a certain color, and you can set
"isVisible" to true or false depending on when you want to draw
attention to it.
Thomas Fritsch - 21 Aug 2005 01:44 GMT
> What's a good way to indicate that one of several JButtons is recommended
> in a given situation?  I tried changing the background color, but I don't
> like the results.  Is there an API method to "highlight" the button?
Of course there is lot of API. See
<http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JButton.html#method_summary>
(and don't forget the methods inherited from AbstractButton, JComponent,
...) to find a setXxxx() method that makes sense for your
highlighting/coaching. There are setBorder (as mentioned already by the
other poster), setBackground, setForeground, setIcon, setFont, ...
Or for being creative, you could even develop your own subclass of JButton
with a brand-new setGimmick() method and an overridden paintComponent()
method.

> I considered setting the button as the default button.  But if the button
> changes frequently, will that be a hassle?
[quoted text clipped - 4 lines]
>
> TIA

Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')

Ed - 21 Aug 2005 22:21 GMT
I think I found a good solution using icons ... a little green "Check" and a
little red "X".

>> What's a good way to indicate that one of several JButtons is recommended
>> in a given situation?  I tried changing the background color, but I don't
[quoted text clipped - 17 lines]
>>
>> TIA
Thomas Hawtin - 22 Aug 2005 13:31 GMT
> I think I found a good solution using icons ... a little green "Check" and a
> little red "X".

Off hand, I'd go for a little, electric-green arrow underneath the
button for good. Nothing (no clutter) for bad. Try out a few ideas and
see which gets universally understood and liked by players.

Tom Hawitn
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.