List of usage examples for java.awt Component setEnabled
public void setEnabled(boolean b)
From source file:de.tbuchloh.kiskis.gui.dialogs.SecuredElementCreationDlg.java
private JPanel createButtonGroup() { final JPanel main = new JPanel(new GridLayout(TYPES.length, 1, 5, 5)); main.setBorder(BorderFactory.createEmptyBorder(15, 50, 5, 150)); _bg = new ButtonGroup(); _buttons = new JRadioButton[TYPES.length]; final String lastSelected = P.get(K_LAST_CREATED_SECURED_ELEMENT, NetAccount.class.getName()); LOG.debug("Last created class: " + lastSelected); for (int i = 0; i < TYPES.length; ++i) { _buttons[i] = new JRadioButton(TYPES[i]._label); final Class c = TYPES[i]._clazz; if (c.getName().equals(lastSelected)) { _buttons[i].setSelected(true); }//from w w w. j av a 2s . c om _bg.add(_buttons[i]); Component comp = _buttons[i]; if (c == GenericAccount.class) { final JPanel p = new JPanel(new BorderLayout(10, 0)); p.add(comp); p.add(_templates, BorderLayout.EAST); _templates.addItemListener(new RadioItemListener(_buttons[i])); comp.setEnabled(_templates.isEnabled()); comp = p; } main.add(comp); } return main; }
From source file:eu.ggnet.dwoss.redtape.position.PositionUpdateCask.java
private void disableComponents(Component... c) { for (Component component : c) { component.setEnabled(false); } }
From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java
/** * Enables all menu items/* ww w . j a v a 2s . c om*/ */ public void enableAll() { for (Component component : getComponents()) { component.setEnabled(true); if (component instanceof JMenu) { for (Component menuComponent : ((JMenu) component).getMenuComponents()) menuComponent.setEnabled(true); } } }
From source file:edu.ku.brc.specify.datamodel.busrules.AgentBusRules.java
/** * Enables/Disables both the control and the Label * @param id the id of the control//from www . j ava 2 s .co m * @param enabled enable it * @param value the value it should set * @param thisObj the main data object */ protected void enableFieldAndLabel(final String id, final boolean enabled, final String value, final Agent agent) { Component field = formViewObj.getCompById(id); if (field != null) { field.setEnabled(enabled); if (field instanceof TextFieldFromPickListTable) { String title = ""; PickListDBAdapterIFace adaptor = ((TextFieldFromPickListTable) field).getPickListAdapter(); if (adaptor != null) { for (PickListItemIFace pli : adaptor.getList()) { if (pli.getValue().equals(value)) { title = pli.getTitle(); break; } } ((TextFieldFromPickListTable) field).setText(title); } else { log.error("Adapter was null for id [" + id + "] on the Agent Form."); } return; } if (field instanceof JComboBox || field instanceof ValComboBox) { JComboBox<?> cbx = field instanceof ValComboBox ? ((ValComboBox) field).getComboBox() : (JComboBox<?>) field; int inx = -1; if (value != null) { AbstractListModel<?> model = (AbstractListModel<?>) cbx.getModel(); for (int i = 0; i < model.getSize(); i++) { Object item = model.getElementAt(i); if (item instanceof PickListItemIFace) { PickListItemIFace pli = (PickListItemIFace) item; if (pli.getValue().equals(value)) { inx = i; break; } } else if (item.toString().equals(value)) { inx = i; break; } } } //System.err.println("AgentBusRules - id "+id+" setting to "+inx); cbx.setSelectedIndex(inx); } else if (field instanceof JTextComponent) { ((JTextComponent) field).setText(value != null ? value : ""); } else if (field instanceof PartialDateUI) { PartialDateUI plugin = (PartialDateUI) field; plugin.setValue(agent, null); } else { log.debug("******** unhandled component type: " + field); } JLabel label = formViewObj.getLabelFor(field); if (label != null) { label.setEnabled(enabled); } } }
From source file:eu.ggnet.dwoss.redtape.document.DocumentUpdateView.java
private void disableComponents(Component... components) { for (Component component : components) { component.setEnabled(false); }/*from w w w.j a v a 2 s. c o m*/ }
From source file:de.mprengemann.intellij.plugin.androidicons.forms.AndroidBatchScaleImporter.java
private void createUIComponents() { table = new JBTable() { @NotNull/*from w w w .ja va2 s . com*/ @Override public Component prepareRenderer(@NotNull TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); c.setEnabled(isCellEditable(row, column)); return c; } }; }
From source file:com.diversityarrays.kdxplore.field.FieldViewDialog.java
private void updateControls(boolean enable, Container cont) { for (int i = cont.getComponentCount(); --i >= 0;) { Component c = cont.getComponent(i); if (c instanceof JButton) { c.setEnabled(enable); }//ww w . ja va2 s . c o m } }
From source file:ca.uviccscu.lp.server.main.MainFrame.java
public static void recursiveComponentChange(Component c, boolean enabled) { if (c instanceof Container) { Component[] components = ((Container) c).getComponents(); if (components != null && components.length > 0) { int count = components.length; for (int i = 0; i < count; i++) { components[i].setEnabled(enabled); recursiveComponentChange(components[i], enabled); }//w w w . j a v a 2s. com } } c.setEnabled(enabled); }
From source file:net.sf.taverna.t2.activities.spreadsheet.views.SpreadsheetImportConfigView.java
private void enableTable(JTable table, boolean enabled) { table.setEnabled(enabled);/*from w ww . j av a 2 s .c o m*/ Component editor = table.getEditorComponent(); if (editor != null) { editor.setEnabled(enabled); } if (enabled) { table.setForeground(Color.BLACK); table.getTableHeader().setForeground(Color.BLACK); } else { table.setForeground(Color.LIGHT_GRAY); table.getTableHeader().setForeground(Color.LIGHT_GRAY); } }
From source file:edu.ku.brc.specify.datamodel.busrules.LoanBusRules.java
@Override public void afterFillForm(final Object dataObj) { if (formViewObj != null && formViewObj.getDataObj() instanceof Loan) { formViewObj.setSkippingAttach(true); MultiView mvParent = formViewObj.getMVParent(); Loan loan = (Loan) formViewObj.getDataObj(); boolean isNewObj = loan.getId() == null;//MultiView.isOptionOn(mvParent.getOptions(), MultiView.IS_NEW_OBJECT); boolean isEdit = mvParent.isEditable(); Component comp = formViewObj.getControlByName("generateInvoice"); if (comp instanceof JCheckBox) { ((JCheckBox) comp).setVisible(isEdit); }//from w w w.j ava 2 s. co m boolean allResolved = true; for (LoanPreparation loanPrep : loan.getLoanPreparations()) { Boolean isResolved = loanPrep.getIsResolved(); if (isResolved == null || (isResolved != null && !isResolved)) { allResolved = false; break; } } comp = formViewObj.getControlByName("ReturnLoan"); if (comp instanceof JButton) { comp.setVisible(isEdit); Boolean isClosed = loan.getIsClosed(); comp.setEnabled(!isNewObj && (isClosed != null ? !loan.getIsClosed() : false) && !allResolved); if (allResolved) { ((JButton) comp).setText(UIRegistry.getResourceString("LOAN_ALL_PREPS_RETURNED")); } } if (isNewObj) { Component shipComp = formViewObj.getControlByName("shipmentNumber"); comp = formViewObj.getControlByName("loanNumber"); if (comp instanceof JTextField && shipComp instanceof JTextField) { JTextField loanTxt = (JTextField) comp; if (shipComp instanceof GetSetValueIFace) { GetSetValueIFace gsv = (GetSetValueIFace) shipComp; gsv.setValue(loanTxt.getText(), loanTxt.getText()); } else if (shipComp instanceof JTextField) { ((JTextField) shipComp).setText(loanTxt.getText()); } if (shipComp instanceof UIValidatable) { UIValidatable uiv = (UIValidatable) shipComp; uiv.setChanged(true); } } } } }