Swing tweaks for Mac OS X - java

I remember having once seen a list of properties that could be set on Swing components to make them look more native on Mac OS X.
This included ways to mark "dirty" documents with the "dot" in the window close button, open dialogs as sheets (not sure about that, but sure would be nice) etc.
I know Apple has let Java down as a "primary" programming language, but as they recently updated Java and even offer Java 6, I wonder if there is a comprehensive and current list - ideally with examples - on what you can do to make Swing apps look better without much effort on the Mac.
After receiving some answers, I put this into community wiki mode and started the following list to be expanded if need be:
Technical Notes: Java - User Experience: Overview page on Apple's developer connection reference library (index page).
New Control Styles available within J2SE 5.0 on Mac OS X 10.5: Examples for Button styles etc. specific to Mac OS X 10.5 Leopard.
Java Runtime System Properties: Information on System properties that help you enable the Apple-style menubar at the top of the screen, give rendering hints for text anti-aliasing etc.
Mac OS X Integration for Java: Information on Menubar and Application menu, context menus, keyboard shortcuts and AppleScript
PDF "Java 1.3.1 Development for Mac OS X (Legacy)": 80 pages of information on various topics such as packaging applications. This is somewhat outdated.

The Quaqua site may be interesting as well. From the site:
"The Quaqua Look and Feel (Quaqua) is a user interface library for Java applications which wish to closely adhere to the Apple Human Interface Guidelines for Mac OS X. ... It runs on top of Apple's Aqua Look and Feel, and provides fixes and enhancements for it."
It has a fairly good user guide with examples as well.

The Java Development Guide for Mac OS X has a Mac OS X Integration for Java section that is probably what you're looking for.

You can check this PDF at Apple, but it's marked as legacy.
On some applications, I'm still using com.apple.macos.useScreenMenuBar to have the Java application use the Mac OS X menu bar, and it still works in Leopard.

My personal link collection:
From developer.apple.com:
Java Runtime Properties for Mac OS X (don't get scared by the "not recommended" popup, some of the information is still useful)
Apple Java Extensions
OS X Runtime Configuration Guidelines (not directly related to Java, but an interesting read anyway)
From Sun:
Bringing your Java Application to Mac OS X Part Three
same page at another location with working images: http://192.9.162.55/developer/technicalArticles/JavaLP/JavaToMac/
When clicking on some old links I'd been redirected to Java Design Guidelines and Java Guides, seems as though I have to update my links...

Related

JFrame in all spaces on Mac OS X

I am trying to make a window in a Java application (a JFrame) follow the user between all Spaces in Mac OS X 10.5 and above, and I cannot seem to find how to do it. I found how to do it Objective-C, but there has to be some way to do this in Java!
How to do it in Objective-C:
http://www.cocoabuilder.com/archive/cocoa/192813-floating-window-across-all-spaces.html
Since it's very platform specific, it sounds like you'll have to write some kind of JNI/JNA to do it. Fortunately, someone might have already done this for you - check out http://code.google.com/p/rococoa/
This thread has a little bit of info on the API to get the NSWindow.

Java IDE for working over Remote Desktop

I have recently found out that anything Swing(NetBeans, IDEA) is excruciatingly slow to paint the UI over Remote Desktop(RDP).
Can you guys give me any suggestion for something that will work properly over RDP?
Actually, contrary to everything I've seen - mostly the "Dsun.java2d.noddraw=true", which is mentioned in a number of places, it is actually setting it to false that fixed the drawing issues(for me at least). Go figure.
RDP is optimized for native Windows apps and, regrettably, newer versions of RCP (like Vista/Win7's default RDP) is even more hostile to non-native apps than older (XP/Server 2003) versions. Here's a good link:
http://devnet.jetbrains.net/thread/280673
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4204845
One workaround is to get a screaming fast CPU/graphics board, tons and tons of memory and a super high-speed network connection :)
Another is to:
Select "32-bit true color" in your Terminal Services settings
Select "Modem"
Reduce screen resolution (heck, use 1024x768 if possible)
Here are some additional tips:
http://www.codinghorror.com/blog/2006/04/remote-desktop-tips-and-tricks.html
Try setting "Dsun.java2d.noddraw=true"
http://ubuntuforums.org/archive/index.php/t-1129187.html
http://www.mindfiresolutions.com/Solving-DIRECT-DRAW-ddraw-problems-in-Java-Swing-730.php
I am launching a java swing application from Linux, and display it as a Windows frame thanks to MobaXterm.
If you haven't done it already, please have a look at the following documentation :
https://docs.oracle.com/javase/8/docs/technotes/guides/2d/flags.html
Using -Dsun.java2d.noddraw=true did not fixed my issue, but setting xrender to true did.
So here's the code I used on Linux :
export _JAVA_OPTIONS='-Dsun.java2d.xrender=true'
java -jar my_java_application.jar
Maybe it's not only Swing that paints slow over Remote Desktop. However, Eclipse is based on SWT, based on native widgets, so it is not Swing.
You should give JavaWIDE a try. It is an IDE designed for access to a JDK without it installed on a system, with a built-in storage system so you just need access to the internet. It's not exactly a program for accessing everything on the computer but it will do a good job with your programming. It may take a while however, as the compiling is done on a separate server.

Support diffent Blackberry OS versions with differing functionality from the same COD file

I would like to support BlackBerry OS versions representing more than 90% of installed user base. Right now that means supporting OS versions 4.5 through 6.0.
I need to have touch-and-swipe events on models supporting with a touch screen, and I would like the same binary to load on both OS 4.5 and higher OS versions.
Is this possible? When I add a method TouchEvent to the code, the application no longer loads on my 8800, OS version 4.5.
Coming from the Windows and Linux PC world it feels odd to be so limited. On these bigger platforms you can create an app that works on any OS version and gracefully drops features not supported on an older platform.
I think I want dynamic class loading, but I am not sure.
What I have found related so far:
"is it possible to have a single build i.e cod file for touch and non-touch screen."
The end of that thread is "It isn't possible to do what you would like" Can anyone confirm this?
Is having one COD file a requirement? RIM provides support for a preprocessor, and the idea is that you can conditionally compile code, depending on your target OS.
The app I have experience with uses browser agent sniffing to offer the appropriate COD file to BlackBerry users. AppWorld also allows you to submit multiple COD files for one application, where each one is tailored for a specific OS version. AppWorld provides the right one to users when they download your app.

Java Swing positioning elements differently in different operating systems

I have written a Java Desktop Application that runs in Windows, Mac OS X, Ubuntu and Open Suse. I am having issues with is positioning thing differently in Linux.
I developed the application with NetBeans using the designer, it looks as I would expect in Windows and Mac OS X, but in the Linux distros certain label controls have shifted into different positions.
Is there a common reason for this?
Perhaps Linux uses a different font. One where letters have a different width.
You could try to explicitely set a specific font for your Look&Feel. It should be a font which is installed on all of your target platforms.
The most probable thing is that you use different Look and Feel for every platform. If you're developing in Windows you do layouts to fit for Window style only. But Linux has different L&F with different margins and font for GUI components. Metal style (basic for Linux) and its descendants (Nimbus and GTK+) have larger default system font and heights for components. I think, that must be a reason why you have shiftings.
The way to fix that is to check program looking in both platforms. I'd suggest to develop in Metal style because Windows has smaller fonts, as result, everything which fits in Metal will fit in Windows.
I'm assuming you developed the thing on Windows or Mac, that's why it looks "as expected". Can you compiling/running the code in your IDE on Linux and see how it looks?
My guess is that one of the implementations of the containers is flawed. I saw this sometimes when I did cross-development and mostly did trial-and-error modifications to fix it (by changing to use other classes). It also helped to have one developer working in Windows and another in Linux, so that we would easily spot and fix problem areas.
I changed the Layout style from 'Free Design' to 'Absolute'

Java applications with Windows 7 - are there compatibility concerns?

with some fuzz around Windows 7, does somebody have experiences with Java compatibility with Windows 7? Should this be a concern or do the programs probably work ok?
I'd be especially interested if somebody has experiences with Swing applications?
The versions available seem to be beta versions so they won't provide perfect basis for evaluation but some.
br, Touko
Updating info related to the question:
According to Supported System Configurations for Java SE 6 and Java For Business 6
,
Windows 7 support was introduced in 1.6.0_14
From Java SE 6 Update 14 Release Notes changes:
6821003 hotspot runtime_system Update hotspot windows os_win32 for windows 7
From Java SE 6 Update 18 Release Notes:
For 6u18, support has been added for the following system configurations:
* Windows 7 support is now available
I have been using various Java apps on my Win 7 x64 box just fine and never had any problems. Even some of my oldt poorly coded swing apps have worked without issues.
For the most part, Win 7 is Vista in new clothing. Shouldn't have much issues because of that.
Your biggest concern is having the right Java runtime installed. WHen that is out of the way you can expect properly written Swing programs to work identically.
(With proper I refer to not having hardcoded button sizes or similar)
There are several problem of swing application in windows7 there are stated below:
JCheckBoxMenuItem will not show image
JCheckBoxMenuItem(Icon,Text,boolean);//Icon will not displayed
you can refer the http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7122141.
Focus issues. Sometimes escape won't work
The problem I have with my Swing application on Windows 7 (and presumably Vista - haven't tried it), is that the Java Runtime indicates to Windows that it is UAC-aware, while my application that runs in the JVM actually isn't. As a result, if someone installs it into the traditional location (e.g. C:\Program Files\MyApp), the application fails because it cannot write configuration data or error log files to its installation directory. Because I use some third-party libraries that write their own files to the current (i.e. install) directory, and I've got many more important things to do than dig into those libraries just to make their error reporting and configuration storage UAC-aware, I took the path of least resistance and changed my default install directory to C:\MyApp. I realize that this is a regression back to the old DOS days where people ended up with myriad application directories in C:\, but it's not my fault that Windows' method of implementing UAC Virtualization for legacy applications doesn't work for Java apps.

Categories