Component isEnabled - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Component isEnabled method.

This code example shows how to use the following methods:isEnabled, isShowing
   * @param c the target component. 
   * @throws IllegalStateException if the {@code Component} is disabled. 
   */ 
  @RunsInCurrentThread 
  public static void checkEnabled(@Nonnull Component c) {
    if (!c.isEnabled()) {
      throw new IllegalStateException(concat("Expecting component ", format(c), " to be enabled"));
    } 
  } 
 
  /** 
   * <p> 
   * Verifies that the {@code Component} is showing on the screen. 
   * </p> 
   *  
   * <p> 
   * <b>Note:</b> This method is accessed in the current executing thread. Such thread may or may not be the event 
   * dispatch thread (EDT.) Client code must call this method from the EDT. 
   * </p> 
   *  

5
CodeRank
This code example shows how to use the following methods:getBackground, getFont, getForeground, isEnabled, getSelectionBackground
This code example shows how to use the following methods:isEnabled, isShowing, isVisible, getClass, getMessage
  @RunsInCurrentThread 
  @Override 
  protected @Nonnull String doFormat(@Nonnull Component c) {
    JOptionPane optionPane = (JOptionPane)c;
    String format = "%s[message=%s, messageType=%s, optionType=%s, enabled=%b, visible=%b, showing=%b]";
    return String.format(format, optionPane.getClass().getName(), quote(optionPane.getMessage()),
        MESSAGE_TYPES.get(optionPane.getMessageType()), OPTION_TYPES.get(optionPane.getOptionType()),
        optionPane.isEnabled(), optionPane.isVisible(), optionPane.isShowing());
  } 
 
  /** 
   * @return {@code JOptionPane.class}. 
   */ 
  @Override 
  public @Nonnull Class<? extends Component> targetType() {
    return JOptionPane.class;
  } 
} 
7
CodeRank
This code example shows how to use the following methods:isEnabled, getDisabledIcon, getIcon, getText
6
CodeRank
This code example shows how to use the following methods:getBackground, getComponentOrientation, getFont, getForeground, isEnabled
            return noFocusBorder;
        } 
    } 
 
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        setComponentOrientation(list.getComponentOrientation());
        if (isSelected) {
            setBackground(list.getSelectionBackground());
            setForeground(list.getSelectionForeground());
        } else { 
            setBackground(list.getBackground());
            setForeground(list.getForeground());
        } 
 
        if (value instanceof Icon) {
            label.setIcon((Icon) value);
            label.setText("");
        } else { 
            label.setIcon(null);
            label.setText((value == null) ? "" : value.toString());

6
CodeRank
This code example shows how to use the following methods:getBackground, isEnabled, setBackground, isEditable
        } 
    } 
 
 
    private void updateBackground(JTextComponent c) {
        Color background = c.getBackground();
        if (!(background instanceof UIResource)) {
            return; 
        } 
        Color newColor = null;
        if (!c.isEnabled()) {
            newColor = UIManager.getColor("TextArea.disabledBackground");
        } 
        if (newColor == null && !c.isEditable()) {
            newColor = UIManager.getColor("TextArea.inactiveBackground");
        } 
        if (newColor == null) {
            newColor = UIManager.getColor("TextArea.background");
        } 
        if (newColor != null && newColor != background) {

6
CodeRank
This code example shows how to use the following methods:isEnabled, isSelected, setBorderPainted, setBackground
        public void mouseExited(MouseEvent e) {
            setDefaultState(getButton(e));
        } 
 
        private void setDefaultState(AbstractButton b) {
            if (b.isSelected()) {
                setSelectedState(b);
            } else { 
                setNormalState(b);
            } 
        } 
 
        private void setNormalState(AbstractButton b) {
            b.setBorderPainted(false);
//            b.setForeground(getDefaultForeground()); 
            b.setBackground(getDefaultBackground());
        } 
 
        private void setSelectedState(AbstractButton b) {
            if (b.isEnabled()) {

6
CodeRank
This code example shows how to use the following methods:getBackground, isEnabled, setBackground, isEditable
        } 
    } 
 
 
    private void updateBackground(JTextComponent c) {
        Color background = c.getBackground();
        if (!(background instanceof UIResource)) {
            return; 
        } 
        Color newColor = null;
        if (!c.isEnabled()) {
            newColor = UIManager.getColor("TextArea.disabledBackground");
        } 
        if (newColor == null && !c.isEditable()) {
            newColor = UIManager.getColor("TextArea.inactiveBackground");
        } 
        if (newColor == null) {
            newColor = UIManager.getColor("TextArea.background");
        } 
        if (newColor != null && newColor != background) {

6
CodeRank
This code example shows how to use the following methods:isEnabled, setEnabled
            enable(); 
        } 
    } 
 
    public void add(JComponent component) {
        components.add(component);
 
        if (SoapUI.getTestMonitor().hasRunningTest(testCase)) {
            states.add(component.isEnabled());
            component.setEnabled(false);
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getName, isEnabled, isShowing, isVisible, getClass
  @Override 
  protected @Nonnull String doFormat(@Nonnull Component c) {
    JFileChooser fileChooser = (JFileChooser) c;
    String format =
        "%s[name=%s, dialogTitle=%s, dialogType=%s, currentDirectory=%s, enabled=%b, visible=%b, showing=%b"; 
    return String.format(format, fileChooser.getClass().getName(), quote(fileChooser.getName()),
        quote(fileChooser.getDialogTitle()), DIALOG_TYPES.get(fileChooser.getDialogType()),
        toStringOf(fileChooser.getCurrentDirectory()), fileChooser.isEnabled(), fileChooser.isVisible(),
        fileChooser.isShowing());
  } 
 
  /** 
   * @return {@code JFileChooser.class}. 
   */ 
  @Override 
  public @Nonnull Class<? extends Component> targetType() {
    return JFileChooser.class;
  } 
} 
6
CodeRank
isEnabled Method Overview
Determines whether this component is enabled.
See Code Examples for other Java 8 Component Methods: