List of usage examples for javax.swing JComponent setEnabled
@BeanProperty(expert = true, preferred = true, visualUpdate = true, description = "The enabled state of the component.") public void setEnabled(boolean enabled)
From source file:Main.java
public static void setJComponentEnabled(JComponent component, boolean enabled) { component.setEnabled(enabled); for (Component c : component.getComponents()) { c.setEnabled(enabled);/* ww w . j a v a 2s . co m*/ } }
From source file:Main.java
/** Recursively sets or clears the enabled property on a JComponent and all its children. */ public static void setEnabledRecursive(JComponent c, boolean enabled) { c.setEnabled(enabled); Component[] child = c.getComponents(); for (int i = 0; i < child.length; ++i) { if (child[i] instanceof JComponent) setEnabledRecursive((JComponent) child[i], enabled); }/*from w ww . j av a 2s. com*/ }
From source file:Main.java
public static void linkEnabled(JComponent watcher, final JComponent... actor) { watcher.addPropertyChangeListener(new PropertyChangeListener() { @Override//from w w w. j a v a 2s . c o m public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("enabled")) { Boolean newValue = (Boolean) evt.getNewValue(); if (newValue) { for (JComponent j : actor) { j.setEnabled(true); } } else { for (JComponent j : actor) { j.setEnabled(false); } } } } }); }
From source file:Main.java
/** * Enables/disables a {@code JComponent} and all its associated children. * * @param component {@code JComponent}// w w w . java 2 s .com * @param enabled true if this component should be enabled, false otherwise * @since 0.3.0 */ public static void setEnabled(JComponent component, boolean enabled) { component.setEnabled(enabled); List<Component> children = getAllComponents(component); for (Component child : children) if (child instanceof JComponent) ((JComponent) child).setEnabled(enabled); }
From source file:Main.java
public static void setEnabled(JComponent component, boolean t) { synchronized (component.getTreeLock()) { for (Component c : component.getComponents()) if (c instanceof JComponent) setEnabled((JComponent) c, t); }//from w ww. ja va 2s . c om component.setEnabled(t); }
From source file:ButtonScroll.java
protected void enableComponent(JComponent c, boolean b) { if (c.isEnabled() != b) c.setEnabled(b); }
From source file:br.usp.poli.lta.cereda.wsn2spa.Editor.java
private void state(boolean status, JComponent... components) { for (JComponent component : components) { component.setEnabled(status); }//w ww. j a v a 2 s . c o m }
From source file:edu.ku.brc.specify.config.init.InstSetupPanel.java
/** * @param enable/*w w w. j av a 2 s. co m*/ */ protected void setUIEnabled(final boolean enable) { for (JComponent c : compList) { c.setEnabled(enable); } testBtn.setEnabled(enable); }
From source file:cool.pandora.modeller.ui.jpanel.base.BagInfoForm.java
private void createFormFieldsFromMap(final BagTableFormBuilder formBuilder) { int rowCount = 0; final int index = 2; final Set<String> keys = fieldMap.keySet(); for (final BagInfoField field : fieldMap.values()) { formBuilder.row();//from w w w.j a v a 2 s .c om rowCount++; final ImageIcon imageIcon = bagView.getPropertyImage("bag.delete.image"); JButton removeButton = new JButton(imageIcon); final Dimension dimension = removeButton.getPreferredSize(); dimension.width = imageIcon.getIconWidth(); removeButton.setMaximumSize(dimension); removeButton.setOpaque(false); removeButton.setBorderPainted(false); removeButton.setContentAreaFilled(false); removeButton.addActionListener(new RemoveFieldHandler()); logger.debug("OrganizationInfoForm add: " + field); if (field.getValue() != null && field.getValue().length() > 60) { field.setComponentType(BagInfoField.TEXTAREA_COMPONENT); } if (field.isRequired()) { removeButton = new JButton(); removeButton.setOpaque(false); removeButton.setBorderPainted(false); removeButton.setContentAreaFilled(false); } switch (field.getComponentType()) { case BagInfoField.TEXTAREA_COMPONENT: final JComponent[] tlist = formBuilder.addTextArea(field.isRequired(), field.getLabel(), removeButton); final JComponent textarea = tlist[index]; textarea.setEnabled(field.isEnabled()); textarea.addFocusListener(this); ((NoTabTextArea) textarea).setText(field.getValue()); textarea.setBorder(new EmptyBorder(1, 1, 1, 1)); ((NoTabTextArea) textarea).setLineWrap(true); if (rowCount == 1) { focusField = textarea; } break; case BagInfoField.TEXTFIELD_COMPONENT: final JComponent[] flist = formBuilder.add(field.isRequired(), field.getLabel(), removeButton); final JComponent comp = flist[index]; comp.setEnabled(field.isEnabled()); comp.addFocusListener(this); ((JTextField) comp).setText(field.getValue()); if (rowCount == 1) { focusField = comp; } break; case BagInfoField.LIST_COMPONENT: final List<String> elements = field.getElements(); final JComponent[] llist = formBuilder.addList(field.isRequired(), field.getLabel(), elements, field.getValue(), removeButton); final JComponent lcomp = llist[index]; lcomp.setEnabled(field.isEnabled()); lcomp.addFocusListener(this); if (field.getValue() != null) { ((JComboBox<?>) lcomp).setSelectedItem(field.getValue().trim()); } if (rowCount == 1) { focusField = lcomp; } break; default: } } if (focusField != null) { focusField.requestFocus(); } }
From source file:cool.pandora.modeller.ui.jpanel.base.OrganizationProfileForm.java
/** * createFormFields./*w w w. jav a2s .c o m*/ * * @return fieldForm */ private JComponent createFormFields() { final JComponent fieldForm; final BagTableFormBuilder formBuilder = new BagTableFormBuilder(getBindingFactory()); formBuilder.row(); formBuilder.addSeparator("Send from Organization"); formBuilder.row(); JComponent field = formBuilder.add("sourceOrganization")[1]; final Organization organization = bagView.getBag().getProfile().getOrganization(); if (organization != null && organization.getName().isReadOnly()) { field.setEnabled(false); } field.addFocusListener(this); formBuilder.row(); final JComponent orgAddress = formBuilder.add("organizationAddress")[1]; if (organization != null && organization.getAddress().isReadOnly()) { field.setEnabled(false); } orgAddress.addFocusListener(this); final Contact fromContact = bagView.getBag().getProfile().getSendFromContact(); formBuilder.row(); formBuilder.addSeparator("Send from Contact"); formBuilder.row(); this.contactName = formBuilder.add("srcContactName")[1]; if (fromContact != null && fromContact.getContactName().isReadOnly()) { field.setEnabled(false); } this.contactName.addFocusListener(this); formBuilder.row(); field = formBuilder.add("srcContactPhone")[1]; if (fromContact != null && fromContact.getTelephone().isReadOnly()) { field.setEnabled(false); } field.addFocusListener(this); formBuilder.row(); field = formBuilder.add("srcContactEmail")[1]; if (fromContact != null && fromContact.getEmail().isReadOnly()) { field.setEnabled(false); } field.addFocusListener(this); formBuilder.row(); formBuilder.addSeparator("Send to Contact"); formBuilder.row(); field = formBuilder.add("toContactName")[1]; final Contact contact = bagView.getBag().getProfile().getSendToContact(); if (contact != null && contact.getContactName().isReadOnly()) { field.setEnabled(false); } field.addFocusListener(this); formBuilder.row(); field = formBuilder.add("toContactPhone")[1]; if (contact != null && contact.getTelephone().isReadOnly()) { field.setEnabled(false); } field.addFocusListener(this); formBuilder.row(); field = formBuilder.add("toContactEmail")[1]; if (contact != null && contact.getEmail().isReadOnly()) { field.setEnabled(false); } field.addFocusListener(this); formBuilder.row(); this.contactName.requestFocus(); fieldForm = formBuilder.getForm(); return fieldForm; }