wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JColor Chooser - JLabels? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JColor Chooser - JLabels?" Watch "JColor Chooser - JLabels?" New topic
Author

JColor Chooser - JLabels?

Jacob Coddaire
Ranch Hand

Joined: Jan 11, 2011
Posts: 36

How would I integrate JColorChooser into each player? I know how to do it for JButtons, but I simply cannot figure out how to do it for JLabels.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10171
    
    8

JOptionPane#showXXX methods accept an Object message argument. You can always pass a JColorChooser instance as the message and check for the color chosen by the user

This question is more suitable for the GUI forums.
Moving thread


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Jacob Coddaire
Ranch Hand

Joined: Jan 11, 2011
Posts: 36

That literally does not make any sense to me.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10171
    
    8

Jacob Coddaire
Ranch Hand

Joined: Jan 11, 2011
Posts: 36

Ok. I've almost got it. Here's the code so far:


It works, but now I want to apply the color to the JLabels of each. I tried the above code, but it didn't work.
I can't compile it because of setForeground. The error is "The method setForeground(Color) is undefined for the type String."

Any ideas on how to fix this?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10171
    
    8


Mixing HTML stuff with Swing?

You can set the foreground by
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Maneesh Godbole wrote:

Wouldn't that do the same as


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10171
    
    8

Rob Spoor wrote:
Wouldn't that do the same as

True.
But
1) Using a JOptionPane for the color chooser would offer the user the same experience as the number of players and name prompt
2) JOptionPane would allow the OP to display custom messages. Something like what color for the player?
3) I had JOptionPane so much in mind that I actually forgot about the JCholorChooser#showDialog()
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JColor Chooser - JLabels?
 
Similar Threads
How do you set the color of an array List of JTextArea
Can JLabels print string from an array list
How do you add objects to arrays?
JOptionPane.showOptionDialog
Arrays - Exception error