The moose likes Swing / AWT / SWT and the fly likes Colorizing a Box 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 "Colorizing a Box" Watch "Colorizing a Box" New topic

Colorizing a Box

Dan Howard

Joined: Oct 10, 2004
Posts: 15
Hi All,

I tried to use a Box in my BoxLayout and it lays out OK but I can't seem to change it's color. Any ideas?
pete stein

Joined: Feb 23, 2007
Posts: 1561
Are Box's opaque? I'm betting not.
Dan Howard

Joined: Oct 10, 2004
Posts: 15
Opacity of course!
Brian Cole
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
pete stein wrote:Are Box's opaque? I'm betting not.

One thing you might (or might not) have to worry about is that
until JDK4 Box wasn't even a Component. (It was a direct subclass
of Container.) As such, it doesn't have a setOpaque() method
when running under JDK1.3.1 or earlier: NoSuchMethodError

If this is a problem, you could instead set a BoxLayout on a JPanel.

bitguru blog
Dan Howard

Joined: Oct 10, 2004
Posts: 15
Good to know. But I'm on Java 6 so I should be good.
Don't get me started about those stupid light bulbs.
subject: Colorizing a Box
Similar Threads
Making Typing "Game", any tips or pointers before I start?
Why aren't my components wrapping?
Can't control BoxLayout when adding JTableHeader