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.
Related
I need to add a popup menu to the JFrame, but when I drop that component there it just dissappears. I can see it in code, but there is no way to edit anything about it. Is there a way I can edit it like say menu bar?
I use Netbeans 7.2.1 if that is important.
PS - Yes, I tried googling and found only this, but it is not helping...
Okay, I figured it out by myself.
Open Windows -> Navigation -> Navigator it will show a navigator window with all components currently on jFrame.
In that navigator window then click Other components.
In there all non visual components including jPopopMenu will be listed.
By clicking on any of these components it is possible to edit their properties.
Editing the popup menu visually is possible by double clicking on it. It will then bring up visual menu builder.
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 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...)
I've recently installed window builder plug-in on my Eclipse IDE. When I create a New project and add window builder or anything, I'm unable to drag even a button from the palette.I might be dragging it the wrong way or there might have been something missing in the path etc. Does anyone know the solution to it? It'll be highly appreciated. Thanks!
What do you mean by "I'm unable to drag even a button from the palette" - is the palette not responsible to mouse events?
Try creating File->New->Other and selecting Window Builder->Swing Designer->Application Window. Switch to Design tab.
Basically you don't drag components/layouts to the graphical view of your window. You should select for example JButton by clicking it first. Afterwards you click (second time) on the window.
I'm writing a simple Java application that uses JFileChooser. However when interacting with the JFileChooser Panel, I want every time I right click on a file, it should trigger the context menu we often see in Windows, with buttons "Select", "Open", "Open in a new window" etc. Do I need some APIs to invoke this Windows function?