javax.swing.JButton#isEnabled ( )源码实例Demo

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

源代码1 项目: netbeans   文件: TubesProjectConfigPanel.java
public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {

        JButton upBtn = client ? upBtnClient : upBtnService;
        int selectedRow = getSelectedRow(client);
        if (selectedRow == 0) {
            upBtn.setEnabled(false);
        } else {
            if (!upBtn.isEnabled()) {
                upBtn.setEnabled(true);
            }
        }

        TubeTableModel tModel = client ? tubeTableClientModel : tubeTableServiceModel;
        JButton downBtn = client ? downBtnClient : downBtnService;
        if (selectedRow == tModel.getRowCount() - 1) {
            downBtn.setEnabled(false);
        } else {
            if (!downBtn.isEnabled()) {
                downBtn.setEnabled(true);
            }
        }
    }
}
 
源代码2 项目: IBC   文件: SwingUtils.java
/**
 * Performs a click on the button labelled with the specified text.
 * @param window
 *  The window containing the button.
 * @param buttonText
 *  The button's label.
 * @return
 *  true if the button was found;  false if the button was not found
 */
static boolean clickButton(final Window window, final String buttonText) {
    final JButton button = findButton(window, buttonText);
    if (button == null) return false;

    if (! button.isEnabled()) {
        button.setEnabled(true);
        Utils.logToConsole("Button was disabled, has been enabled: " + buttonText);
    }

    Utils.logToConsole("Click button: " + buttonText);
    button.doClick();
    if (! button.isEnabled()) Utils.logToConsole("Button now disabled: " + buttonText);
    return true;
}
 
源代码3 项目: netbeans   文件: EditablePropertyDisplayer.java
private void trySendEnterToDialog() {
    //        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();

    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER)) {
        if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
            return;
        }

        if (
            ev.getSource() instanceof JTextComponent &&
                ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
                ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
        ) {
            return;
        }

        JRootPane jrp = getRootPane();

        if (jrp != null) {
            JButton b = jrp.getDefaultButton();

            if ((b != null) && b.isEnabled()) {
                b.doClick();
            }
        }
    }
}
 
源代码4 项目: netbeans   文件: BaseTable.java
private void trySendEnterToDialog(BaseTable bt) {
    //        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();

    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER)) {
        if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
            return;
        }

        if (
            ev.getSource() instanceof JTextComponent &&
                ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
                ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
        ) {
            return;
        }

        JRootPane jrp = bt.getRootPane();

        if (jrp != null) {
            JButton b = jrp.getDefaultButton();

            if ((b != null) && b.isEnabled()) {
                b.doClick();
            }
        }
    }
}
 
源代码5 项目: netbeans   文件: ETable.java
@Override
public void actionPerformed(ActionEvent e) {
    JRootPane jrp = getRootPane();
    if (jrp != null) {
        JButton b = getRootPane().getDefaultButton();
        if (b != null && b.isEnabled()) {
            b.doClick();
        }
    }
}
 
源代码6 项目: jeveassets   文件: JSimpleColorPicker.java
private Border getBorderInner(JButton jButton) {
	if (jButton.isEnabled()) {
		return BorderFactory.createLineBorder(Color.BLACK, 1);
	} else {
		return BorderFactory.createLineBorder(Color.DARK_GRAY, 1);
	}
}
 
源代码7 项目: ib-controller   文件: SwingUtils.java
/**
 * Performs a click on the button labelled with the specified text.
 * @param window
 *  The window containing the button.
 * @param buttonText
 *  The button's label.
 * @return
 *  true if the button was found;  false if the button was not found
 */
static boolean clickButton(final Window window, final String buttonText) {
    final JButton button = findButton(window, buttonText);
    if (button == null) return false;

    if (! button.isEnabled()) {
        button.setEnabled(true);
        Utils.logToConsole("Button was disabled, has been enabled: " + buttonText);
    }

    Utils.logToConsole("Click button: " + buttonText);
    button.doClick();
    if (! button.isEnabled()) Utils.logToConsole("Button now disabled: " + buttonText);
    return true;
}
 
/**
 * Creates a {@link JFormattedTextField} for the specified cell. If a formatter is given, will
 * apply it to the field. Does not validate the model, so make sure this call works!
 * 
 * @param model
 * @param rowIndex
 * @param columnIndex
 * @param cellClass
 * @param formatter
 *            the formatter or <code>null</code> if none is required
 * @param hideUnavailableContentAssist
 * @return
 */
public CellTypeTextFieldDefaultImpl(final TablePanelModel model, final int rowIndex, final int columnIndex,
		final Class<? extends CellType> cellClass, AbstractFormatter formatter, boolean hideUnavailableContentAssist) {
	super();

	final JFormattedTextField field = CellTypeImplHelper.createFormattedTextField(model, rowIndex, columnIndex);
	setLayout(new BorderLayout());
	add(field, BorderLayout.CENTER);

	// otherwise 'null' would be restored
	Object value = model.getValueAt(rowIndex, columnIndex);
	String text = value != null ? String.valueOf(value) : "";

	// specical handling when formatter is given
	if (formatter != null) {
		field.setFormatterFactory(new DefaultFormatterFactory(formatter));
	}
	field.setText(text);

	// set syntax assist if available
	String syntaxHelp = model.getSyntaxHelpAt(rowIndex, columnIndex);
	if (syntaxHelp != null && !"".equals(syntaxHelp.trim())) {
		SwingTools.setPrompt(syntaxHelp, field);
	}

	// see if content assist is possible for this field, if so add it
	ImageIcon icon = SwingTools.createIcon("16/"
			+ I18N.getMessageOrNull(I18N.getGUIBundle(), "gui.action.content_assist.icon"));
	JButton contentAssistButton = new JButton();
	contentAssistButton.setIcon(icon);
	if (field.isEnabled() && model.isContentAssistPossibleForCell(rowIndex, columnIndex)) {
		contentAssistButton.setToolTipText(I18N.getMessageOrNull(I18N.getGUIBundle(),
				"gui.action.content_assist_enabled.tip"));
		CellTypeImplHelper.addContentAssist(model, rowIndex, columnIndex, field, contentAssistButton, cellClass);
	} else {
		contentAssistButton.setToolTipText(I18N.getMessageOrNull(I18N.getGUIBundle(),
				"gui.action.content_assist_disabled.tip"));
		contentAssistButton.setEnabled(false);
	}
	if (contentAssistButton.isEnabled() || (!contentAssistButton.isEnabled() && !hideUnavailableContentAssist)) {
		add(contentAssistButton, BorderLayout.EAST);
	}

	// set size so panels don't grow larger when they get the chance
	setPreferredSize(new Dimension(300, 20));
	setMinimumSize(new Dimension(100, 15));
	setMaximumSize(new Dimension(1600, 30));
}
 
源代码9 项目: IBC   文件: SwingUtils.java
/**
 * Indicates whether the specified JButton is enabled.
 * @param window
 * the window in which to search for the required JButton
 * @param buttonText
 * the label of the required JButton
 * @return
 * true if the JButton is enabled; false if there is no such JButton, or it
 * is disabled
 */
static boolean isButtonEnabled(final Window window, final String buttonText) {
    final JButton button = findButton(window, buttonText);
    if (button == null) return false;

    return button.isEnabled();
}
 
源代码10 项目: ib-controller   文件: SwingUtils.java
/**
 * Indicates whether the specified JButton is enabled.
 * @param window
 * the window in which to search for the required JButton
 * @param buttonText
 * the label of the required JButton
 * @return
 * true if the JButton is enabled; false if there is no such JButton, or it
 * is disabled
 */
static boolean isButtonEnabled(final Window window, final String buttonText) {
    final JButton button = findButton(window, buttonText);
    if (button == null) return false;

    return button.isEnabled();
}