Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
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 1124 times)
0 Members and 1 Guest are viewing this topic.
Offline blahblahblahh

JGO Coder

Medals: 1

« 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:

Oh and there is also a little demo with copy/past/cut

弾幕 ☆ @mahonnaiseblog
Offline blahblahblahh

JGO Coder

Medals: 1

« 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*.


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 »


Maybe KeyMap helps then?

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

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


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. 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.

Jesse (12 views)
2015-07-29 04:35:27

Riven (35 views)
2015-07-27 16:38:00

Riven (18 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (11 views)
2015-07-27 12:23:39

BurntPizza (30 views)
2015-07-25 00:14:37

BurntPizza (41 views)
2015-07-24 22:06:39

BurntPizza (24 views)
2015-07-24 06:06:53

NoxInc (27 views)
2015-07-22 22:16:53

NoxInc (18 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!