本文整理了Java中javax.swing.JLabel.setDisplayedMnemonicIndex()
方法的一些代码示例,展示了JLabel.setDisplayedMnemonicIndex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.setDisplayedMnemonicIndex()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:setDisplayedMnemonicIndex
暂无
代码示例来源:origin: org.netbeans.api/org-openide-awt
/**
* Wrapper for the
* <code>AbstractButton.setMnemonicIndex</code> or
* <code>JLabel.setDisplayedMnemonicIndex</code> method.
* @param item AbstractButton/JLabel or subclasses
* @param index Index of the Character to underline under JDK1.4
* @param latinCode Latin Character Keycode to underline under JDK1.3
*/
private static void setMnemonicIndex(Object item, int index) {
if (item instanceof AbstractButton) {
AbstractButton b = (AbstractButton) item;
b.putClientProperty(PROP_DISPLAYED_MNEMONIC_INDEX, index);
b.removePropertyChangeListener(PROP_DISPLAYED_MNEMONIC_INDEX, MNEMONIC_INDEX_LISTENER);
b.setDisplayedMnemonicIndex(index);
b.addPropertyChangeListener(PROP_DISPLAYED_MNEMONIC_INDEX, MNEMONIC_INDEX_LISTENER);
} else if (item instanceof JLabel) {
((JLabel) item).setDisplayedMnemonicIndex(index);
}
}
private static final String PROP_TEXT = "text"; // NOI18N
代码示例来源:origin: net.sf.doolin/doolin-gui
/**
* Configures a label with this mnemonic information
*
* @param label
* Label to configure
* @see JLabel#setText(String)
* @see JLabel#setDisplayedMnemonicIndex(int)
*/
public void configureLabel(JLabel label) {
label.setText(this.text);
if (this.mnemonic != 0 && this.mnemonicIndex >= 0) {
label.setDisplayedMnemonicIndex(this.mnemonicIndex);
}
}
代码示例来源:origin: robo-code/robocode
public JLabel getFindLabel() {
if (findLabel == null) {
findLabel = new JLabel();
findLabel.setText("Find:");
findLabel.setDisplayedMnemonicIndex(3);
}
return findLabel;
}
代码示例来源:origin: robo-code/robocode
public JLabel getReplaceLabel() {
if (replaceLabel == null) {
replaceLabel = new JLabel();
replaceLabel.setText("Replace:");
replaceLabel.setDisplayedMnemonicIndex(3);
}
return replaceLabel;
}
代码示例来源:origin: net.java.dev.appframework/appframework
private static void configureLabel(JLabel target, String text, int key, int index) {
target.setText(text);
if (key != KeyEvent.VK_UNDEFINED) { target.setDisplayedMnemonic(key); }
if (index != -1) { target.setDisplayedMnemonicIndex(index); }
}
}
代码示例来源:origin: com.jgoodies/jgoodies-common
private static void configure0(JLabel label, MnemonicText mnemonicText) {
label.setText(mnemonicText.text);
label.setDisplayedMnemonic(mnemonicText.key);
label.setDisplayedMnemonicIndex(mnemonicText.index);
}
代码示例来源:origin: org.jdesktop.bsaf/bsaf
private static void configureLabel(JLabel target, String text, int key, int index) {
target.setText(text);
if (key != KeyEvent.VK_UNDEFINED) {
target.setDisplayedMnemonic(key);
}
if (index != -1) {
target.setDisplayedMnemonicIndex(index);
}
}
}
代码示例来源:origin: xyz.cofe/gui.swing
@Override
public void setTabDisplayedMnemonicIndex(int mnemonicIndex) {
if (isClosed())
return;
titleLabel.setDisplayedMnemonicIndex(mnemonicIndex);
}
代码示例来源:origin: com.anrisoftware.prefdialog/prefdialog-core
@Override
public void setMnemonicIndex(int index) {
super.setMnemonicIndex(index);
if (titleLabel.getText() != null) {
titleLabel.setDisplayedMnemonicIndex(index);
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/**
* Wrapper for the
* <code>AbstractButton.setMnemonicIndex</code> or
* <code>JLabel.setDisplayedMnemonicIndex</code> method.
* <li>Under JDK1.4 calls the method on item
* <li>Under JDK1.3 adds " (<latin character>)" (if needed)
* to label and sets the latin character as mnemonics.
* @param item AbstractButton/JLabel or subclasses
* @param index Index of the Character to underline under JDK1.4
* @param latinCode Latin Character Keycode to underline under JDK1.3
*/
private static void setMnemonicIndex (Object item, int index) {
if (item instanceof AbstractButton) {
((AbstractButton)item).setDisplayedMnemonicIndex(index);
} else if (item instanceof JLabel) {
((JLabel)item).setDisplayedMnemonicIndex(index);
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/**
* Wrapper for the
* <code>AbstractButton.setMnemonicIndex</code> or
* <code>JLabel.setDisplayedMnemonicIndex</code> method.
* <li>Under JDK1.4 calls the method on item
* <li>Under JDK1.3 adds " (<latin character>)" (if needed)
* to label and sets the latin character as mnemonics.
* @param item AbstractButton/JLabel or subclasses
* @param index Index of the Character to underline under JDK1.4
* @param latinCode Latin Character Keycode to underline under JDK1.3
*/
private static void setMnemonicIndex (Object item, int index) {
if (item instanceof AbstractButton) {
((AbstractButton)item).setDisplayedMnemonicIndex(index);
} else if (item instanceof JLabel) {
((JLabel)item).setDisplayedMnemonicIndex(index);
}
}
代码示例来源:origin: groboclown/p4ic4idea
public static void loadLabelText(JLabel component, String text) {
StringBuilder result = new StringBuilder();
boolean haveMnemonic = false;
char mnemonic = '\0';
int mnemonicIndex = -1;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '&') {
i++;
if (i == text.length()) {
break;
}
if (!haveMnemonic && text.charAt(i) != '&') {
haveMnemonic = true;
mnemonic = text.charAt(i);
mnemonicIndex = result.length();
}
}
result.append(text.charAt(i));
}
component.setText(result.toString());
if (haveMnemonic) {
component.setDisplayedMnemonic(mnemonic);
component.setDisplayedMnemonicIndex(mnemonicIndex);
}
}
代码示例来源:origin: cpesch/RouteConverter
/**
* @noinspection ALL
*/
private void $$$loadLabelText$$$(JLabel component, String text) {
StringBuffer result = new StringBuffer();
boolean haveMnemonic = false;
char mnemonic = '\0';
int mnemonicIndex = -1;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '&') {
i++;
if (i == text.length()) break;
if (!haveMnemonic && text.charAt(i) != '&') {
haveMnemonic = true;
mnemonic = text.charAt(i);
mnemonicIndex = result.length();
}
}
result.append(text.charAt(i));
}
component.setText(result.toString());
if (haveMnemonic) {
component.setDisplayedMnemonic(mnemonic);
component.setDisplayedMnemonicIndex(mnemonicIndex);
}
}
代码示例来源:origin: cpesch/RouteConverter
/**
* @noinspection ALL
*/
private void $$$loadLabelText$$$(JLabel component, String text) {
StringBuffer result = new StringBuffer();
boolean haveMnemonic = false;
char mnemonic = '\0';
int mnemonicIndex = -1;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '&') {
i++;
if (i == text.length()) break;
if (!haveMnemonic && text.charAt(i) != '&') {
haveMnemonic = true;
mnemonic = text.charAt(i);
mnemonicIndex = result.length();
}
}
result.append(text.charAt(i));
}
component.setText(result.toString());
if (haveMnemonic) {
component.setDisplayedMnemonic(mnemonic);
component.setDisplayedMnemonicIndex(mnemonicIndex);
}
}
代码示例来源:origin: cpesch/RouteConverter
/**
* @noinspection ALL
*/
private void $$$loadLabelText$$$(JLabel component, String text) {
StringBuffer result = new StringBuffer();
boolean haveMnemonic = false;
char mnemonic = '\0';
int mnemonicIndex = -1;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '&') {
i++;
if (i == text.length()) break;
if (!haveMnemonic && text.charAt(i) != '&') {
haveMnemonic = true;
mnemonic = text.charAt(i);
mnemonicIndex = result.length();
}
}
result.append(text.charAt(i));
}
component.setText(result.toString());
if (haveMnemonic) {
component.setDisplayedMnemonic(mnemonic);
component.setDisplayedMnemonicIndex(mnemonicIndex);
}
}
代码示例来源:origin: groboclown/p4ic4idea
/**
* @noinspection ALL
*/
private void $$$loadLabelText$$$(JLabel component, String text) {
StringBuffer result = new StringBuffer();
boolean haveMnemonic = false;
char mnemonic = '\0';
int mnemonicIndex = -1;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '&') {
i++;
if (i == text.length()) {
break;
}
if (!haveMnemonic && text.charAt(i) != '&') {
haveMnemonic = true;
mnemonic = text.charAt(i);
mnemonicIndex = result.length();
}
}
result.append(text.charAt(i));
}
component.setText(result.toString());
if (haveMnemonic) {
component.setDisplayedMnemonic(mnemonic);
component.setDisplayedMnemonicIndex(mnemonicIndex);
}
}
代码示例来源:origin: cpesch/RouteConverter
/**
* @noinspection ALL
*/
private void $$$loadLabelText$$$(JLabel component, String text) {
StringBuffer result = new StringBuffer();
boolean haveMnemonic = false;
char mnemonic = '\0';
int mnemonicIndex = -1;
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '&') {
i++;
if (i == text.length()) break;
if (!haveMnemonic && text.charAt(i) != '&') {
haveMnemonic = true;
mnemonic = text.charAt(i);
mnemonicIndex = result.length();
}
}
result.append(text.charAt(i));
}
component.setText(result.toString());
if (haveMnemonic) {
component.setDisplayedMnemonic(mnemonic);
component.setDisplayedMnemonicIndex(mnemonicIndex);
}
}
代码示例来源:origin: com.github.waikato/fcms-widgets
/**
* Sets the text for the prefix label. Mnemonics can be indicated by a
* preceding underscore "_".
*
* @param value the text to display
* @see GUIHelper#MNEMONIC_INDICATOR
*/
public void setPrefix(String value) {
char mnemonic;
String caption;
mnemonic = GUIHelper.getMnemonic(value);
caption = GUIHelper.stripMnemonic(value);
m_LabelPrefix.setText(caption);
if (mnemonic != '\0')
m_LabelPrefix.setDisplayedMnemonic(mnemonic);
else
m_LabelPrefix.setDisplayedMnemonicIndex(-1);
if (value.length() > 0)
m_LabelPrefixSpacer.setText(" ");
else
m_LabelPrefixSpacer.setText("");
}
代码示例来源:origin: com.anrisoftware.prefdialog/prefdialog-core
private void updateMnemonic() {
Integer mnemonic = getMnemonic();
if (mnemonic != null) {
titleLabel.setDisplayedMnemonic(mnemonic);
}
int index = getMnemonicIndex();
if (index != -1) {
titleLabel.setDisplayedMnemonicIndex(index);
}
}
代码示例来源:origin: org.jclarion/clarion-runtime
private void configurePrompt()
{
JLabel label=this.label;
if (label==null) return;
MnemonicDecoder dec = new MnemonicDecoder(getProperty(Prop.TEXT)
.toString().trim());
label.setText(dec.getString());
if (dec.getMnemonicPos() >= 0) {
label.setDisplayedMnemonicIndex(dec.getMnemonicPos());
getWindowOwner().getMnemonic(true).addMnemonic(this,
dec.getMnemonicChar(), MnemonicConfig.Mode.SELECTONLY, 1);
}
}
内容来源于网络,如有侵权,请联系作者删除!