• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

sun solaris , copy keyboard button

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !!!
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
khaja , please BeForthrightWhenCrossPostingToOtherSites

https://forums.oracle.com/forums/thread.jspa?threadID=2288717
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic