本文整理汇总了Java中javax.swing.JCheckBox.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java JCheckBox.setEnabled方法的具体用法?Java JCheckBox.setEnabled怎么用?Java JCheckBox.setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JCheckBox
的用法示例。
在下文中一共展示了JCheckBox.setEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setEnabled
import javax.swing.JCheckBox; //导入方法依赖的package包/类
@Override
public void setEnabled(final boolean enable) {
for (final JCheckBox check : _packets.values()) {
check.setEnabled(enable);
}
_hostIpTextField.setEnabled(enable);
_allPortCheck.setEnabled(enable);
_capturePeriod.setEnabled(enable);
_filterLengthTF.setEnabled(enable && _filterPacketLengthCheck.isSelected());
_filterPacketLengthCheck.setEnabled(enable);
_portTF.setEnabled(enable && !_allPortCheck.isSelected());
if (enable) {
_captureButton.setToolTipText(Resources.getLabel("capture.packet.start"));
_captureButton.setIcon(GO_IMG);
} else {
_captureButton.setToolTipText(Resources.getLabel("cancel.button"));
_captureButton.setIcon(Resources.getImageIcon("over.png"));
}
}
示例2: getListCellRendererComponent
import javax.swing.JCheckBox; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(
JList<? extends JCheckBox> list, JCheckBox value, int index,
boolean isSelected, boolean cellHasFocus) {
JPanel panel = new JPanel(new BorderLayout());
JCheckBox checkbox = value;
final JCheckBox newCheck = new JCheckBox();
final JLabel newLabel = new JLabel(checkbox.getText());
newCheck.setSelected(checkbox.isSelected());
// Drawing checkbox, change the appearance here
newCheck.setBackground(isSelected ? getSelectionBackground()
: getBackground());
newCheck.setForeground(isSelected ? getSelectionForeground()
: getForeground());
newCheck.setEnabled(isEnabled());
newCheck.setFont(getFont());
newCheck.setFocusPainted(false);
newCheck.setBorderPainted(true);
newCheck.setBorder(isSelected ? UIManager
.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
newLabel.setOpaque(true);
newLabel.setBackground(isSelected ? getSelectionBackground()
: getBackground());
newLabel.setForeground(isSelected ? getSelectionForeground()
: getForeground());
newLabel.setEnabled(isEnabled());
newLabel.setFocusable(false);
newLabel.setFont(getFont());
newLabel.setBorder(isSelected ? UIManager
.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
newLabel.setIcon(checkbox.getIcon());
panel.add(newCheck, BorderLayout.WEST);
panel.add(newLabel, BorderLayout.CENTER);
return panel;
}
示例3: initGapValues
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private static void initGapValues(EditableGap eg, JComboBox sizeCombo, JCheckBox resCheckBox) {
if (eg != null) {
String selected = null;
String[] defaultNames = eg.getPaddingDisplayNames();
if (eg.canHaveDefaultValue() && defaultNames != null) {
sizeCombo.setModel(new DefaultComboBoxModel(defaultNames));
if (eg.definedSize == LayoutConstants.NOT_EXPLICITLY_DEFINED) {
LayoutConstants.PaddingType[] defaultTypes = eg.getPossiblePaddingTypes();
if (eg.paddingType == null || defaultTypes == null || defaultTypes.length == 0) {
selected = defaultNames[0];
} else {
for (int i=0; i < defaultTypes.length; i++) {
if (eg.paddingType == defaultTypes[i]) {
selected = defaultNames[i];
break;
}
}
}
}
}
if (selected == null) {
selected = Integer.toString(eg.definedSize);
}
sizeCombo.setSelectedItem(selected);
resCheckBox.setSelected(eg.resizing);
} else {
sizeCombo.setSelectedItem(NbBundle.getMessage(EditLayoutSpacePanel.class, "VALUE_NoEmptySpace")); // NOI18N
sizeCombo.setEnabled(false);
resCheckBox.setEnabled(false);
}
}
示例4: setUpCheckBox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
final JCheckBox setUpCheckBox(CheckRenderDataProvider crendata, Object value, JCheckBox cb) {
Boolean chSelected = crendata.isSelected(value);
cb.setEnabled(true);
cb.setSelected(!Boolean.FALSE.equals(chSelected));
// Third state is "selected armed" to be consistent with org.openide.explorer.propertysheet.ButtonModel3Way
cb.getModel().setArmed(chSelected == null);
cb.getModel().setPressed(chSelected == null);
cb.setEnabled(crendata.isCheckEnabled(value));
cb.setBackground(getBackground());
return cb;
}
示例5: createComponent
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private JCheckBox createComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
EclipseProject project = projects[row];
JCheckBox chb = new JCheckBox();
chb.setSelected(selectedProjects.contains(project) ||
requiredProjects.contains(project));
chb.setToolTipText(null);
if (project.isImportSupported() && !requiredProjects.contains(project)) {
chb.setEnabled(true);
} else {
// required and non-java project are disabled
chb.setEnabled(false);
if (!project.isImportSupported()) {
chb.setToolTipText(ProjectImporterWizard.getMessage(
"MSG_NonJavaProject", project.getName())); // NOI18N
}
}
if (isSelected) {
chb.setOpaque(true);
chb.setForeground(table.getSelectionForeground());
chb.setBackground(table.getSelectionBackground());
} else {
chb.setOpaque(false);
chb.setForeground(table.getForeground());
chb.setBackground(table.getBackground());
}
return chb;
}
示例6: enableOrDisableCompareAlgs
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/** Edited by Abhimanyu Chugh **/
private void enableOrDisableCompareAlgs(boolean enabled) {
compPanel.setEnabled(enabled);
compMultiAlg.setEnabled(enabled);
for (JCheckBox checkBox : algCheckBoxes.values()) {
checkBox.setEnabled(enabled);
}
for (JTextField tolerance : algTolerances.values()) {
tolerance.setEnabled(enabled);
}
for (JLabel algTolLabel : algToleranceLabels.values()) {
algTolLabel.setEnabled(enabled);
}
}
示例7: setAlgorithms
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private void setAlgorithms() {
if ((data.isWhatifAlgorithms() && !compMultiAlg.isSelected()) || (!data.isWhatifAlgorithms() && compMultiAlg.isSelected())) {
algPanel.setVisible(true);
compMultiAlg.setSelected(true);
}
if (!data.isClosed()) {
compMultiAlg.setEnabled(false);
}
for (Entry<SolverAlgorithm, JCheckBox> e : this.algCheckBoxes.entrySet()) {
SolverAlgorithm algo = e.getKey();
boolean selected = (data.getWhatifAlgorithms().contains(algo));
JCheckBox checkbox = e.getValue();
if ((selected && !checkbox.isSelected()) || (!selected && checkbox.isSelected())) {
checkbox.doClick();
}
if (!data.isClosed()) {
checkbox.setEnabled(false);
}
if (!algo.isExact()) {
algTolerances.get(algo).setText(numFormat.format(data.getWhatifAlgorithmTolerance(algo)));
if (!data.isClosed()) {
algToleranceLabels.get(algo).setEnabled(false);
algTolerances.get(algo).setEnabled(false);
}
}
}
}
示例8: resetColorChooser
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private void resetColorChooser(JCheckBox checkBox, ColorPanel colorPanel,
@Nullable Color color) {
checkBox.setEnabled(true);
if (color == null) {
checkBox.setSelected(false);
colorPanel.setEnabled(false);
colorPanel.setSelectedColor(null);
} else {
checkBox.setSelected(true);
colorPanel.setEnabled(true);
colorPanel.setSelectedColor(color);
}
}
示例9: GuiPayloadField
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private GuiPayloadField(FieldVO fieldVO, FieldVO superfieldVO) {
this.isSubfield = (superfieldVO != null);
this.superFieldVO = superfieldVO;
this.fieldVO = fieldVO.getInstanceCopy();
this.fieldVO.setFieldList(new ArrayList<FieldVO>());
if (isSubfield)
superFieldVO.getFieldList().add(this.fieldVO);
else
messageVO.getFieldList().add(this.fieldVO);
ckBox = new JCheckBox();
txtType = new JTextField();
txtLength = new JTextField();
txtValue = new JTextField();
subfieldList = new ArrayList<GuiPayloadField>();
lblFieldNum = new JLabel(fieldVO.getBitNum().toString());
lblFieldName = new JLabel(fieldVO.getName());
lblType = new JLabel(fieldVO.getType().toString());
lblDynamic = new JLabel();
lblDynamic.setIcon(new ImageIcon(PnlGuiPayload.class.getResource("/resource/search.png")));
lblDynamic.setToolTipText(fieldVO.getDynaCondition());
lineNum = numLines;
numLines++;
ckBox.setBounds(10, 10 + (lineNum * 25), 22, 22);
lblFieldNum.setBounds(40, 10 + (lineNum * 25), 50, 22);
lblFieldName.setBounds(80, 10 + (lineNum * 25), 100, 22);
lblType.setBounds(470, 10 + (lineNum * 25), 100, 22);
lblDynamic.setBounds(600, 10 + (lineNum * 25), 50, 22);
if (fieldVO.getType() == TypeEnum.ALPHANUMERIC) {
txtValue.setBounds(190, 10 + (lineNum * 25), 260, 22);
}
else if (fieldVO.getType() == TypeEnum.TLV) {
txtType.setBounds(190, 10 + (lineNum * 25), 80, 22);
txtLength.setBounds(280, 10 + (lineNum * 25), 80, 22);
txtValue.setBounds(370, 10 + (lineNum * 25), 80, 22);
pnlFields.add(txtType);
pnlFields.add(txtLength);
}
if (!isSubfield)
pnlFields.add(ckBox);
pnlFields.add(lblFieldNum);
pnlFields.add(lblFieldName);
pnlFields.add(txtValue);
pnlFields.add(lblType);
txtType.addKeyListener(saveFieldPayloadAction);
txtLength.addKeyListener(saveFieldPayloadAction);
txtValue.addKeyListener(saveFieldPayloadAction);
if (!fieldVO.getDynaCondition().equals("") && !fieldVO.getDynaCondition().equals("true"))
pnlFields.add(lblDynamic);
if (fieldVO.getDynaCondition().equals("true")) {
ckBox.setSelected(true);
ckBox.setEnabled(false);
ckBoxClick(ckBox);
setEnabled(true);
}
else {
ckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ckBoxClick((JCheckBox) e.getSource());
saveFieldValue();
}
});
setEnabled(false);
}
}
示例10: setChoicesEnabled
import javax.swing.JCheckBox; //导入方法依赖的package包/类
@Override
protected void setChoicesEnabled(boolean enabled)
{
this.enabled = enabled;
for( JCheckBox box : checkboxes.values() )
{
box.setEnabled(enabled);
}
}
示例11: createPlotAllCheckbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private Component createPlotAllCheckbox() {
drawAllIcons = new JCheckBox("Draw All Center Icons",false);
drawAllIcons.addActionListener(this);
drawAllIcons.setActionCommand("drawAll");
drawAllIcons.setEnabled(false);
return drawAllIcons;
}
示例12: createThumbsCheckbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected Component createThumbsCheckbox() {
thumbsB = new JCheckBox("<html>Image Viewer</html>",true);
thumbsB.setSize(45, 45);
thumbsB.addActionListener(this);
thumbsB.setActionCommand("thumb");
thumbsB.setEnabled(false);
return thumbsB;
}
示例13: createPlotCheckbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected Component createPlotCheckbox() {
plotB = new JCheckBox("<html>Plot Refresh</html>",true);
plotB.setSize(50, 45);
plotB.addActionListener(this);
plotB.setActionCommand("plotS");
plotB.setEnabled(false);
return plotB;
}
示例14: createAllPlotableCheckbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected Component createAllPlotableCheckbox() {
plotAllB = new JCheckBox("<html>Plot All</html>",true);
plotAllB.setSize(50, 45);
plotAllB.addActionListener(this);
plotAllB.setActionCommand("plotAll");
plotAllB.setEnabled(false);
return plotAllB;
}
示例15: initComponentsMore
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private void initComponentsMore(ImportData data, boolean removeUnusedImports) {
contentPanel.setLayout( new GridBagLayout() );
contentPanel.setBackground( UIManager.getColor("Table.background") ); //NOI18N
jScrollPane1.setBorder( UIManager.getBorder("ScrollPane.border") ); //NOI18N
jScrollPane1.getVerticalScrollBar().setUnitIncrement( new JLabel("X").getPreferredSize().height );
jScrollPane1.getVerticalScrollBar().setBlockIncrement( new JLabel("X").getPreferredSize().height*10 );
if (data.variants.length > 0 ) {
int row = 0;
combos = new JComboBox[data.variants.length];
Font monoSpaced = new Font( "Monospaced", Font.PLAIN, new JLabel().getFont().getSize() );
FocusListener focusListener = new FocusListener() {
public void focusGained(FocusEvent e) {
Component c = e.getComponent();
Rectangle r = c.getBounds();
contentPanel.scrollRectToVisible( r );
}
public void focusLost(FocusEvent arg0) {
}
};
for (int i=0; i < data.variants.length; i++){
combos[i] = createComboBox(data.variants[i], data.defaults[i], monoSpaced, focusListener );
JLabel lblSimpleName = new JLabel(data.simpleNames[i]);
lblSimpleName.setOpaque( false );
lblSimpleName.setFont( monoSpaced );
lblSimpleName.setLabelFor( combos[i] );
contentPanel.add( lblSimpleName, new GridBagConstraints(0,row,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(3,5,2,5),0,0) );
contentPanel.add( combos[i], new GridBagConstraints(1,row++,1,1,1.0,0.0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(3,5,2,5),0,0) );
}
contentPanel.add( new JLabel(), new GridBagConstraints(2,row,2,1,0.0,1.0,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0) );
Dimension d = contentPanel.getPreferredSize();
d.height = getRowHeight() * Math.min(combos.length, 6);
jScrollPane1.getViewport().setPreferredSize( d );
} else {
contentPanel.add( new JLabel(getBundleString("FixDupImportStmts_NothingToFix")), new GridBagConstraints(0,0,1,1,1.0,1.0,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(20,20,20,20),0,0) );
}
// load localized text into widgets:
lblTitle.setText(getBundleString("FixDupImportStmts_IntroLbl")); //NOI18N
lblHeader.setText(getBundleString("FixDupImportStmts_Header")); //NOI18N
checkUnusedImports = new JCheckBox();
Mnemonics.setLocalizedText(checkUnusedImports, getBundleString("FixDupImportStmts_UnusedImports")); //NOI18N
bottomPanel.add( checkUnusedImports, BorderLayout.WEST );
checkUnusedImports.setEnabled(true);
checkUnusedImports.setSelected(removeUnusedImports);
}