I have an applet that displays a dialog box on click of a button. When the dialog box is first displayed, it is shown using the native look-and-feel of the OS. When the dialog box is displayed a second time (same page, browser, OS, etc.), it is shown using what I think is the Swing look-and-feel. To my knowledege, I do not explicity set the look-and-feel of my applet. Should I be doing so to avoid this inconsistent behavior?
Please elaborate what you mean by "display". A different screen on the same computer? A different computer? Is the same version of Java installed? Is the exact same version of the OS installed?
The user can influence the L&F with environment variables. These docs may help.
Also, for the native Windows XP L&F, you need a special DLL.
Related
I've searched a lot but I didn't find any anwser to my issue.
I recently discovered JNativeHook and I use it to bring to the foreground an application window when I click on a key, even if the application has not the focus. Everything works good when I use keys like "a" or "f" but what I want is to use the "left-home" key of my keyboard.
The problem is when I do that, the windows menu appears but not my application which blinks in orange on the bottom launcher bar.
I think this is a normal behavior since the windows menu has a stronger priority than my application.
Do you think there is a possibility to override the default home button behavior? What I need is to bring to the front my application from elsewhere when I clicked on the left-home button.
Thanks for your replies,
JNativeHook is getting a passive keyboard input from the operating system. If you press the Windows Key, the OS will bring up the menu if it receives that event. If you want to prevent that behavior, you must consume the event before the OS receives it. You can check the Wiki article for unsupported method of consuming events on Windows and OS X.
I've had the same issue with CTRL and similar keys, you just have to run the program using an administrator command prompt (or with sudo-access on Linux)
It won't work if you're using Windows Terminal on Windows 10 though, you have to use CMD, also if you want your end-user to only use the program using administrative privileges, you'd have to add a manifest to your wrapper (You can do that in Launch4J afaik)
Mac OS X features an 'About' screen for applications.
But how do I change the version number that is displayed, the icon shown, and add some text programmatically? I don't want a seperate Mac application bundle trough, I want to keep anything in a single multiplatform Jar file. Thank you.
The way to do this was to use OSXAdapter and call its setAboutHandler(...) method pointing to your method for popping up an about dialog. But apparently that's legacy now.
On Windows 7 an application can control how to group their Windows on the taskbar. Windows has some default settings related to the executable, how the shortcut was created, the name of the program, etc. to apply some default grouping. The problem with host based applications like Java, is that the same executable is used by many programs so Windows has some registry settings to set that javaw.exe is a host app. When this happens, applications must configure at runtime how to group Windows and enable pin to taskbar. I am already setting Application User Model IDs in order to group Windows as needed.
The problem that I haven't found solution is that for a multi window application: how to set a stable icon to be used on the taskbar?. The default Windows behavior for an application, say for example with two windows, where each windows has his own icon, the task bar icon shows the icon of the first opened window, if that window is closed it changes to the other one, and the process is repeated every time windows are opened and closed.
There is some API to set the icon when the user pin an application to the taskbar setting System.AppUserModel.RelaunchIconResource window property, but the documentation says that this icon is used when the app is being pinned, so according to that it only is used if the application is running from that pinned applications, leaving the problem open for applications that are not able to be pinned (or that the developer do not want to allow pinning).
There are options like generating a new executable with the icon (launching the JVM from that application), creating a shortcut with the correct AppUserModelID. Those aren't solutions for me because the application is distributed using Java WebStart/JNLP, so the application shortcut is created by Java and the launcher is a marked as a host application (as it should)
the other solution is to set the same icon to each window when running on Windows 7, that icon, with the exception of the taskbar one, is not very prominent on Windows 7 on Aero mode, but with Aero disabled it is, it is the icon used on the Alt+tab switcher without windows previews, something I want to leave looking different for each windows
Note: This is a tagged Java but really is a question for any platform that use a host executable (javaw.exe, python.exe ...)
I have a Java application that uses JDialog boxes for displaying certain information. The JDialog boxes are not minimizable (and shouldn't be), but we've run into a problem specific to Linux KDE desktop (4.3.5, but I believe it probably applies to 4.x). KDE window decorators appear to be overriding Java's and are allowing minimization of JDialog boxes. Windows/Solaris/Linux (GNOME desktops) do not allow minimization of JDialog boxes, it appears to only be KDE. Is there an attribute that I am missing or other way to explicitly say this JDialog box should never be minimized?
Other potentially useful info:
Java: JRE 1.6.0_17
Linux: openSUSE and SUSE Enterprise Server (both running KDE 4.3.5)
You can try removing the whole dialog title by calling dialog.setUndecorated(true) but this means that the dialog can't be moved anymore.
This related question also has some pointers: Remove "X" button in Swing JDialog
Though I cannot find a way to navigate around the JDialog minimization, I found a work around. Setting the visibility of the display to false, then toggling back to true causes the minimized window to become visible and available again:
myDialog.setVisible(false);
myDialog.setVisible(true);
In the NetBeans 6.9 IDE, if you create a
New Project >> Java >> Java Desktop Application and run it, you will find that the menu items have mnemonics, but only after ALT is pressed.
(The netbeans program itself uses this style of menu.)
However, if you create a new File >> Swing GUI Forms >> JFrame Form, and add a simple menubar with mnemonics, then run the JFrame, the mnemonics will always appear without having to press ALT. This is what I would prefer.
(Firefox uses this style of menu)
My thoughts are that the org.jdesktop.application overrides the default setting, but that's just a guess. Anyone know how to make a SingleFrameApplication not require ALT to be pressed?
Thanks.
Edit:
The problem was found to be that JFrame and JDesktop use different default Look and Feels
It's a Windows setting. In XP go to:
Control Panel
Display
Appearance
Effects
Hide underlined letters for keyboard navigation until I press the Alt key
(Win7 should have a similar setting somewhere, I suppose.)
The default setting is on, so Java is right and Firefox is wrong (even Office 2003 doesn't respect that setting).
Uncheck it and you'll always see mnemonic underline in Java.
Note that only Windows LAF correctly respects the setting. Motif and Metal always show the underline. I don't use NetBeans or jDesktop but I guess it uses system LAF and thus the underline is correct.
If you still want to always show underline under Windows LAF (please think twice before you do), call UIManager.getLookAndFeelDefaults().put("Button.showMnemonics", false), which does NOT seem to work for XP because WindowsMenuItemUI#paintText only checks the flag under Vista. You could check Win7 JDK yourself.
Note that there's an accepted bug when the setting is on, which goes like this (saving you some time to parse the 2nd most awful bug tracking system in the universe. The worst is an in-house ColdFusion system my company used to have): create one menu with mnemonic, for example &File, press Alt-F, release, press Alt-F again, the underline is gone. They are back as soon as you do anything else, clicking, or just press Alt by itself.