I am given a task to port a java application with a JComboBox from OS2 to Windows.
The JComboBox in OS2(JRE1.4) has a behavoir that when the popup is open, user click on other windows, the popup remains open. But when that run in Windows (JRE1.6), user clicked on other windows, JComboBox will close automatically.
How can i achieve the same behavior in Windows? I want it remain opened...
not possible, JComboBoxes popup always to hide on focusLost, these changes were fixed in Java 1.4
have to create own Component that simulating funcionalities from JComboBox, popup window should be based on JDialog / JWindow (strongly don't suggest that...)
Related
I've made a Menu bar and when i click on Help>>about a popup window jumps.
i also put on the popup window a button and i'm wondering what's the command i should use to close the popup window in the button action listener but not abort the program.
(i tried before to use (System.exit(0)) but it's abort the program.
i'm wondering what's the command i should use to close the popup window
You would use:
window.dispose();
Or better yet just use a JOptionPane to display the "About" dialog. The JOptionPane will build the dialog and buttons for you.
Check out the section from the Swing tutorial on How to Make Dialogs for more information and examples.
I'm currently developing an application in JavaFX to create a virtual keyboard.
I had done it in Swing, and I worked with an unfocused JFrame to be able to send KeyEvent to the background application (for example Word is open, my always on top JFrame is visible, I click on a button, and it fire key event to Word).
In Swing I did:
frame.setFocusable(false);
frame.setFocusableWindowState(false);
But in JavaFX I didn't find how to do it, I saw
stage.setFocused(false);
But it's not working, is there an solution or workaround ?
Requested a feature on report board
https://javafx-jira.kenai.com/browse/RT-40494?page=com.atlassian.jira.plugin.system.issuetabpanels
Summary: make invisible app visible again by clicking desktop icon.
I have created a java desktop application and used Launch4j to create the executable. My application needs to run as a single instance. I have achieved this my checking that option in the Launch4j configuration GUI. When the user clicks the x button on my window (I'm using a JFrame) the window is made invisible. It is NOT disposed. When the user double clicks the system tray icon, the application window is made visible again. When the user double clicks the application desktop icon, and the application is already running, I need my main window to become visible again just like the behavior with the system tray icon.
Launch4j provides an option for a window title under the Single instance tab. I think that this option may be intended for what I need. However, when I set a window title and carry out the steps described above, I get a blank white window. With the blank white window displayed, double clicking my system tray icon will cause my app to appear in the white window. This behavior suggests that maybe changing my code relating to the top level container (Window,Frame,JFrame) might have an effect.
Do you have any ideas on how to incorporate this behavior while still using Launch4j? (it's convenient).
edit:
The core of my question is how do I define what happens when the user double clicks my executable desktop icon? If I could check for an existing instance and redirect the double click to the associated system tray icon, that would be fantastic.
I was able to accomplish my goal. In the Single Instance tab I gave the title of my main JFrame in the field for "Window title". I then added a WindowFocusListener to my main JFrame. When my JFrame receives focus, I check to see if it is already visible. If it is not, I call the appropriate method for displaying my JFrame.
The key observation is that double clicking the exe icon generated by Launch4j fires a window focus event when a window title is given in the setup. I am not sure if that is the only event that is fired, but by listening for that event, I can take whatever actions are necessary from within my java code when the user double clicks the desktop icon.
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.