-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Introduce MnemonicsAction interface - Give Action with mnemonics processing Signed-off-by: Hiroshi Miura <[email protected]>
- Loading branch information
Showing
4 changed files
with
98 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.openide.awt; | ||
|
||
import javax.swing.*; | ||
import java.util.Locale; | ||
|
||
public abstract class AbstractMnemonicsAction extends AbstractAction implements MnemonicsAction { | ||
public AbstractMnemonicsAction(String text, Locale locale) { | ||
super(); | ||
setText(text, locale); | ||
} | ||
|
||
public void setText(String text, Locale locale) { | ||
int i = Mnemonics.findMnemonicAmpersand(text); | ||
if (i < 0) { | ||
putValue(Action.NAME, text); | ||
putValue(Action.DISPLAYED_MNEMONIC_INDEX_KEY, -1); | ||
} else { | ||
putValue(Action.NAME, text.substring(0, i) + text.substring(i + 1)); | ||
Mnemonics.setMnemonicAndIndex(this, text.charAt(i + 1), i, locale); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.openide.awt; | ||
|
||
import javax.swing.Action; | ||
import java.util.Locale; | ||
|
||
public interface MnemonicsAction extends Action { | ||
/** | ||
* Set NAME attribute with mnemonics processing. | ||
* When given "&Text" then it set NAME attribute as | ||
* "Text" and put mnemonics for "T". | ||
* @param text Label text. | ||
* @param locale locale of the text. | ||
*/ | ||
void setText(String text, Locale locale); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters