I have a Java Swing application running on OSX that uses Quaqua. All the TextFields and TextAreas have a popup menu on right click. This must be done by Quaqua as it is not standard in Swing.
My question is:
How do I set my own Actions on the popup menu?
Please Note. This is a question about Quaqua popup menus NOT any Swing popup menu. If you are not familiar about Quaqua then please don't answer.
A pop-up menu is the same as a regular menu. The Swing tutorial about menus covers how to use them, how to insert entries, ... . Reading that tutorial should get you started
The popup menu set by Quaqua can be removed by setting a client property:
myTextField.putClientProperty("Quaqua.TextComponent.showPopup", Boolean.FALSE);
You can then add your own MouseListener to handle creating your own pop up menu.
I haven't figured out, however, to make this change global, and so I have to set the client property on each of my text fields individually, which is a bit of a pain.
Related
I was trying out example of how to create Menu using SWT. I am using Eclipse on Mac. I was referring to this example. Whenever I run this example, I have two problems:
The Menu doesn't show up until I make it full screen.
The Menu buttons are unresponsive i.e when I click on Help, it doesn't show up the dropdown containing Get Help.
Do I have to make some spwcific changes while creating Menus on Mac?
Probably 7 years too late, but if anybody finds this I had the same problem and I simply switch to another window and switch back to the display and it worked. I don't know why it works but it did it for me and I hope it will for you as well.
I've been creating GUIs using Jigloo for a game and I've run into a problem.
I would like one of my GUIs to have some properties that the JOptionPane has but I don't know how to describe it properly.
The JOptionPane, when open, doesn't allow a user to access the other open windows. It gives a ping sound and flash the JOptionPane window.
Is there a name for that? Also can I put that onto one of my GUI windows?
Thanks in advance
The JOptionPane uses a modal dialog. See How to Use Modality in Dialogs for details.
I have added a JPopupMenu with certain JMenuItems to a JTable in my java application.
I then set accelerators for those JMenuitems.
Now my problem is that when I try to use those hotkeys, they don't work until I open that JPopupMenu.
When that popup menu is open at that time, the hotkey works properly which is really useless. Please help me.
The accelerator bindings only work on components added to the GUI. A popup menu is not added to the GUI until the popup has been invoked.
You can try:
Add you popup menu to the menuBar of your frame. Then the accelerator will be recognized
Manually add the KeyBindings for each accelerator in you popup menu. Read the Swing tutorial on How to Use Key Bindings for more information.
I have written a java app using NetBeans 7.2 under Os X 10.8.2 on a 2012 Mac Book Pro and I have decided I want the screen menubar removed or hidden since there is no easy way of editing the screen menu bar for my java app. I have searched and searched on the screen menu bar but I have not found anything showing how to: edit or hide. The only information I have come up with, using NetBeans is how to combine my JMenuBar into the screen menu bar and the examples for that didn't work.
If someone can point me into a good direction for editing the contents of the Screen Menu Bar I would be more then happy to use it. But if there is no easy way of doing this without re-writing the source code with an override then I will stay with my own menu on the form and hide or remove the Screen Menu Bar if this can be done.
You cannot. The system menubar is a shared user interface element — you can only hide it if you're running full screen, at which point you end up with no menu bar at all.
You should really look into getting your application's menu bar to not appear in the window, as this is not an expected user interface idiom on Mac OS X. If you are not doing so already, this code may help:
System.setProperty("apple.laf.useScreenMenuBar", "true");
If that doesn't do it, there are a number of questions in the "Related" sidebar with information that may help.
I'm trying to use Ctrl+C, Ctrl+X and Ctrl+V as Swing JMenu shortcut using NetBeans Visual Designer in my app. All of other shortcuts work except these.
What's the problem?
Those Key Bindings are used by default for text components. So if focus is on a text component they will invoke the default Action for the text component.
If you need more help then post your SSCCE that demonstrates the problem.
It is pretty hard to guess what the problem is from your description, but let me guess: do you happen to have JTextArea on the same JFrame? It has some neat property called actionMap (setActionMap(), getActionMap()), which probably has these Accelerators registered.