Java-Mac OS X integration without breaking platform independence

I want my application to integrate Mac OS X better. I read Mac OS X Integration for Java and I found out that I need to import com.apple.eawt.*and write additional code. But if I do, my application will not work on Windows due to the lack of a link. I could do this with a preprocessor command if I write in C, but it is Java. How can I do this without dividing the code file into 2 branches?

+5
source share
6 answers
+9
source

, , com.apple.whatever, , .

.

+3

, Swing- OS X.

  • Swing Go Native ( 1, 2, 3)
  • Java Mac OS X ( 1, 2)
+2

, "" , "swing" MacOSX ( 10.6)

System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Your app name");
try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} 
catch (ClassNotFoundException ex) {}
catch (InstantiationException ex) {}
catch (IllegalAccessException ex) {}
catch (UnsupportedLookAndFeelException ex) {}

, Mac. Mac OSX l & f.

, :)

+1

, , , Mac OS X.

0

, . - "Mac OS X Integration for Java" "J2SE 5.0 Apple Extensions Reference" com.apple.eawt, ( 2015 ) - ", ". Apple Developer . : , com.apple.eawt - http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/macosx/classes/com/apple/eawt

com.apple.eawt, , removeAboutMenuItem() " " setAboutHandler "(AboutHandler) ". setAboutHandler (null) , .

0
source

All Articles