Java Code Examples for javax.swing.JComponent.setEnabled()

The following are Jave code examples for showing how to use setEnabled() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: RunAnalysisPanel.java   View Source Code Vote up 6 votes
void started() {
    started = true;
    
    ((CardLayout) progress.getLayout()).show(progress, "progress");
    progress.invalidate();

    //disable all elements in the dialog:
    List<JComponent> todo = new LinkedList<JComponent>();

    todo.add(this);

    while (!todo.isEmpty()) {
        JComponent c = todo.remove(0);

        if (c == progress) continue;

        c.setEnabled(false);

        for (Component child : c.getComponents()) {
            if (child instanceof JComponent) todo.add((JComponent) child);
        }
    }
}
 
Example 2
Project: HBaseClient   File: EditSubmitActionListener.java   View Source Code Vote up 6 votes
/**
 * 设置所有查询条件控件是否有效
 * 
 * @param i_Visible
 */
public void setEditDatasEnabled(boolean i_Enabled)
{
    // 先设置事情源本身
    this.myself.setEnabled(i_Enabled);
    
    Iterator<?> v_Iterator = this.editDatas.values().iterator();
    
    while ( v_Iterator.hasNext() )
    {
        Object v_QueryCondition = v_Iterator.next();
        
        if ( v_QueryCondition instanceof JComponent )
        {
            JComponent v_QC = (JComponent)v_QueryCondition;
            
            v_QC.setEnabled(i_Enabled);
        }
    }
}
 
Example 3
Project: incubator-netbeans   File: TableUISupport.java   View Source Code Vote up 5 votes
public Component getTableCellRendererComponent(JTable jTable, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    boolean joinTable = false;
    boolean validClass = true;
    boolean existentUpdate = false;
    String problemDisplayName = null;

    if (jTable.getModel() instanceof TableClassNamesModel) {
        TableClassNamesModel model = (TableClassNamesModel)jTable.getModel();
        Table table = model.getTableAt(row);
        joinTable = table.isJoin();
        if (column == 1) {
            existentUpdate = table.getDisabledReason() instanceof Table.ExistingDisabledReason;
            validClass = model.isValidClass(table);
            if (!validClass) {
                problemDisplayName = model.getProblemDisplayName(table);
            }
        }
    }

    Object realValue = null;
    if (joinTable && column == 1) {
        realValue = NbBundle.getMessage(TableUISupport.class, "LBL_JoinTable");
    } else {
        realValue = value;
    }
    JComponent component = (JComponent)super.getTableCellRendererComponent(jTable, realValue, isSelected, hasFocus, row, column);
    component.setEnabled(!joinTable && !existentUpdate);
    component.setToolTipText(joinTable ? NbBundle.getMessage(TableUISupport.class, "LBL_JoinTableDescription") : problemDisplayName);
    component.setForeground((validClass) ? nonErrorForeground : errorForeground);
   
    return component;
}
 
Example 4
Project: incubator-netbeans   File: DefaultFoldingOptions.java   View Source Code Vote up 5 votes
private void updateEnabledState() {
    boolean foldEnable = preferences.getBoolean(SimpleValueNames.CODE_FOLDING_ENABLE, true);
    boolean useDefaults = preferences.getBoolean(FoldUtilitiesImpl.PREF_OVERRIDE_DEFAULTS, true);
    
    for (JComponent c : controls) {
        FoldType ft = (FoldType)c.getClientProperty("type"); // NOI18N
        boolean enable = true;
        if (defaultPrefs != null && useDefaults) {
            enable = !isDefinedDefault(ft);
        }
        enable &= foldEnable;
        c.setEnabled(enable);
    }
}
 
Example 5
Project: incubator-netbeans   File: RemoteRepository.java   View Source Code Vote up 5 votes
@Override
protected void setEnabled (boolean enabled) {
    for (JComponent inputField : inputFields) {
        inputField.setEnabled(enabled);
    }
    if (enabled) {
        updateAuthSelection();
    }
}
 
Example 6
Project: freecol   File: OptionUI.java   View Source Code Vote up 5 votes
/**
 * Set up component.
 */
protected void initialize() {
    JComponent component = getComponent();
    component.setToolTipText(label.getToolTipText());
    component.setEnabled(editable);
    component.setOpaque(false);
}
 
Example 7
Project: incubator-netbeans   File: ExportDiffPanel.java   View Source Code Vote up 5 votes
/** Creates new form ExportDiffPanel */
public ExportDiffPanel(JComponent attachComponent) {
    initComponents();
    this.attachComponent = attachComponent;
    asFileRadioButton.addActionListener(this);
    attachRadioButton.addActionListener(this);
    attachPanel.add(attachComponent);

    attachComponent.setEnabled(false);
    fileTextField.setEnabled(true);
}
 
Example 8
Project: incubator-netbeans   File: ClassNameList.java   View Source Code Vote up 5 votes
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    TableCellRenderer def = table.getDefaultRenderer(table.getColumnClass(column));
    if (!table.isEnabled()) {
        isSelected = hasFocus = false;
    }
    JComponent c = (JComponent)def.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    c.setEnabled(table.isEnabled());
    
    return c;
}
 
Example 9
Project: FreeCol   File: OptionUI.java   View Source Code Vote up 5 votes
/**
 * Set up component.
 */
protected void initialize() {
    JComponent component = getComponent();
    component.setToolTipText(label.getToolTipText());
    component.setEnabled(editable);
    component.setOpaque(false);
}
 
Example 10
Project: incubator-netbeans   File: TableUISupport.java   View Source Code Vote up 5 votes
public Component getTableCellRendererComponent(JTable jTable, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    boolean joinTable = false;
    boolean validClass = true;
    String problemDisplayName = null;

    if (jTable.getModel() instanceof TableClassNamesModel) {
        TableClassNamesModel model = (TableClassNamesModel)jTable.getModel();
        Table table = model.getTableAt(row);
        joinTable = table.isJoin();
        if (column == 1) {
            validClass = model.isValidClass(table);
            if (!validClass) {
                problemDisplayName = model.getProblemDisplayName(table);
            }
        }
    }

    Object realValue = null;
    if (joinTable && column == 1) {
        realValue = NbBundle.getMessage(TableUISupport.class, "LBL_JoinTable");
    } else {
        realValue = value;
    }
    JComponent component = (JComponent)super.getTableCellRendererComponent(jTable, realValue, isSelected, hasFocus, row, column);
    component.setEnabled(!joinTable);
    component.setToolTipText(joinTable ? NbBundle.getMessage(TableUISupport.class, "LBL_JoinTableDescription") : problemDisplayName);
    component.setForeground((validClass) ? nonErrorForeground : errorForeground);
   
    return component;
}
 
Example 11
Project: incubator-netbeans   File: TagManager.java   View Source Code Vote up 5 votes
private void enableControls (boolean enabled) {
    for (JComponent c : new JComponent[] {
            panel.txtFilter,
            panel.btnUpdate,
            panel.tagList,
            panel.btnRemove }) {
        c.setEnabled(enabled);
    }
}
 
Example 12
Project: HBaseClient   File: SubmitActionListener.java   View Source Code Vote up 5 votes
/**
 * 设置所有查询条件控件是否有效
 * 
 * 当 i_Enabled 为真时,对特别控件有业务逻辑判断
 * 
 * @param i_Enabled
 */
public void setQueryConditionsEnabled(boolean i_Enabled)
{
	// 先设置事情源本身
    $myself.setEnabled(i_Enabled);
	
	
	Iterator<?> v_Iterator = this.queryConditionMap.values().iterator();
	while ( v_Iterator.hasNext() )
	{
		Object v_QueryCondition = v_Iterator.next();
		
		if ( v_QueryCondition instanceof JComponent )
		{
			JComponent v_QC = (JComponent)v_QueryCondition;
			
			v_QC.setEnabled(i_Enabled);
		}
	}
	
	
	boolean v_Enable = false;
	if ( i_Enabled )
	{
	    // 设置过滤查询按钮的可用性
        String  v_FileName   = ((JComboBox)XJava.getObject("FamilyName")).getSelectedItem().toString();
        String  v_ColumnName = ((JComboBox)XJava.getObject("ColumnName")).getSelectedItem().toString();
        
        if ( !JavaHelp.isNull(v_FileName) && !JavaHelp.isNull(v_ColumnName) )
        {
            v_Enable = true;
        }
	}
	
	((JComponent)XJava.getObject("xbSubmit"))      .setEnabled(i_Enabled);
       ((JComponent)XJava.getObject("xbSubmitFilter")).setEnabled(v_Enable);
}
 
Example 13
Project: incubator-netbeans   File: RendererFactory.java   View Source Code Vote up 4 votes
/** Get a renderer component appropriate to a given property */
public JComponent getRenderer(Property prop) {
    mdl.setProperty(prop);
    env.reset();

    PropertyEditor editor = preparePropertyEditor(mdl, env);

    if (editor instanceof ExceptionPropertyEditor) {
        return getExceptionRenderer((Exception) editor.getValue());
    }

    JComponent result = null;

    try {
        if (editor.isPaintable()) {
            result = prepareString(editor, env);
        } else {
            Class c = mdl.getPropertyType();

            if ((c == Boolean.class) || (c == boolean.class)) {
                //Special handling for hinting for org.netbeans.beaninfo.BoolEditor
                boolean useRadioRenderer = useRadioBoolean ||
                    (env.getFeatureDescriptor().getValue("stringValues") != null); //NOI18N

                if (useRadioRenderer) {
                    result = prepareRadioButtons(editor, env);
                } else {
                    result = prepareCheckbox(editor, env);
                }
            } else if (editor.getTags() != null) {
                String[] s = editor.getTags();
                boolean editAsText = Boolean.TRUE.equals(prop.getValue("canEditAsText"));

                if ((s.length <= radioButtonMax) && !editAsText) {
                    result = prepareRadioButtons(editor, env);
                } else {
                    result = prepareCombobox(editor, env);
                }
            } else {
                result = prepareString(editor, env);
            }
        }

        if ((result != radioRenderer) && (result != textFieldRenderer)) {
            if ((result != checkboxRenderer) && tableUI && !(result instanceof JComboBox)) {
                result.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
            } else if ((result instanceof JComboBox) && tableUI) {
                result.setBorder(BorderFactory.createEmptyBorder());
            } else if (!(result instanceof JComboBox) && (!(result instanceof JCheckBox))) {
                result.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
            }
        }
    } catch (Exception e) {
        result = getExceptionRenderer(e);
        Logger.getLogger(RendererFactory.class.getName()).log(Level.WARNING, null, e);
    }

    result.setEnabled(prop.canWrite());

    boolean propRequestsSuppressButton = Boolean.TRUE.equals(prop.getValue("suppressCustomEditor")); //NOI18N

    if (
        !(result instanceof JLabel) &&
            ((env.getState() == env.STATE_INVALID) || (prop.getValue("valueIcon") != null))
    ) { //NOI18N
        result = prepareIconPanel(editor, env, (InplaceEditor) result);
    }

    /* If we need a custom editor button, embed the resulting component in
     an instance of ButtonPanel and return that */
    if (
        editor.supportsCustomEditor() && !PropUtils.noCustomButtons && !suppressButton &&
            !propRequestsSuppressButton
    ) {
        ButtonPanel bp = buttonPanel();
        bp.setInplaceEditor((InplaceEditor) result);
        result = bp;
    }

    return result;
}
 
Example 14
Project: incubator-netbeans   File: RemoteRepository.java   View Source Code Vote up 4 votes
@Override
protected void setEnabled (boolean enabled) {
    for (JComponent inputField : inputFields) {
        inputField.setEnabled(enabled);
    }
}
 
Example 15
Project: incubator-netbeans   File: RemoteRepository.java   View Source Code Vote up 4 votes
@Override
protected void setEnabled (boolean enabled) {
    for (JComponent inputField : inputFields) {
        inputField.setEnabled(enabled);
    }
}
 
Example 16
Project: incubator-netbeans   File: SelectUriStep.java   View Source Code Vote up 4 votes
private void setEnabled (boolean enabled) {
    for (JComponent inputField : inputFields) {
        inputField.setEnabled(enabled);
    }
    repository.setEnabled(enabled);
}
 
Example 17
Project: incubator-netbeans   File: LibrariesCustomizer.java   View Source Code Vote up 4 votes
private void selectLibrary (Node[] nodes) {
    int tabCount = this.properties.getTabCount();
    for (int i=0; i<tabCount; i++) {
        this.properties.removeTabAt(0);
    }
    this.libraryName.setEnabled(false);
    this.libraryName.setText("");   //NOI18N
    this.jLabel1.setVisible(false);
    this.libraryName.setVisible(false);
    this.properties.setVisible(false);
    this.deleteButton.setEnabled(false);
    if (nodes.length != 1) {
        return;
    }
    LibraryImplementation impl = nodes[0].getLookup().lookup(LibraryImplementation.class);
    if (impl == null) {
        return;
    }
    this.jLabel1.setVisible(true);
    this.libraryName.setVisible(true);
    this.properties.setVisible(true);
    boolean editable = model.isLibraryEditable (impl);
    this.libraryName.setEnabled(editable && LibrariesSupport.supportsDisplayName(impl));
    this.deleteButton.setEnabled(editable);
    this.libraryName.setText (LibrariesSupport.getLocalizedName(impl));
    LibraryTypeProvider provider = nodes[0].getLookup().lookup(LibraryTypeProvider.class);
    if (provider == null) {
        return;
    }
    LibraryCustomizerContextWrapper customizerContext;
    LibraryStorageArea area = nodes[0].getLookup().lookup(LibraryStorageArea.class);
    if (area != LibraryStorageArea.GLOBAL) {
        customizerContext = new LibraryCustomizerContextWrapper(impl, area);
        File f = Utilities.toFile(URI.create(area.getLocation().toExternalForm()));
        this.libraryLocation.setText(f.getPath());
    } else {
        customizerContext = new LibraryCustomizerContextWrapper(impl, null);
        this.libraryLocation.setText(LABEL_Global_Libraries());
    }

    String[] volumeTypes = provider.getSupportedVolumeTypes();
    for (int i=0; i< volumeTypes.length; i++) {
        Customizer c = provider.getCustomizer (volumeTypes[i]);
        if (c instanceof JComponent) {
            c.setObject (customizerContext);
            JComponent component = (JComponent) c;
            component.setEnabled (editable);
            String tabName = component.getName();
            if (tabName == null) {
                tabName = volumeTypes[i];
            }
            this.properties.addTab(tabName, component);
        }
    }        
}
 
Example 18
Project: jdk8u-jdk   File: ImageTests.java   View Source Code Vote up 4 votes
public JComponent getJComponent() {
    JComponent comp = super.getJComponent();
    comp.setEnabled(possible);
    return comp;
}
 
Example 19
Project: OpenJSharp   File: ImageTests.java   View Source Code Vote up 4 votes
public JComponent getJComponent() {
    JComponent comp = super.getJComponent();
    comp.setEnabled(possible);
    return comp;
}
 
Example 20
Project: KivaBot   File: MainFrameView.java   View Source Code Vote up 2 votes
/**
 * Enables or disables all input fields.
 * 
 * @param enabled
 *            Whether the fields should be enabled or disabled
 */
public void setAllInputEnabled(final boolean enabled) {
	for (final JComponent element : this.mInputElements) {
		element.setEnabled(enabled);
	}
}