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 > Java, Swing, OS X, and You...

Java, Swing, OS X, and You...
Thread Tools
Dedicated MacNNer
Join Date: Apr 1999
Location: MA
Status: Offline
Reply With Quote
Apr 27, 2001, 09:29 PM
 
Hello Everyone...

I was wondering how I could use the Mac menubar in a swing app instead of the cheesy Windows/X-Windows style menus that swing apps have instead. I'm trying to package up jEdit nicely for OS X, and everything is good, except for the fact that the menubar is in the window...

I know this should be possible... earlier versions of jEdit under OS X PB did this... I'm hoping that it's an option that I can pass to the JVM or whatever to do this.

Any ideas?
dennis
     
Fresh-Faced Recruit
Join Date: Jan 2001
Location: Areas 51 thru 55 :P
Status: Offline
Reply With Quote
Apr 28, 2001, 01:17 AM
 
Originally posted by SmileyDude:
Hello Everyone...

I was wondering how I could use the Mac menubar in a swing app instead of the cheesy Windows/X-Windows style menus that swing apps have instead. I'm trying to package up jEdit nicely for OS X, and everything is good, except for the fact that the menubar is in the window...
Any ideas?
In order to pass Sun's Java Certification thing they, get this, HAD TO make the default JMenuBar for their look and feel show up within the Frame.

There is a system property to change this: com.apple.macos.useScreenMenuBar=true. I think you can set this as a Java default with a defaults write com.apple.macos useScreenMenuBar true. Otherwise you will need to modify the MrJApp.properties file for your application or use java -Dblahblahblah. I do not know if you can modify the MrJApp.propertiesof an already built application, though.
Well, let's just say, 'if your VCR is still blinking 12:00,you don't want Linux'
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Apr 28, 2001, 08:49 PM
 
Forte comes up with the OS X look and feel without any extra commands required, and I am using the Solaris build so there is no way it was coded with OS X in mind. I believe the Apple's OS X pages mention the OS X look and feel is defaulted in the client. (If I remembered that correctly and Forte seems to corroborate this).

I don't think the actual OS X menu bar is accessible within Swing. That would defeat the purpose of Swing for implimenting true cross platform applications in a single build.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Apr 29, 2001, 03:21 AM
 
Originally posted by AirSluf:
Forte comes up with the OS X look and feel without any extra commands required, and I am using the Solaris build so there is no way it was coded with OS X in mind. I believe the Apple's OS X pages mention the OS X look and feel is defaulted in the client. (If I remembered that correctly and Forte seems to corroborate this).
There was never any dispute of this.

I don't think the actual OS X menu bar is accessible within Swing. That would defeat the purpose of Swing for implimenting true cross platform applications in a single build.
But not having it in the OS X menu bar would defeat the purpose of having a consistent UI, unlike Linux and so on where apps all use different GUI toolkits and look quite different.
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Apr 29, 2001, 02:47 PM
 
But not having it in the OS X menu bar would defeat the purpose of having a consistent UI, unlike Linux and so on where apps all use different GUI toolkits and look quite different.
Very true, but that is also the basic decision faced when you decide to code in Swing.

Do I want a consistent Mac interface?
Y: Use the Java Bridge API's and not Swing

Do I want seamless cross platform implementation in a single file?
Y: Use Swing but give up Mac Consistent UI.


Currently there is no middle ground.
     
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Apr 30, 2001, 04:19 PM
 
Unfotunately, such is life. I have a workaround for you though. Make a frame with the menu bar in it and then put that frame at the top of the screen where the menu bar normally goes. You'll have to check on screen resolutions though and make its size accordingly.

Don't flame me - it's just a crazy(but practical) idea.

Dave

------------------
Think Different.
     
Dedicated MacNNer
Join Date: Apr 1999
Location: MA
Status: Offline
Reply With Quote
Apr 30, 2001, 07:23 PM
 
Hmm... not good options here..

I tried the useScreenMenuBar trick... doesn't seem to work.

The issue that I'm facing here is that I have a pre-existing Swing application (jEdit) that I wish to have a more consistent MacOS X look.

It's a bunch of bull that for the app to be Swing that it can't have a menu in the menu bar! If it's true that Sun mandates that, then they are really being bull-headed, and Apple should comply, but allow developer's to deviate using a flag or option.

If Apple is the one making the limitation, then they are being stupid. One of the advantages the Mac has always had over other OS's is the fact that the menu bar is always in the same portion of the screen, making it easy to run the mouse to the top to get the edit menu, which is always in the same location (well, at least until X...)

I'm gonna go the route of de-compiling the swing classes and see if there is anything hidden in there... I think Apple is already hooking into Quartz and/or Aqua, because the menu's are translucent, just like the real things... so, it appears that Swing on OS X really isn't a light-weight component like it's supposed to be.

I'll report back on anything I find.

------------------
dennis
dennis
     
Fresh-Faced Recruit
Join Date: Sep 2000
Status: Offline
Reply With Quote
May 4, 2001, 09:08 PM
 
There is a macos.jar file that uses the regular menu bar instead.
But I have no idea if it will work on OS X (I know it works in OS 9).
See: http://www.ing.unitn.it/~luttero/javaonMac/
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
May 5, 2001, 12:06 AM
 
That is a nice concept but the latest update listed on the page was 3/3/99. Definitely Mac OS 9 era. It looks like it was a look and feel update, so the Java program was done with Swing but had an OS 9 look and feel. The look and feel is already implemented in X by Apple and rightly noted above, just isn't the same as the real thing.
     
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Dixon, Ca
Status: Offline
Reply With Quote
May 6, 2001, 04:15 PM
 
Haven't actually tried this yet (can't start using X until my Cube shows up, hopefully Monday), but this supposedly works.

try {
properties = System.getProperties();
// ...
properties.put("com.apple.macos.useScreenMenuBar", "true");
// ...
System.setProperties(properties);
} catch (SecurityException exception) {
// ...
}
So they cloned a sheep - who could tell the difference anyway? - Robin Williams
     
Fresh-Faced Recruit
Join Date: Apr 2001
Status: Offline
Reply With Quote
May 6, 2001, 08:45 PM
 
Originally posted by gandalf:
Haven't actually tried this yet (can't start using X until my Cube shows up, hopefully Monday), but this supposedly works.

try {
properties = System.getProperties();
// ...
properties.put("com.apple.macos.useScreenMenuBar", "true");
// ...
System.setProperties(properties);
} catch (SecurityException exception) {
// ...
}
You can also define this on an app by app basis IF you package them using MRJAppBuilder. I've done this with jEdit (I use it for most of my coding).
Go into the .app directory for the application and then into Contents/Resources/MRJApp.properties. Edit this file and add
Code:
com.apple.macos.useScreenMenuBar=true
. If you check apple's release notes for the DevTools, there are a few others you can change. One that I particularly like is
Code:
com.apple.mrj.application.live-resize=false
because it speeds up resizing a lot by doing it MacOS 9 style.

mccullocht
     
Fresh-Faced Recruit
Join Date: Sep 2000
Status: Offline
Reply With Quote
May 8, 2001, 09:39 PM
 
OK, we have it figured out now.

For some reason the jEdit OS X download shows jEdit.app as a folder instead
of a double-clickable application. I know there is some Apple developer note
about that kind of problem.

So I made a version myself that turns on the use of the regular menu bar and
turns off live resizing (but you can change those, see instructions again below).

Either connect to my itools iDisk (doug.holton) or go to http://homepage.mac.com/doug.holton/ and get the jedit.dmg file.

Alternatively, you can run jedit from the command line:
java -Dcom.apple.macos.useScreenMenuBar=true -jar jedit.jar &

Or to make your own jedit.app using MRJAppBuilder, set the main classname
to org.gjt.sp.jedit.jEdit, the classpath to jedit.jar, the output file, and add
the properties
com.apple.macos.useScreenMenuBar (true) and
com.apple.mrj.application.live-resize (false).

To remove or change those properties later, as the earlier person wrote, open your terminal, cd into the jedit.app/Contents/Resources/ , and edit the MRJApp.properties file.
     
Dedicated MacNNer
Join Date: Feb 2001
Location: Victoria, BC, Canada
Status: Offline
Reply With Quote
May 11, 2001, 04:03 AM
 
whoops, wrong thread

[This message has been edited by wr11 (edited 05-11-2001).]
     
   
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 01:29 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