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/Cocoa++ Java/Swing--

Java/Cocoa++ Java/Swing--
Thread Tools
Fresh-Faced Recruit
Join Date: Nov 1999
Location: San Jose, CA, USA
Status: Offline
Reply With Quote
Nov 3, 2003, 05:33 PM
 
What can I say. I think the only way to have Java MacOS X applications with MacOS X look and feel is to use Cocoa, not Swing. A large part of what makes using MacOS X easy is what Apple has always done, built strong UI guidelines so users can switch easily between apps and be confronted with the same set of patterns.

Java-Swing is great if you want your MacOS X app to feel like a Windows application with Aqua controls. Don't get me wrong, the Swing team at Apple has done a great job getting Swing to MacOS X. I use Swing apps every day: IntelliJ's IDEA, JProfiler and dbVisualizer. However, I also wish in my heart of hearts they used Cocoa so I could get tighter MacOS X integration.

The Java apps I'm bringing to MacOS X use Cocoa, not Swing. So they look, feel and behave like MacOS X apps.

Anyone else feel this way?
     
Dedicated MacNNer
Join Date: Oct 2003
Status: Offline
Reply With Quote
Nov 3, 2003, 07:55 PM
 
Hi. Have you tried SWT? Perhaps this might integrate better. I have not yet tried it, but Eclipse is build using SWT.
     
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Nov 6, 2003, 06:15 PM
 
I think that a Cocoa-Java GUI would be the easiest way to create a Mac native GUI look and feel for Java applications.

However, the to date poor samples of Java swing applications is not the fault of Swing, rather that traditional Java GUI development has been most focused on Windows look and feel.

This however does not mean that Java Swing is not able to be used to build a native looking applications with the near same functionality of a cocoa application.

The swing API's are in no way lesser then the Cocoa Framework.

It is rather up to the skill of the developer to develop his swing application to the standard expected by Mac OS X users.
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Nov 7, 2003, 08:48 AM
 
Interestingly, pure AWT applications tend to feel quite Cocoay. It's just that the Swing classes were designed with different abstractions and metaphors in mind, and a different workflow...
[vash:~] banana% killall killall
Terminated
     
jobim  (op)
Fresh-Faced Recruit
Join Date: Nov 1999
Location: San Jose, CA, USA
Status: Offline
Reply With Quote
Nov 7, 2003, 04:10 PM
 
Originally posted by depolitic:
The swing API's are in no way lesser then the Cocoa Framework.

It is rather up to the skill of the developer to develop his swing application to the standard expected by Mac OS X users.
I'm sorry, but I have to disagree. There are functionality differences. For example, in Swing how can I create a Cocoa toolbar, the kind you find in Mail or XCode? Swing has equivalent toolbar code that looks very much like Windows and in no way behaves like the Cocoa version. Or how do I get a drawer in Swing? You can't. There are things in Cocoa which are not available in Swing. If you can find a way to do these things easily in Swing using Swing APIs I'd more than welcome it.

I've used a variety of cross platform UI frameworks. They always have the same problem: they choose an "idea" UI and make that work on every platform. As a result, they will always be lacking tightness in some degree with the platform they are on.

This however does not mean that Java Swing is not able to be used to build a native looking applications with the near same functionality of a cocoa application.
Yes, you can spend a lot of extra time making Swing look more like a MacOS native app. But then you are probably going to violate Swing UI Guidelines or alienate Windows or Linux users if your app feels too MacOS X. The whole ideal of Java Swing in my mind is a write once philosophy. You may need to tweak per platform, but the fundamental UI should be the same. So why build an extra MacOS X tailored UI in Swing when I can use Cocoa which has a wonderful tool like Interface Builder, which has all sorts of helpers to make my UI layout look and feel MacOS X native. Quickly and easily.
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Nov 7, 2003, 07:59 PM
 
Originally posted by depolitic:

The swing API's are in no way lesser then the Cocoa Framework.

It is rather up to the skill of the developer to develop his swing application to the standard expected by Mac OS X users.
1. Show me one Swing UI that makes you not want to wish it was Cocoa?

2. Show me a Cocoa UI that makes you want to wish it was done with Swing?

Having a hard time finding examples?




It's not about programming talent... Swing is just not that good.

     
Fresh-Faced Recruit
Join Date: Nov 2003
Status: Offline
Reply With Quote
Nov 8, 2003, 08:49 AM
 
I think that there are some important points being missed here. Number one is that Java is a cross-platform solution and is being embraced by Apple as their cross-platform solution. This argument that Swing is inferior to the platform's native UI toolkit is apples and oranges. Swing is supposed to embrace the lowest common denominator so that it can be used on any platform.

There are some things about Swing that are not ideal, but this is the case with all the toolkits. Again, I think the argument that Swing is fundamentally inadequate is a sign of ignorance; the problem is people are crippling themselves with their choice of tools. Reliance upon GUI building applications (which are universally quite poor) is the problem here.

I'm writing a cross-platform n-tier application for a medium sized business and am using Java across the board. Development has progressed rapidly, mostly because of the variety of open solutions like Lucene and Castor. The client application is very responsive and the user is comfortable with it, regardless of their choice of platform.

If you are writing an OS X only application, use Cocoa. If it's going to be cross-platform, use Swing.
     
Dedicated MacNNer
Join Date: May 2001
Location: Edinburgh, UK
Status: Offline
Reply With Quote
Nov 8, 2003, 11:48 AM
 
Every time I've touched swing I've hated it. Nothing created with it seems to look the way it should on any platform. The main reason for this has to be the control layouts (including BoxLayout, GridLayout, BorderLayout, etc) which seem designed to screw up the sizing and placement of anything in the window. From what I've seen KDE has a similar idea but it actually works properly.
     
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Nov 8, 2003, 11:59 AM
 
Originally posted by cmiles74:
Swing is supposed to embrace the lowest common denominator so that it can be used on any platform.
When was the last time Swing was revised to leverage these common denominators? These common denominators are not static. Furthermore, within the set of common denominators, is Swing really that good? For example, redrawing the screen "is a common denominator" in any platform. I haven't found a single Swing drawing app that does this well -in either macs or windows. Is it becuase of the JVM overhead blah blah. When is that excuse going to die out, we got machines that scream -in any platform.

Swing is basically fix-up work over the heavy AWT. Sun got it "sort of wrong " the first time but did not go back to drawing board. They manouvered around it and extended some old AWT classes. That was an offortunate lack of vision and a wasted opportunity to do things right. Now they're is an industry built around Swing (despite it's shortcommings) and it's probably too late to trash the API and start over.

Anyway, there's much room for improvemt in Swing specifications and implementations. Apple has done some things to improve its own but the real significant change needs to come from the mothership.

One reason that I like Apple is that they have the guts to take things down and start over, when reality of the product doesn't align with the vision. The most common scenario is to let the current reality drive the vision. That's just too bad...


     
jobim  (op)
Fresh-Faced Recruit
Join Date: Nov 1999
Location: San Jose, CA, USA
Status: Offline
Reply With Quote
Nov 8, 2003, 03:54 PM
 
Originally posted by cmiles74:
Swing is supposed to embrace the lowest common denominator so that it can be used on any platform.
Have you been reading Sun's comments about Swing lately? About how they want Swing to look much better under Windows? The Swing UI model is very close to that of Windows, I'm sure for practical business reasons on Sun's part: so Swing apps can hopefully look and feel best on Windows. Having minimizable internal frames is not lowest common denominator for all platforms. Having tear-away toolbars is not lowest common denominator since certain don't have that either. The list goes on.

Again, I think the argument that Swing is fundamentally inadequate is a sign of ignorance; the problem is people are crippling themselves with their choice of tools. Reliance upon GUI building applications (which are universally quite poor) is the problem here.
I keep hearing that in defense. While I think people can suffer from ignorance, I however have been building UI layers for awhile with various toolkits. And I take Swing seriously. And have learned about it. And not cursed the terrible GUI builders alone and done nothing about it.

But how do I get a Cocoa style toolbar in Swing? A drawer on a window? A Cocoa search field? A sheet? It's not that I'm trying to add these features for no reason. The type of problem I'm trying to solve calls for these according to Apple's UI guidelines. Swing toolbars look absolutely nothing like Cocoa's. Swing has no drawers. Swing has no sheets. Swing has no special search field widget that looks like Cocoa's. Period. Same for various other UI elements. And you're correct, in a Swing world I want to write once, run the UI anywhere. So I also don't want a bunch of MacOS X only code in my Swing UI. See the problem? If I take my MacOS X users seriously I'm going to give them UI they expect.

Development has progressed rapidly, mostly because of the variety of open solutions like Lucene and Castor. The client application is very responsive and the user is comfortable with it, regardless of their choice of platform.
Lucene is for text based searching and Castor is a data binding and serialization mechanism. They have nothing at all to do with UI, and therefore nothing to do with Swing. I'm using Java as well for my backend, and that code has nothing to do with my choices for UI frameworks.

If you are writing an OS X only application, use Cocoa. If it's going to be cross-platform, use Swing.
I'm writing a cross-platform n-tier application and all that good stuff like you. I've worked at a variety of companies using everything from Java to HTML to XML to WML to home brew solutions to pull off a "write once, UI anywhere" solution.

If you're limited for time and resources and hence need a way to bring a single UI to all your target platforms, then yes you can use something like Swing. I get it's point. However, why do so many people here and on other lists complain about Swing on MacOS X? If you care a great deal about the users of a particular UI platform, building something meeting that platform's UI guildelines and being more tightly integrated at the app level with that OS is a great way to win over users and keep them happy.

My backend is currently all in Java. And I'm planning a Swing UI version for other platforms like Windows and Linux because the UI ideal of Swing looks more like their platforms anyway. But since I can't get Cocoa toolbars, or drawers or search fields or sheets or a variety of other things in Swing, and because I care about my MacOS X users, I'm building a front end in Cocoa-Java for MacOS X.
     
Fresh-Faced Recruit
Join Date: Nov 2003
Status: Offline
Reply With Quote
Nov 9, 2003, 01:03 PM
 
I have written an article about Cocoa Java that will be in this December's issue of MacTech magazine.

Cocoa is the way to go for Java applications on Mac OS X. Swing is the way to go if you want a cross-platform application. Never expect Apple's "Aqua" pluggable Swing look & feel to even approach the level of beauty of a true Cocoa application; because of Swing's "least-common-denominator" approach, it's never gonna happen.

There is a lot of BS out there from Objective-C proponents about how it's "bad to use Cocoa with Java," but this simply isn't the case. It's perfectly acceptable to do so, and I encourage it.

If you want a good example of a shareware Cocoa Java application complete with full source code, check out "Aquataxx", a game that has a lot of Java code and a lot of Cocoa Java integration:

http://buzzlabs.com/aquataxx/

...and check out MacTech magazine this December!

Steve Klingsporn
Geek
     
Mac Enthusiast
Join Date: Apr 2001
Location: 127.0.0.1
Status: Offline
Reply With Quote
Nov 10, 2003, 08:22 AM
 
Originally posted by buzzlabs:
I have written an article about Cocoa Java that will be in this December's issue of MacTech magazine.
Awesome... I can't wait to read it. I've always wished that CocoaJava would get more coverage in the press. There's a real lack of information out there which leads people to a lot of misconceptions. O'Reilly even published a book called "Mac OS X for Java Geeks" (which I bought) and it didn't even touch on the subject once. With a book that narrow in focus, you'd think at least a chapter or two would be in order.
     
   
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:22 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