Key binding for SWT Text - java

I have a dialog(org.eclipse.jface.dialogs.Dialog) containing a Text(org.eclipse.swt.widgets.Text) field. I want to add key binding.
For example: Once dialog is open when user press key 'Ctrl + E' some changes need to be performed in Text field.
How to achieve this using key binding ?

Related

java Swing JCombobox multiple selection using ctrl key

I am trying to create JCombobox with multiple selection by holding ctrl key.
i have created Jcombobox for multiple selection by overinding ListCellRenderer.
it is working fine on selecting one by one .
but i required to select multiple using ctrl or shift key any way to achieve this.

What is the SWT key constant for the menu key

Does anyone know what the key constant in SWT is for the menu key on the keyboard (right next to right-Ctrl)?
This key has a virtual key code of 0x5D (93). I need it for correct key combination detection.
There seems to be no constant defined for the Menu key.
In order to detect if a context menu was opened by mouse or by keyboard, you should add a MenuDetectListener. The detail field of its MenuDetectEvent is either SWT.MENU_MOUSE or SWT.MENU_KEYBOARD.

Prevent JComboBox from filling in the field automatically

I'm trying to create a JComboBox that shows filtered suggestions based on the input from the user so far. Filtering the model works, but the default behaviour of the JComboBox is to automatically put the current value from the list into the textfield if you go through the list with the arrow keys.
As I'm filtering based on the content of the associated PlainDocument, navigating the ComboBox list with arrow keys triggers the filter as the content of the document is automatically changed. The insertString method doesn't distinguish between manual user input and the selection by the ComboBox itself.
I found the suggestion to set the "JComboBox.isTableCellEditor"property to true, which does seem to disable the automatic input, but it does seem to do more than that and breaks the usual behaviour in my case.
Is there a way to intercept the automatic insertion of the currently selected item into the Document? How can I distinguish between the real user input, and what the JComboBox inserts into the field automatically?

getattribute for changing textfield value when selection is done in another drop down box

My 1st question, hope I make it easy for everyone to understand.
Now I am trying to getattribute of text field whos status is changed when I select a value on a drop down box.
When I select vessels in dropdown box, text field value is changed to (see attachment)
When I select companies in dropdown box, text field value is changed to (see attachment)
So I am clubbing my test scenario with outline which means I am passing different values which will change attributes of text field.
I want to write a if condition so that it checks wat is value selected in drop down and according send keys to text field.enter image description hereenter image description here

Setting custom focus key to exit focus of components like JTable

I want to set custom focus key in my application. Default is TAB. Sometime I need to omit for some component. Sometime need to reverse by another key. I find that when JTable gets focused. TAB only works and select within its row and never go outside the table. In my case, I need to change focus when all row has finished selection or a hot key to omit entire table.
Sometime I also need to implement system focus key as client already may habituate with it.
How can I achieve that easily?
I think this is what you are looking for.
note :
Set<AWTKeyStroke> set = p.getFocusTraversalKeys(KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
set = new HashSet(set);
KeyStroke up = KeyStroke.getKeyStroke("A");

Categories

Resources