HELP NEEDED........PLZ

I know how to set accelerator for a JMenuItem but how can I set accelerator with bothControl button and[Shift button.

I mean

SaveAs...Ctrl+Shift+S

how can I set accelerator like this?

[246 byte] By [student@sunDNa] at [2007-11-27 11:10:41]
# 1

1) Your subject line is uninformative (minus 2 points)

2) Your subject line is ALL IN CAPS (minus 10 points)

3) Your subject line contains "........" (minus 7 points)

4) You subject line contains PLZ (minus 5 points)

5) This is a Swing question incorrectly posted into a forum other then the Swing forum (minus 10 points)

So I give this post a score of negative 34 plus 5 dukes gives us a balance of negative 29.

So you fail.

cotton.ma at 2007-7-29 13:43:24 > top of Java-index,Java Essentials,Java Programming...
# 2

cotton.m thanks for reply.

Somebody please help me.

I don't know how to do this!

student@sunDNa at 2007-7-29 13:43:24 > top of Java-index,Java Essentials,Java Programming...
# 3

Add the modifiers together.

masijade.a at 2007-7-29 13:43:24 > top of Java-index,Java Essentials,Java Programming...
# 4

how to that?

I mean I tried

saveFileAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,KeyEvent.CTRL_MASK && KeyEvent.SHIFT_MASK));

but this dose not work.

student@sunDNa at 2007-7-29 13:43:24 > top of Java-index,Java Essentials,Java Programming...
# 5

From the API for KeyStroke

getKeyStroke

public static KeyStroke getKeyStroke(Character keyChar,

int modifiers)

Returns a shared instance of a KeyStroke, given a Character object and a set of modifiers. Note that the first parameter is of type Character rather than char. This is to avoid inadvertent clashes with calls to getKeyStroke(int keyCode, int modifiers). The modifiers consist of any combination of:

java.awt.event.InputEvent.SHIFT_MASK (1)

java.awt.event.InputEvent.CTRL_MASK (2)

java.awt.event.InputEvent.META_MASK (4)

java.awt.event.InputEvent.ALT_MASK (8)

Since these numbers are all different powers of two, any combination of them is an integer in which each bit represents a different modifier key. Use 0 to specify no modifiers.

Parameters:

keyChar - the Character object for a keyboard character

modifiers - a bitwise-ored combination of any modifiers

Returns:

an KeyStroke object for that key

Throws:

IllegalArgumentException - if keyChar is null

Since:

1.3

See Also:

InputEvent

masijade.a at 2007-7-29 13:43:24 > top of Java-index,Java Essentials,Java Programming...
# 6

something like this?:

yourJMenuItem.setAccelerator(KeyStroke.getKeyStroke(VK_S, SHIFT_DOWN_MASK | CTRL_DOWN_MASK));

Message was edited by:

petes1234

petes1234a at 2007-7-29 13:43:24 > top of Java-index,Java Essentials,Java Programming...
# 7

KeyStroke.getKeyStroke(KeyEvent.VK_S,ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)

Message was edited by:

Yannix

Yannixa at 2007-7-29 13:43:24 > top of Java-index,Java Essentials,Java Programming...
# 8

Thanks masijade.

Thanks a lot.

and thanks Yannix.

Message was edited by:

student@sunDN

student@sunDNa at 2007-7-29 13:43:24 > top of Java-index,Java Essentials,Java Programming...