Menu bar in wrong place (in window) on Mac OS. Netbeans Platform Application - macos

I'm building app in Netbeans Platform 7.1, and the problem is that the menu bar is in the window and not on the top of the desktop, when I run it on Mac OS (Lion).
Where can be the problem?

You will either have to switch back to Java 6 so you can use Apple's implementation or you will have to be patient for OpenJDK to be complete their port.
Edit:
Installed the latest macportpreview of OpenJDK 1.7. But my netbeans platform based application still wasn't using the apple menubar. Then made a small Swing application and it did use the apple menu bar. So it is possible. Tried several things with the netbeans.conf in several locations but didn't help. However the following did work. In one of the core modules in my netbeans platform application I allready had a ModuleInstaller. So I changed the restored function to contain the following lines:
#Override
public void restored() {
if (System.getProperty("os.name").equals("Mac OS X")) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
}
}

Make sure that:
a) -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true are included in the "etc/netbeans.conf" settings file. That makes the platform to place the menu correctly.
b) You're including the "Apple Application Menu" module inside the "platform" cluster, along with the "Window System API" and their dependencies.
Cheers,
Antonio

Related

QT QSystemTrayIcon on mac is squashed in the second screen

I create a system tray icon on MacBook. And I connect a screen with Mac. When I run this program,the system tran icon on the monitor is squashed.
QSystemTrayIcon *m_tTrayIcon = new QSystemTrayIcon(this);
m_tTrayIcon->setIcon(QIcon(QPixmap("/Users/xxx/Downloads/pic.png")));
m_tTrayIcon->show();
when the monitor is not focused, the icon is squashed.
and when I click the desktop of the monitor, the monitor is focused, the icon is also become normal.
This is a known bug in Qt with new verisons of MacOS. Check out this bugreport.
Solution would be either use fixed versions (they claim to fix it in 5.12.11 and 6.1.0) or compile cocoa plugin by your own and ship it with your application instead of one provided by Qt.
Fix is just a one line of code that you need to apply. The easiest way is:
download qtbase (for example from github) and checkout version you need
In case you will use Qt < 6.0.0 (i.e. building with qmake rather than with CMake) - copy .qmake.conf from root to qtbase/src/plugins/platforms/
you go to qtbase/src/plugins/platforms/cocoa and open cocoa.pro or CMakeLists.txt (depends on what version of Qt you have checked out)
you apply patch and compile the plugin
From now on you should use cocoa plugin you have just compiled instead of one shipped with Qt (either replace it in Qt installation or every time you deploy your application)

RCP application menus in Mac OS

I am struggling to figure out how RCP applications on Mac OS work with "About" and "Preferences" actions. I create them with ActionFactory and place them to relevant file menus. Works fine everywhere. However, on Mac OS those actions get placed into application menu by something which knows better where to put other peoples good actions. But of course they don't work.. Any idea why?
(eclipse target platform 3.7, OSX - the latest El Capitan)
For the 3.x style action bar advisor add the menu item in the normal place but use an ActionContributionItem and set the menu item in be invisible on the Mac:
So for Quit something like:
IWorkbenchAction quitAction = ActionFactory.QUIT.create(window);
register(quitAction);
ActionContributionItem quitItem = new ActionContributionItem(quitAction);
quitItem.setVisible(!Util.isMac());
menu.add(quitItem);
'About' and 'Preferences' can also be specified like this.
Util is org.eclipse.jface.util.Util.
Eclipse will find these items and move them to the correct place.

Xcode 5 Cocoa App Fails to Load Nib on OS X 10.6

I'm creating a Cocoa application for 10.6 and newer OSs. I created a brand new document-based application in Xcode 5 (10.9) and changed two settings to make it 10.6-compatible: I changed the deployment target to 10.6 and turned Auto Layout off on both MainMenu.xib and xxDocument.xib, the two default nibs that are included with the document-based template. I archived my application (no code signing) adding no other code and tested it on four different OSs. Here are the results:
OS X 10.9: Launches and shows a new document window ("Your document contents here") as expected.
OS X 10.8: Launches as expected; same as 10.9.
OS X 10.7: Fails to launch; Console applications yields "App Name: Unable to load nib file: MainMenu, exiting".
OSX 10.6: Fails to launch; Console yields same as 10.7.
I'm quite baffled as to the behavior of my application. I added absolutely no code to the template document-based app that Xcode created for me; I just changed the required settings to make it compatible with 10.6 and up. I also tried turning off ARC in the build settings, which made no difference at all. I checked Apple docs and also searched for other questions about the console error I received, but none of them were related to this problem. I was very surprised that 10.7 exhibited this behavior, as 10.7 is compatible with ARC. I would greatly appreciate any advice on how I can fix this problem. I would suspect that there is an easy modification to the default template, as Apple probably wouldn't supply a template that requires extensive modification to merely get it working. Thanks.
UPDATE:
As suggested, I turned off base internationalization in Xcode. I ran the app, and it worked fine. I exported the application (no code signing) and tested on all of the above OSs. This time, the error that I received above occurred for all OSs. This even occurred on the SAME machine that I built the project with, the only difference is that I didn't run it from Xcode. My next step was to actually make a MainMenu.xib file (because removing base internationalization deleted the old one) and set that as the main interface. Now not only do I get the error in the exported application on all OSs, but it shows up in Xcode when I try to run the application! Is there something else that I am missing?
AS mentioned before you need to disable Internationalization Base.
In the Project Navigator Click on the on the first item which is your project (denoted by blue page with white A in it, it is the root of all other items)
You should by default see the Info page to the left (if not select it from the tab at the top)
The last item in the Info property sheet is Localization. Under Localization you will have the ability to add and remove languages and you should by default have two already Base, and English.
Delete both, and deselect the check box "Use Base Internationalization"
Once you have done this, remove the any *.xib files you have from the project itself. MAKE SURE TO ONLY REMOVE REFERENCES !!!DO NOT SEND TO TRASH!!!
Once the references have been removed, go into Finder, Open your project directory and you will find a directory called Base.lproj with your *.xib files located in them. Copy or move them one level up to your project directory, and delete Base.lproj directory.
Go back into xCode and add back in your *.xib files. ++K to clean the project, then ++R to rebuild.
This should move the *.xib files in the App Package from Base.lproj (where 10.6 does not seem to find them) to the Resources file folder, and solve the problem.
Newly created Xcode 5 projects have base internationalization turned on. Base internationalization is supported on OS X 10.8 and later. You'll have to turn off base internationalization to support 10.7 and 10.6. See the following Stack Overflow question for more information:
Base.lproj/MainMenu.xib is not available when compiling for targets before Mac OS X 10.8
Another thing you may need to do to support 10.6 is to set the deployment target to 10.6 for both the project and the xib files. I know you said you set the deployment target to 10.6 in your question, but it wasn't clear if you set it for both the project and the xib files. As you're discovering, Apple's project templates do not place a high priority on compatibility with old OS versions.

Delphi XE2 - No output files created when building project for OSX platform

I have some problem which is stopping Delphi XE2 from building my project for the OSX platform. I've gone back to basics and created a brand new 'Hello World' console application project. The program compiles/builds/runs fine on the Win32 platform. I add OSX as a new platform for the project, and my remote profile is configured correctly and clicking 'Test Connection' confirms it can see my MacBook. Problem is when I activate the OSX platform, then click 'Build' (under Debug or Release) then the progress window appears as usual and no errors occur, but no output files are created and the 'OSX32' subfolder doesn't get created.
Any ideas what might be the problem?
Solved it - no idea how it got there but in Tools->Options->Environment Variables I had an entry under 'User overrides' as follows :
PLATFORM = Win32
This meant the compiler was only ever building for Win32, regardless of which platform was currently activated.

bundle a jnlp so you can add to dock on a mac?

I want to be able to drag Findbugs to the Dock on my Mac.
The problem is it's a JNLP.
Is there a distilled idiots guide to creating an Mac application bundle from a JNLP?
I saw this article on the Apple website: http://developer.apple.com/library/mac/#documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.html
but it was a case of 'information overload'!
Quoting from the Java Web Start section of the linked article:
Mac OS X’s desktop integration with Java Web Start lets users can create a local application bundle from any Java Web Start application. The Shortcut Creation setting in Java Preferences controls whether the user is prompted to create an application bundle when opening a Java Web Start application. Bundled Java Web Start applications have all of the benefits of native application bundles, which are described in “Mac OS X Application Bundles.”
Try looking in Applications->Utilities->Java Preferences. Click on the Advanced tab. You should see the Shortcut Creation setting. Let us know if it works for you.

Resources