Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sun solaris , copy keyboard button

 
khaja mohideen
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

In ay java application , where i want to copy a text , with "Copy" special button in sun solariskeyboard , it does not work

but ctrl+c is working , any ideas ?

I use JTextArea in my application

Regards
kmm
 
khaja mohideen
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

is there a way to map the keys in java i..e

if the user presses "Copy" button in sun keyboard , is it possible to translate it to "Ctrl+c" within java application

i know i can create a key listener , but after i get the Copy key , how do i map to "Ctrl+c"

or may be i can say

JTextArea area;
area.getselectedtext

and then where should i put this text in order for this text to be available for writing into say for ex. texteditor ?

regards
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We first need to know what key code that button is:
Once you know that you can use it in a key stroke; check how key binding works in Java.

As for the actual copying, JTextArea inherits method copy() from JTextComponent. All you need to do is call that.
 
khaja mohideen
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

thankyou for your reply

KeyStroke ksF12 = KeyStroke.getKeyStroke("F12");
displayArea.getInputMap().put(ksF12, "copy");

KeyStroke ksF11 = KeyStroke.getKeyStroke("F11");
displayArea.getInputMap().put(ksF11, "paste");

the code above works for windows
what is the equivalent of "copy" , "paste" in Sun Solaris , how can i find it ?

although for Sun Solaris , i found the following with xev
keycode 131 = F16 F16 SunCopy
keycode 132 = F18 F18 SunPaste

Regards
 
khaja mohideen
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:We first need to know what key code that button is:
Once you know that you can use it in a key stroke; check how key binding works in Java.

As for the actual copying, JTextArea inherits method copy() from JTextComponent. All you need to do is call that.


JTextArea --> copy() , does not work in Solaris !!!
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
khaja , please BeForthrightWhenCrossPostingToOtherSites

https://forums.oracle.com/forums/thread.jspa?threadID=2288717
 
Rob Camick
Ranch Hand
Posts: 2564
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there a way to map the keys in java i..e if the user presses "Copy" button in sun keyboard , is it possible to translate it to "Ctrl+c" within java application


Swing uses Key Bindings to map KeyStrokes to an Action. You can map any KeyStroke to any existing Action.

See Key Bindings for a list of all the bindings for a given component and an example of how to share an Action with a different binding.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
khaja mohideen wrote:JTextArea --> copy() , does not work in Solaris !!!

Does Solaris have an actual system clipboard? If the system clipboard is not available, usually an IllegalStateException is thrown when retrieving the clipboard. However, the implementation behind the copy() method catches that IllegalStateException, then calls UIManager.getLookAndFeel().provideErrorFeedback(c). If that call does nothing, then indeed nothing will happen at all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic