当前位置: 首页>>代码示例>>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;未经允许,请勿转载。