This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Ctrl+X,Ctrl+C,Ctrl+V not working! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Ctrl+X,Ctrl+C,Ctrl+V not working!" Watch "Ctrl+X,Ctrl+C,Ctrl+V not working!" New topic
Author

Ctrl+X,Ctrl+C,Ctrl+V not working!

Santhi Chalasani
Greenhorn

Joined: Sep 26, 2009
Posts: 8
Hi All,

I am facing an issue where in my GUI (which is developed using Swings), the short cut keys Ctrl+X,Ctrl+C,Ctrl+V keys not working for text,panel and cell fields (I didnt check for all the other fileds which can be editable).

Our servers which runs on solaris use CDE/JDS environments. (CDE- Common Desktop Env., JDS- Java Desktop System). I found the issue on CDE with look and feel set as "SYSTEMLOOKANDFEEL". When the look and changed to "METALLOOKANDFEEL", the issue is not seen. Also, On JDS machine, i dnt see the issue in both the cases.

Any help in resolving the issue is appreciated.

Thanks & Best Regards,
Santhi
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Santhi ch wrote:Swings

Swing is a proper noun.

Also, read your private messages.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
Maybe the LAF doesn't support those key bindings. You can try the Key Bindings app for your environment to see what binding are used.
Santhi Chalasani
Greenhorn

Joined: Sep 26, 2009
Posts: 8
Hi Rob,

Thank you very much for the response. Unfortunately i dnt have access to the link you have provided.

I am working out on the alternate shortcut keys ctrl+insert,shift+insert,shift+delete instead of ctrl+c,ctrl+v,ctrl+x. Those alternate keys works fine for all the JComponents we are used in our GUI's excpet for JTable cell.

I just wanted to know whether this JTable supports these alternate shortcut keys or not. I explored alot in this front but as of now i have no clue.

Could someone send me the info like JTable component supports which lookandfeel, which version of java for which type keys in windows as well as Unix enviroments and all the stuff related to JTable component? That would really help me to resolve the issue soon.

Thank you in advance,
Santhi
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
The link I provided has all the information. Try it again. I'll get back to you in a month.
Santhi Chalasani
Greenhorn

Joined: Sep 26, 2009
Posts: 8
Hi,

Can we support both short cut keys(ctrl+x,ctrl+insert) for Copy operation at a time. Is it possible to include keyevents for both keys together?

My code as below:

myCutAction = createAction("Cut", myEditMenu, false,KeyStroke.getKeyStroke(KeyEvent.VK_X , KeyEvent.CTRL_MASK));

The above code is written for ctrl+X for copy operation.

Can we have the same code works for ctrl+insert as well for Copy operation?

Thank you in advance,
Santhi
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

You would need a new Action object because Action objects can only contain one keystroke.

If you check out how key bindings work then you can do it with only one Action object. Key bindings map from a keystroke to some key, and from this key to an Action. This allows one Action to be mapped to from multiple keystrokes, and this is just what you want.
Santhi Chalasani
Greenhorn

Joined: Sep 26, 2009
Posts: 8
Hi Rob,

Thanks for your response. I understood how keybinding works...but i dnt know how to implement the same in code.

I've tried like this...but it is working as Ctrl+Shift+Delete. but i want the code for Ctrl+X and Shift+Delete.

myCutAction = createAction("C", myEditMenu, false,
KeyStroke.getKeyStroke(KeyEvent.VK_C | KeyEvent.VK_DELETE, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK));

Please correct me.

Best Regards,
Santhi
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
You need 2 separate bindings. See you again in a couple of weeks when you decide to reply.

Don't you think it would be better to reply the day you post a question and get an answer?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Santhi Chalasani wrote:I've tried like this...but it is working as Ctrl+Shift+Delete. but i want the code for Ctrl+X and Shift+Delete.

That's not a key binding. How To Use Key Bindings.
Santhi Chalasani
Greenhorn

Joined: Sep 26, 2009
Posts: 8
Hi Rob Camick,

I am sorry for the late respone. I work on several issues depend on their priority. As this issue is of low priority i am not concentrating much on it.
I'll try to respond quickly and close the issue as early as possible.

Thank you for your support.

Hi Rob Prime,

As you mentioned yesterday, Key bindings map from a keystroke to some key, and from this key to an Action. As per my understanding, in our code CTRL+X is the key stroke which is mapping to a key "Cut" and from this key to myCutAction. Only the thing i have to do is to map keystroke CTRL+INSERT to the same key and to the same action.


Please correct me if i am wrong. I am new to Swings so it is taking some time to understand these concepts. I had visited the same url sometime back, but still i'll have a serious look into it once again.

Thank you for your support,
Santhi
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
As per my understanding, in our code CTRL+X is the key stroke which is mapping to a key "Cut" and from this key to myCutAction. Only the thing i have to do is to map keystroke CTRL+INSERT to the same key and to the same action.


I already gave you an examle of how to do that over a month ago.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Santhi Chalasani wrote:As per my understanding, in our code CTRL+X is the key stroke which is mapping to a key "Cut" and from this key to myCutAction. Only the thing i have to do is to map keystroke CTRL+INSERT to the same key and to the same action.

There is a difference between assigning a key stroke to a single Action and using key bindings. I believe you are doing the former (action.putValue(Action.ACCELERATOR_KEY, keystroke)), and that only allows one key stroke per Action.
 
 
subject: Ctrl+X,Ctrl+C,Ctrl+V not working!
 
Similar Threads
pet peeves (computer related)
cut and paste on solaris
Cut, copy, paste in unsigned apple
Short-cut key issue in SWT (Ctrl+C and Ctrl+v)
WA #1.....word association