當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractButton.getText方法代碼示例

本文整理匯總了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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:22,代碼來源:JMenuItemJavaElement.java

示例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]);
                }
            }
        }
    }
}
 
開發者ID:CLARIN-PL,項目名稱:WordnetLoom,代碼行數:26,代碼來源:DialogBox.java

示例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));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:UI.java

示例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)));
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:11,代碼來源:RapidDockingToolbar.java

示例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;
}
 
開發者ID:LEB-EPFL,項目名稱:SASS,代碼行數:17,代碼來源:ButtonGroupUtils.java

示例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;
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:13,代碼來源:TimeEntry.java

示例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);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:43,代碼來源:FlatterCheckBoxUI.java


注:本文中的javax.swing.AbstractButton.getText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。