本文整理匯總了Java中javax.swing.AbstractButton.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java AbstractButton.getText方法的具體用法?Java AbstractButton.getText怎麽用?Java AbstractButton.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.AbstractButton
的用法示例。
在下文中一共展示了AbstractButton.getText方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getText
import javax.swing.AbstractButton; //導入方法依賴的package包/類
public static String getText(String original, Component current, Component[] components) {
String itemText = original;
int suffixIndex = 0;
for (int i = 0; i < components.length; i++) {
if (components[i] == current) {
return itemText;
}
if (!(components[i] instanceof AbstractButton)) {
continue;
}
AbstractButton menuItem = (AbstractButton) components[i];
String menuItemText = menuItem.getText();
if ("".equals(menuItemText) || menuItemText == null) {
menuItemText = getTextFromIcon((JMenuItem) components[i]);
}
if (menuItemText.equals(original)) {
itemText = String.format("%s(%d)", original, ++suffixIndex);
}
}
return itemText;
}
示例2: addMnemonicsToButtons
import javax.swing.AbstractButton; //導入方法依賴的package包/類
/**
* dodanie mneomonikow do przyciskow
*
* @param parentComponent - komponent
* @param text - nazwy przyciskow
* @param mnemonic - mnemoniki dla przyciskow
*/
private static void addMnemonicsToButtons(Component parentComponent, String[] text, int[] mnemonic) {
Collection<Component> components = getAllSubComponents(parentComponent);
for (Component child : components) {
if (child instanceof AbstractButton) {
AbstractButton b = (AbstractButton) child;
String btnText = b.getText();
if (btnText == null) {
btnText = "";
}
int textCount = text.length;
for (int j = 0; j < textCount; j++) {
if (btnText.equals(text[j])) {
b.setMnemonic(mnemonic[j]);
}
}
}
}
}
示例3: getSelectedButtonText
import javax.swing.AbstractButton; //導入方法依賴的package包/類
String getSelectedButtonText(ButtonGroup buttonGroup) {
for (Enumeration buttons = buttonGroup.getElements(); buttons.hasMoreElements();) {
AbstractButton button = (AbstractButton) buttons.nextElement();
if (button.isSelected()) {
return button.getText();
}
}
return null;
}
開發者ID:srilekhadasari,項目名稱:online-quiz-application-in-java-with-jdbc-using-swing-login-registration-timer,代碼行數:11,代碼來源:Questions.java
示例4: 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));
}
示例5: installButtonUI
import javax.swing.AbstractButton; //導入方法依賴的package包/類
@Override
public void installButtonUI(AbstractButton button) {
button.setUI(new ButtonUI());
button.setBorder(null);
button.setMargin(new Insets(0, 0, 0, 0));
if ((button.getText() == null || "".equals(button.getText())) && button.getIcon() != null) {
button.setPreferredSize(new Dimension((int) (button.getIcon().getIconWidth() * 1.45d), (int) (button.getIcon()
.getIconHeight() * 1.45d)));
}
}
示例6: getSelectedButtonText
import javax.swing.AbstractButton; //導入方法依賴的package包/類
/**
* Determines the label of the current selected button.
* @param buttonGroup
* @return The text label of the selected button.
*/
public static String getSelectedButtonText(ButtonGroup buttonGroup) {
for (Enumeration<AbstractButton> buttons = buttonGroup.getElements(); buttons.hasMoreElements();) {
AbstractButton button = buttons.nextElement();
if (button.isSelected()) {
return button.getText();
}
}
return null;
}
示例7: getSelectedButton
import javax.swing.AbstractButton; //導入方法依賴的package包/類
private String getSelectedButton(ButtonGroup bGroup) {
for (Enumeration<AbstractButton> buttons = bGroup.getElements(); buttons.hasMoreElements();) {
AbstractButton button = buttons.nextElement();
if (button.isSelected()) {
return button.getText();
}
}
return "None";
}
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:10,代碼來源:CognizantITSSettings.java
示例8: getSelected
import javax.swing.AbstractButton; //導入方法依賴的package包/類
public String getSelected()
{
ButtonModel m = getSelection();
for (AbstractButton b : buttons)
{
if (b.getModel() == m)
{
return b.getText();
}
}
return null;
}
示例9: paint
import javax.swing.AbstractButton; //導入方法依賴的package包/類
@Override
public synchronized void paint(Graphics g, JComponent c)
{
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
Dimension d = b.getSize();
g.setFont(c.getFont());
FontMetrics fm = g.getFontMetrics();
Icon icon = mIconUnchecked;
if( model.isPressed() && model.isSelected() )
{
icon = mIconPressedChecked;
}
else if( model.isPressed() && !model.isSelected() )
{
icon = mIconPressedUnchecked;
}
else if( !model.isPressed() && model.isSelected() )
{
icon = mIconChecked;
}
int x = 0;
int y = (d.height - icon.getIconHeight()) / 2;
icon.paintIcon(c, g, x, y);
if( b.isEnabled() )
{
g.setColor(mTextNormal);
}
else
{
g.setColor(mTextDisabled);
}
String caption = b.getText();
x = icon.getIconWidth() + mTextIconGap;
y = (d.height + fm.getAscent()) / 2;
g.drawString(caption, x, y);
}