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.
Related
I have a Java Swing application that's using "system" look and feel (as i'm using Windows, i'm getting "native Windows" controls in my app). Now, for "branding" reasons i'm trying to enforce particular color on my buttons but i have a problem. I prefer using UIManager but i can't find any property that would let me choose "button mouse over" color.
Take a look at the picture attached please:
Seems like i'm stuck with default Windows "light-blue" color for button mouse over (pointer is not visible in this screenshot).
How can i change that color?
For me only option is some sort of UIManager global variable, i simply can't afford to go through all buttons in my app and override some custom button or add listeners for "mouse enter" and "mouse exit".
The best way to do it is to customize the LAF of your application, using this library TinyLAF.
Very easy to use, with nice control panel to help do some theming and using the created theme file on your project.
Here is a small tutorial on how to use it in case the doc is not too clear
http://yourjavacode.blogspot.com.ng/2013/05/tinylaf-change-your-java-look-and-feel.html
I hope this helped out.
I have come across a stickler of a problem.
In the swing environment there is a function that is available TextArea in the AWT Components. However this is not present in either the JFace or the Swing environment.
has anybody come across a solution? Would I have to make my own Interface as a work around?
Thanks in advance
You can use the SWT Text control for simple single or multi-line text, or you can use StyledText if you want text with fonts and colors.
When you open a dialog in Eclipse, where is a form layout, you can see that when you hover your mouse over some item, its label or space between them, there's an auxiliary arrow shown. Screenshot:
My question is: is there any (simple) way to achieve the same in Java with SWT and JFace?
Regards
No there is no standard way to achieve this through SWT or JFace, as it is not a built in feature. It is not that difficult to add on your own though.
Have a look at this ConfigurationBlock.java file from the PDE source. This class is the base for all option blocks in PDE preference pages. This exact same code snippet is also used by JDT but it has a different copy in OptionConfigurationBlock.java.
The method that gets called for each combo control is ConfigurationBlock#addHighlight(..), which is responsible for adding the highlight when the control is in focus or when mouse is hovering over its label.
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.
I want to show the form when someone presses a key in my java swing application when it is in system tray. I have tried adding key listeners, but it didn't work. I know this can be done by using Popup menu. But I want to know can java swing app can detect keystrokes when it is in system tray? can anyone help me to do this. Thank you.
You might look at JIntelliType (http://melloware.com/products/jintellitype/index.html) but this will only be a windows solution. There may be something similar for other OSes. This library provides global hotkey registration which is what you need.
Update: looks like they reference a similar API for linux also.
You can use the JNI to hook into Window's Window-Event-API, i think, but this is complicated. A more simple but slightly hacky way to do it is create a link in the Start>>Programs menu, set a key-combination there, then with that link call your program into windowed-mode or fullscreen-mode.
Short answer, no, it's not possible.
See Is it Possible to show a previously hidden JFrame using a keylistener