本文整理匯總了Java中javax.swing.AbstractButton.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java AbstractButton.setText方法的具體用法?Java AbstractButton.setText怎麽用?Java AbstractButton.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.AbstractButton
的用法示例。
在下文中一共展示了AbstractButton.setText方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mnemonicAndToolTip
import javax.swing.AbstractButton; //導入方法依賴的package包/類
private static void mnemonicAndToolTip(AbstractButton button, String toolTip) {
String text = button.getText();
if (text == null) {
Mnemonics.setLocalizedText(button, toolTip);
button.setText(null);
}
else {
Mnemonics.setLocalizedText(button, text);
button.setText(cutMnemonicAndAmpersand(text));
}
button.setToolTipText(cutMnemonicAndAmpersand(toolTip));
}
示例2: setLocalizedText
import javax.swing.AbstractButton; //導入方法依賴的package包/類
/**
* Actual setter of the text & mnemonics for the AbstractButton or
* their subclasses. We must copy necessary code from org.openide.awt.Mnemonics
* because org.openide.awt module is not available yet when this code is called.
* @param item AbstractButton
* @param text new label
*/
private static void setLocalizedText (AbstractButton button, String text) {
if (text == null) {
button.setText(null);
return;
}
int i = findMnemonicAmpersand(text);
if (i < 0) {
// no '&' - don't set the mnemonic
button.setText(text);
button.setMnemonic(0);
} else {
button.setText(text.substring(0, i) + text.substring(i + 1));
if (Utilities.isMac()) {
// there shall be no mnemonics on macosx.
//#55864
return;
}
char ch = text.charAt(i + 1);
// it's latin character or arabic digit,
// setting it as mnemonics
button.setMnemonic(ch);
// If it's something like "Save &As", we need to set another
// mnemonic index (at least under 1.4 or later)
// see #29676
button.setDisplayedMnemonicIndex(i);
}
}
示例3: updateButton
import javax.swing.AbstractButton; //導入方法依賴的package包/類
static final void updateButton(AbstractButton btnResume) {
if (isSuspended()) {
int pending = Integer.getInteger("org.netbeans.io.pending", 0); // NOI18N
btnResume.setText(Bundle.MSG_Resume(pending));
btnResume.setSelected(true);
} else {
btnResume.setText(null);
btnResume.setSelected(false);
}
}
示例4: setText
import javax.swing.AbstractButton; //導入方法依賴的package包/類
/**
* Wrapper for AbstractButton/JLabel.setText
* @param item AbstractButton/JLabel
* @param text the text to set
*/
private static void setText(Object item, String text) {
if (item instanceof AbstractButton) {
AbstractButton b = (AbstractButton) item;
b.putClientProperty(PROP_TEXT, text);
b.setText(text);
} else {
((JLabel) item).setText(text);
}
}
示例5: configureAbstractButton
import javax.swing.AbstractButton; //導入方法依賴的package包/類
private void configureAbstractButton(AbstractButton button, String resource) {
String title = resources.getString(resource);
int i = title.indexOf('&');
int mnemonic = 0;
if (i >= 0) {
mnemonic = title.charAt(i + 1);
title = title.substring(0, i) + title.substring(i + 1);
button.setText(title);
button.setMnemonic(Character.toUpperCase(mnemonic));
button.setDisplayedMnemonicIndex(i);
} else
button.setText(title);
}