javax.swing.AbstractButton#getText ( )源码实例Demo

下面列出了javax.swing.AbstractButton#getText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: marathonv5   文件: JMenuItemJavaElement.java
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 项目: netbeans   文件: UI.java
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));
}
 
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";
}
 
源代码4 项目: rapidminer-studio   文件: RapidDockingToolbar.java
@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)));
	}
}
 
源代码5 项目: JavaMainRepo   文件: AddFrame.java
public String getSelectedRadioButton() {
	for (Enumeration<AbstractButton> allButtons = buttonGroup.getElements(); allButtons.hasMoreElements();) {
		AbstractButton button = allButtons.nextElement();
		if (button.isSelected()) {
			return button.getText();
		}
	}
	return null;
}
 
源代码6 项目: JavaMainRepo   文件: AddFrame.java
public String getSelectedRadioButton() {
	for (Enumeration<AbstractButton> allButtons = buttonGroup.getElements(); allButtons.hasMoreElements();) {
		AbstractButton button = allButtons.nextElement();
		if (button.isSelected()) {
			return button.getText();
		}
	}
	return null;
}
 
源代码7 项目: snap-desktop   文件: TimeSeriesExportHelper.java
private static int parseLevel(ButtonGroup buttonGroup) {
    Enumeration<AbstractButton> buttonEnumeration = buttonGroup.getElements();
    while (buttonEnumeration.hasMoreElements()) {
        AbstractButton abstractButton = buttonEnumeration.nextElement();
        if (abstractButton.isSelected()) {
            String buttonText = abstractButton.getText();
            final int index = buttonText.indexOf(" (");
            if (index != -1) {
                buttonText = buttonText.substring(0, index);
            }
            return Integer.parseInt(buttonText);
        }
    }
    return-1;
}
 
源代码8 项目: seaglass   文件: SeaGlassButtonUI.java
/**
 * @see javax.swing.plaf.basic.BasicButtonUI#getBaseline(javax.swing.JComponent,
 *      int, int)
 */
public int getBaseline(JComponent c, int width, int height) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }

    if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Width and height must be >= 0");
    }

    AbstractButton b    = (AbstractButton) c;
    String         text = b.getText();

    if (text == null || "".equals(text)) {
        return -1;
    }

    Insets    i        = b.getInsets();
    Rectangle viewRect = new Rectangle();
    Rectangle textRect = new Rectangle();
    Rectangle iconRect = new Rectangle();

    viewRect.x      = i.left;
    viewRect.y      = i.top;
    viewRect.width  = width - (i.right + viewRect.x);
    viewRect.height = height - (i.bottom + viewRect.y);

    // layout the text and icon
    SeaGlassContext context = getContext(b);
    FontMetrics     fm = context.getComponent().getFontMetrics(context.getStyle().getFont(context));

    context.getStyle().getGraphicsUtils(context).layoutText(context, fm, b.getText(), b.getIcon(), b.getHorizontalAlignment(),
                                                            b.getVerticalAlignment(), b.getHorizontalTextPosition(),
                                                            b.getVerticalTextPosition(), viewRect, iconRect, textRect,
                                                            b.getIconTextGap());
    View view     = (View) b.getClientProperty(BasicHTML.propertyKey);
    int  baseline;

    if (view != null) {
        baseline = BasicHTML.getHTMLBaseline(view, textRect.width, textRect.height);
        if (baseline >= 0) {
            baseline += textRect.y;
        }
    } else {
        baseline = textRect.y + fm.getAscent();
    }

    context.dispose();
    return baseline;
}