Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 28, 2004, 09:16 PM   #1
MacFan26
macrumors 65816
 
MacFan26's Avatar
 
Join Date: Jan 2003
Location: San Jose, California
Send a message via Yahoo to MacFan26
JButtons color in OS X vs. Windows

Does anyone know if it's possible to change the background color of a Java JButton in OS X? This is a screenshot of a game I had to write for a CS project. It's like Light's Out, where the lights are green when on and black when off. In Windows it's easier to see because the entire button is the color, rather than the space in the background. Is there a way to change this in OS X?
Attached Thumbnails
Click image for larger version

Name:	1.jpg
Views:	125
Size:	36.4 KB
ID:	18441  
__________________
15" i7 MacBook Pro antiglare, iPhone 4, 5G black iPod 60GB, iPod shuffle (red), new AppleTV
MacFan26 is offline   0 Reply With Quote
Old Oct 28, 2004, 10:38 PM   #2
therevolution
macrumors 6502
 
Join Date: May 2003
Best I can come up with is to change the look and feel to Metal, so that it looks like the Windows default:
Code:
    ...
    try {
    	UIManager.setLookAndFeel(new MetalLookAndFeel());
    }	
    catch(Exception e) {}

    JButton button = new JButton(" ");
    button.setBackground(Color.red);
    ...
I'm not seeing an easy way to change button backgrounds with the OS X L&F. I'd imagine it would involve overriding ButtonUI's paint() method... no fun. Anybody have a better solution?
therevolution is offline   0 Reply With Quote
Old Oct 28, 2004, 10:44 PM   #3
jsw
Moderator emeritus
 
jsw's Avatar
 
Join Date: Mar 2004
Location: Andover, MA
Share a link to the code or PM/email me with it and I'll look at it for you. But tomorrow - I'm going to bed now. Hopefully, someone can fix it for you before then - but I'd be happy to see what I can do.
__________________
You'll be the one moaning for me to give you some. - THC(taken out of context)
jsw is offline   0 Reply With Quote
Old Oct 28, 2004, 10:49 PM   #4
bousozoku
Moderator emeritus
 
Join Date: Jun 2002
Location: Gone but not forgotten.
There is no way to change the button face in the Mac OS X look and feel but if you make a button with a glyph (I've forgotten the class), you can put any image you want in there.
bousozoku is offline   0 Reply With Quote
Old Oct 29, 2004, 12:47 AM   #5
MacFan26
Thread Starter
macrumors 65816
 
MacFan26's Avatar
 
Join Date: Jan 2003
Location: San Jose, California
Send a message via Yahoo to MacFan26
Thanks guys, looks like there's no simple way to do this. Oh well.

here's the code I was using to set the colors on the board:

for (int x = 0; x < 8; x++)
for (int y = 0; y < 8; y++)
{
if (m.isLitAt(x, y))
board[x][y].setBackground(Color.GREEN);
else
board[x][y].setBackground(Color.BLACK);
}

For the fun of it I tried doing setForeground, but alas, then there was no color
__________________
15" i7 MacBook Pro antiglare, iPhone 4, 5G black iPod 60GB, iPod shuffle (red), new AppleTV
MacFan26 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Desktop: can i change the color of the borders at the top of windows? s1nister UI Customization 4 May 18, 2014 10:02 AM
Windows 7 Boot Camp Color Scheme Issues OminousFlare Windows, Linux & Others on the Mac 0 Aug 9, 2013 08:37 PM
Inability for windows to lay between 2 displays - hide LED LCD color inconsistency? bedifferent OS X Mavericks (10.9) 3 Jun 27, 2013 10:20 PM
How do you change the color of windows in OSX? hakuin Mac Applications and Mac App Store 6 Aug 16, 2012 04:59 AM
Label color of Windows Partition Icon tv3636 OS X 0 Jul 1, 2012 05:25 AM

Forum Jump

All times are GMT -5. The time now is 04:44 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC