codecentric / NSMenuFX

Other
128 stars 27 forks source link

Use Swing instead of SWT #5

Closed msgilligan closed 8 years ago

msgilligan commented 8 years ago

This is somewhere in-between a question and a feature request. A little of both I guess.

Why use SWT instead of Swing? Since Swing is bundled with the JRE, couldn't Swing be used to build the Mac OS menus in the same way you are doing with SWT. Then there would be no external dependencies -- especially natively compiled ones.

0x4a616e commented 8 years ago

Hi! Thing is, I don't actually use any SWT stuff... This comes in by eclipse swt from which I just use the cocoa native bindings. I'm currently working on a solution that uses neither SWT nor Swing but just JavaFX classes. This is however not so straight forward as it requires some reflections due to restricted access and one also looses the capability to rename the application menu (although this currently not ideal...)

So before switching to Swing, I'd like to try out a pure JavaFX solution. I'll push that on a branch within the next days so you can try it out if you like.

msgilligan commented 8 years ago

What I'm looking for:

Additional nice to haves:

0x4a616e commented 8 years ago

I now pushed a pure JavaFX implementation on a branch https://github.com/codecentric/NSMenuFX/tree/pure-javafx It is basically a complete rewrite of the existing project, so have a look at the test samples and/or the readme first. It'd be nice if you could give me some feedback.

What exactly do you mean by syncing the menu bar state? That the menu bar of all stages is updated when changing the menu bar of one stage? If so, I think this could be added without much effort.

Any I'm not a Windows user, so I'm not sure what exactly the Windows menu is :wink: Is that a menu you have in your start menu?

msgilligan commented 8 years ago

I spent some time trying to use Swing (com.apple.eawt.Application) with JavaFX without much success. With an understanding of the internals (which I currently lack) it may be possible to make it work, but it's certainly no "slam dunk". (The next thing to try on this front is using FX without a primaryStage.)

It'd be nice if you could give me some feedback.

I was able to check out and run the samples on Yosemite via IntelliJ. I'd like to see a sample that looks like a standard Mac OS X app (e.g. what you get when you use the Mac OS X application template in Xcode) (This is preliminary feedback, I'll provide more in a few days)

What exactly do you mean by syncing the menu bar state? That the menu bar of all stages is updated when changing the menu bar of one stage?

Yes. I want to build a multi-window app that works like a real Mac application. The menu bar can change when the front window changes, but many parts of it are the same and need to be kept in sync.

I'm not sure what exactly the Windows menu

It's the standard Window menu on Mac OS X described in OS X Human Interface Guidelines.

msgilligan commented 8 years ago

Is JDK-8091517 essentially what you are doing here? Is submission to OpenJFX a possible future goal?

0x4a616e commented 8 years ago

Ah, now I got it :wink: Yes, the window menu is certainly a good idea and should be possible. I'll try to complete the sample App from your PR. Submitting to OpenJFX is certainly an option. Thx for the link to the ticket, I'll see if I can contribute something.

0x4a616e commented 8 years ago

Just pushed some changes adding a global menu bar sync and a window menu. It's all added to your example

msgilligan commented 8 years ago

Cool. When do you think you might publish a JAR to jcenter or Maven Central?

0x4a616e commented 8 years ago

should be there!

<dependency>
    <groupId>de.codecentric.centerdevice</groupId>
    <artifactId>centerdevice-nsmenufx</artifactId>
    <version>2.0.0</version>
</dependency>