Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Copy n Paste in swing  (Read 946 times)
0 Members and 1 Guest are viewing this topic.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Posted 2004-05-27 09:41:13 »

Um, how do you do this ...using Actions?

It's one of those many evil parts of AWT/swing design where it's like learning French - the most frequently-used stuff to seems to be the most deviating from all the rules Sad.

What I do know is this:

- Actions which register themselves as using CTRL + C or V as their ACCELERATOR_KEY get silently ignored. But if you use any other CTRL combination, it works as a global shortcut.
- I can't see anything in the Action docs as to why this happens (or even any indication that it happens). In fact, the AbstractAction docs even use "Cut" as an example (haven't checked, but I'm guessing Ctrl-X does nothing too?)
- ...but I also can't see what the difference is between ACCELERATOR_KEY and ACTION_COMMAND_KEY.
- ...except that *if* you attempt to put a value of Ctrl-C for ACTION_COMMAND_KEY, you crash swing's AbstractAction class. It dies with an internal ClassCastException. Great!

malloc will be first against the wall when the revolution comes...
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #1 - Posted 2004-05-27 11:33:17 »

There's also TextAction:
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/text/TextAction.html

Oh and there is also a little demo with copy/past/cut
<sdk>/demo/jfc/Notepad

弾幕 ☆ @mahonnaiseblog
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #2 - Posted 2004-05-27 12:46:57 »

Sorry, I should have been clearer...

I want to do copy/paste that *involves no text whatsover at all*.

Smiley.

e.g. copy/pasting objects and things. So, no text components are involved, and in fact all the components are custom subclasses of JPanel (or similar).

Which makes it all the more annoying that CTRL-C simply doesn't work - assuming this is a design choice and not a bug (despite the lack of docs) - that it seems to be in order to support some text handling that is totally irrelevant! Sad

malloc will be first against the wall when the revolution comes...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #3 - Posted 2004-05-27 13:05:43 »

Hmhmhmhmhm...

Maybe KeyMap helps then?

"Keymap
Defines the Actions performed when certain keys are pressed. For example, pressing CTRL-C may copy some text and CTRL-V may paste the cut or copied text and the current cursor location. This is considered a look-and-feel feature because different native look-and-feels have different default keymaps."

Hmyea... default keymaps are to blame, I guess Smiley

弾幕 ☆ @mahonnaiseblog
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #4 - Posted 2004-05-27 14:22:13 »

Quote
Hmhmhmhmhm...

Maybe KeyMap helps then?


Maybe. I've tried manually altering the KeyMap's before for stuff like this, but it *always* seems to break Swing.

In particular, I tend to have a heck of a hard time trying to remove the seemingly random places and situations where Sun's Swing components insert their own bindings - and I've not managed to find a clear simple list of what's doing what where Sad.

...is this stuff perhaps stored authoritatively in e.g. the Look-n-feel descriptors? But then I run into the problem that Sun still hasn't documented LaF API's etc, so I don't know what I'm looking at or where to look for it (the "where" being easier to workaround - I've found LaF data before, but never found any docs).

Any advice on altering keymaps?

NB: just inserting a new default keymap at the root of the keymap chain is something I found relatively easy before.

HOWEVER IIRC even this breaks Swing! There seem to be swing components that rely upon the fact that some things are not in the KeyMap and then handle them specially when they aren't found. Or something like that. I posted in Newbies because I've never quite got my head around this stuff (partly because it keeps changing from  release to release Tongue ?) and am probably misunderstanding a lot of it Sad.

malloc will be first against the wall when the revolution comes...
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (25 views)
2014-09-12 09:08:26

Norakomi (56 views)
2014-09-10 13:57:51

TehJavaDev (69 views)
2014-09-10 06:39:09

Tekkerue (35 views)
2014-09-09 02:24:56

mitcheeb (56 views)
2014-09-08 06:06:29

BurntPizza (40 views)
2014-09-07 01:13:42

Longarmx (26 views)
2014-09-07 01:12:14

Longarmx (33 views)
2014-09-07 01:11:22

Longarmx (31 views)
2014-09-07 01:10:19

mitcheeb (39 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!