本文整理匯總了Java中javax.swing.JButton.isEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java JButton.isEnabled方法的具體用法?Java JButton.isEnabled怎麽用?Java JButton.isEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.isEnabled方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: trySendEnterToDialog
import javax.swing.JButton; //導入方法依賴的package包/類
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();
}
}
}
}
示例2: trySendEnterToDialog
import javax.swing.JButton; //導入方法依賴的package包/類
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();
}
}
}
}
示例3: actionPerformed
import javax.swing.JButton; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
JRootPane jrp = getRootPane();
if (jrp != null) {
JButton b = getRootPane().getDefaultButton();
if (b != null && b.isEnabled()) {
b.doClick();
}
}
}
示例4: actionPerformed
import javax.swing.JButton; //導入方法依賴的package包/類
/**
* Starts / stops the search. This code is called by the text field and
* search button.
*/
public void actionPerformed(final ActionEvent event) {
final JButton searchButton = (JButton) event.getSource();
if (!searchButton.isEnabled())
return;
if (searchButton.getLabel().equals("Stop")) {
searchWindow.stopSearch();
} else {
searchWindow.startSearch();
}
}
示例5: CellTypeTextFieldDefaultImpl
import javax.swing.JButton; //導入方法依賴的package包/類
/**
* 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())) {
PromptSupport.setForeground(Color.LIGHT_GRAY, field);
PromptSupport.setPrompt(syntaxHelp, field);
PromptSupport.setFontStyle(Font.ITALIC, field);
PromptSupport.setFocusBehavior(FocusBehavior.SHOW_PROMPT, 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));
}