Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSBox in Swing Java application?

NSBox in Swing Java application?
Thread Tools
Senior User
Join Date: May 2001
Location: Massachusetts, USA
Status: Offline
Reply With Quote
Dec 8, 2003, 10:29 PM
 
Hey all,

I'm crafting a fairly large application in Java. It needs to run on both Mac OS X and Windows, and probably on Linux as well, so I'm using Swing rather than doing it in Cocoa Java (or just Cocoa). Anyway, I need a group box, probably better known to this crowd as an NSBox... I can use EtchedBorder or whatnot to get a box that groups things, but it's a far cry from Panther's spiffy sunken effect -- and, petty or not, I want that effect.
My plan was initially to use some Mac-specific library inline, and then just wimp out for other platforms, something like this:
Code:
if (System.getProperty("os.name").startsWith("Mac OS X") { myWindow.add(new com.apple.spiffy.controls.NSBox()); }
The problem is, I don't know if this will cause the application to complain if I try to run it on Windows -- Java doesn't support conditional compilation per se, so that reference is still in the code at runtime on Windows... so my first question is, can I do that?
My second question may supercede the first: how can I get a group box/NSBox control into a native Swing application? I thought I had worked it out; JTabbedPanes have the same appearance, so I added an empty JTabbedPane to the window and it seemed to work -- but as soon as I added controls to it, it grew an empty tab at the top, which certainly wasn't going to cut it. I'm willing to resort to third-party libraries if I have to...

Can anyone help?
     
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Dec 9, 2003, 06:09 PM
 
I think that if you compile it on a Mac it should run on Windows/Linux with your test statement. IT however will not compile on Windows/Linux as these Cocoa classes will not be available on those platforms.

I however feel for such a minor LAF element it is not worth polluting your swing code with Cocoa. Rather it would be better to find another approach to your LAF problem.
     
K++
Senior User
Join Date: Jan 2002
Location: NYC
Status: Offline
Reply With Quote
Dec 10, 2003, 11:36 PM
 
You could always create your own object to do this for you rather than using Apples.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:30 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2