本文整理汇总了Java中javax.swing.JCheckBox.setSelected方法的典型用法代码示例。如果您正苦于以下问题:Java JCheckBox.setSelected方法的具体用法?Java JCheckBox.setSelected怎么用?Java JCheckBox.setSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JCheckBox
的用法示例。
在下文中一共展示了JCheckBox.setSelected方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Ed
import javax.swing.JCheckBox; //导入方法依赖的package包/类
public Ed(ReportState piece) {
box = new JPanel();
box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
descInput = new StringConfigurer(null, "Description: ", piece.description);
box.add(descInput.getControls());
keys = new NamedKeyStrokeArrayConfigurer(null, "Report on these keystrokes: ", piece.keys);
box.add(keys.getControls());
cycle = new JCheckBox("Cycle through different messages?");
box.add(cycle);
format = new PlayerIdFormattedStringConfigurer(null, "Report format: ", new String[]{COMMAND_NAME,
OLD_UNIT_NAME,
NEW_UNIT_NAME,
MAP_NAME,
OLD_MAP_NAME,
LOCATION_NAME,
OLD_LOCATION_NAME});
format.setValue(piece.reportFormat);
box.add(format.getControls());
cycleFormat = new StringArrayConfigurer(null, "Message formats", piece.cycleReportFormat);
box.add(cycleFormat.getControls());
cycleDownKeys = new NamedKeyStrokeArrayConfigurer(null, "Report previous message on these keystrokes: ", piece.cycleDownKeys);
box.add(cycleDownKeys.getControls());
ItemListener l = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
format.getControls().setVisible(!cycle.isSelected());
cycleFormat.getControls().setVisible(cycle.isSelected());
cycleDownKeys.getControls().setVisible(cycle.isSelected());
Window w = SwingUtilities.getWindowAncestor(box);
if (w != null) {
w.pack();
}
}
};
l.itemStateChanged(null);
cycle.addItemListener(l);
cycle.setSelected(piece.cycleReportFormat.length > 0);
}
示例2: initComponents
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private void initComponents() {
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(RevertModificationsPanel.class, "RevertModificationsPanel.infoLabel.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(RevertModificationsPanel.class, "RevertModificationsPanel.infoLabel2.text")); // NOI18N
doBackupChxBox = new JCheckBox();
org.openide.awt.Mnemonics.setLocalizedText(doBackupChxBox, org.openide.util.NbBundle.getMessage(RevertModificationsPanel.class, "RevertModificationsPanel.doBackupChxBox.text")); // NOI18N
boolean doBackup = HgModuleConfig.getDefault().getBackupOnRevertModifications();
doBackupChxBox.setSelected(doBackup);
doPurgeChxBox = new JCheckBox();
org.openide.awt.Mnemonics.setLocalizedText(doPurgeChxBox, org.openide.util.NbBundle.getMessage(RevertModificationsPanel.class, "RevertModificationsPanel.doPurgeChxBox.text")); // NOI18N
doPurgeChxBox.setToolTipText(org.openide.util.NbBundle.getMessage(RevertModificationsPanel.class, "RevertModificationsPanel.doPurgeChxBox.desc")); // NOI18N
doPurgeChxBox.getAccessibleContext().setAccessibleDescription(doPurgeChxBox.getToolTipText());
boolean doPurge = HgModuleConfig.getDefault().isRemoveNewFilesOnRevertModifications();
doPurgeChxBox.setSelected(doPurge);
JPanel optionsPanel = new JPanel();
optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS));
optionsPanel.add(doBackupChxBox);
optionsPanel.add(doPurgeChxBox);
optionsPanel.setBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0));
setOptionsPanel(optionsPanel, null);
}
示例3: load
import javax.swing.JCheckBox; //导入方法依赖的package包/类
@Override
public void load()
{
final DynaCollection dynaCollection = state.getEntity();
name.load(dynaCollection.getName());
description.load(dynaCollection.getDescription());
owner.setUserId(dynaCollection.getOwner());
final Set<String> usageIds = dynaCollection.getUsageIds();
if( !Check.isEmpty(usageIds) )
{
for( String usageId : usageIds )
{
JCheckBox cb = usages.get(usageId);
if( cb != null )
{
cb.setSelected(true);
}
}
}
}
示例4: booleanValue
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
* Prompts the user for boolean value
*
* @param name The name of the dialog to show
* @param currentValue The current value to be displayed
* @param description The help text to provide
* @return The value selected by the user
*/
static public Value booleanValue (String name, final boolean currentValue, final String description) {
return new DefaultValue(name, String.valueOf(currentValue)) {
public void showDialog () {
JCheckBox checkBox = new JCheckBox();
checkBox.setSelected(currentValue);
if (showValueDialog(checkBox, description)) value = String.valueOf(checkBox.isSelected());
}
public Object getObject () {
return Boolean.valueOf(value);
}
};
}
示例5: linkToEmitter
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
* Link this set of controls to a linear interpolater within the particle emitter
*
* @param name The name of the article emitter being linked
* @param interpol The interpolator being configured
*/
private void linkToEmitter(String name, LinearInterpolator interpol) {
// put to value map
valueMap.put(name, interpol);
// now update the checkbox to represent the state of the given
// interpolator
boolean checked = interpol.isActive();
JCheckBox enableControl = (JCheckBox) valueNameToControl.get(name);
enableControl.setSelected(false);
if (checked)
enableControl.setSelected(checked);
}
示例6: getListCellRendererComponent
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
* @see javax.swing.DefaultListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
*/
public Component getListCellRendererComponent(JList list, final Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
final JCheckBox box = new JCheckBox(label.getText());
box.setBackground(label.getBackground());
box.setSelected(((ConfigurableEmitter) value).isEnabled());
checks.put(value, box);
return box;
}
示例7: 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);
}
}
示例8: ShowNextTime
import javax.swing.JCheckBox; //导入方法依赖的package包/类
/** Creates a new instance of RecentProjects */
public ShowNextTime() {
super( new BorderLayout() );
setOpaque(false);
button = new JCheckBox( BundleSupport.getLabel( "ShowOnStartup" ) ); // NOI18N
button.setSelected( WelcomeOptions.getDefault().isShowOnStartup() );
button.setOpaque( false );
button.setForeground( Color.white );
button.setHorizontalTextPosition( SwingConstants.LEFT );
BundleSupport.setAccessibilityProperties( button, "ShowOnStartup" ); //NOI18N
add( button, BorderLayout.CENTER );
button.addActionListener( this );
}
示例9: mkCheckBox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected JCheckBox mkCheckBox(final BooleanPref pref) {
final JCheckBox cb = make(new JCheckBox(pref.getTitleAction()));
pref2comp.put(pref, cb);
ChangeListener ctrl = new ChangeListener() {
public void stateChanged(ChangeEvent e) {
cb.setSelected(pref.get());
}
};
pref.addChangeListener(ctrl);
ctrl.stateChanged(null);
return cb;
}
示例10: 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);
}
}
示例11: checkbox
import javax.swing.JCheckBox; //导入方法依赖的package包/类
protected JCheckBox checkbox(String name, boolean selected)
{
JCheckBox rb = new JCheckBox(name);
rb.setActionCommand(name);
rb.setText("");
rb.setSelected(selected);
checks.put(name, rb);
return rb;
}
示例12: setCheckBoxValue
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private void setCheckBoxValue(Boolean value, boolean defValue, JCheckBox component) {
if (value != null) {
component.setSelected(value.booleanValue());
component.setToolTipText(null);
inherited = false;
component.setFont(component.getFont().deriveFont(Font.BOLD));
} else {
component.setSelected(defValue);
component.setToolTipText(MSG_Value_Inherited());
inherited = true;
component.setFont(component.getFont().deriveFont(Font.PLAIN));
}
}
示例13: createCredentialsInput
import javax.swing.JCheckBox; //导入方法依赖的package包/类
private JPanel createCredentialsInput() {
// main body
JPanel main = new JPanel();
main.setBorder(new EmptyBorder(10, 0, 10, 0));
main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
// Create and populate the panel.
JPanel credentialsPanel = new JPanel(new SpringLayout());
MatteBorder mb = new MatteBorder(1, 0, 0, 0, Color.LIGHT_GRAY);
TitledBorder tb = new TitledBorder(mb, I18n.get("settings.credentials"), TitledBorder.LEFT,
TitledBorder.DEFAULT_POSITION);
credentialsPanel.setBorder(tb);
JLabel serverLabel = new JLabel(I18n.get("settings.server"), JLabel.TRAILING);
credentialsPanel.add(serverLabel);
serverInput = new JTextField();
serverLabel.setLabelFor(serverInput);
credentialsPanel.add(serverInput);
JLabel authLabel = new JLabel(I18n.get("settings.authmethod"), JLabel.TRAILING);
credentialsPanel.add(authLabel);
authBox = new JComboBox<>();
authLabel.setLabelFor(authBox);
credentialsPanel.add(authBox);
JLabel pathLabel = new JLabel(I18n.get("settings.remotepath"), JLabel.TRAILING);
credentialsPanel.add(pathLabel);
pathInput = new JTextField();
pathLabel.setLabelFor(pathInput);
credentialsPanel.add(pathInput);
JLabel userLabel = new JLabel(I18n.get("settings.username"), JLabel.TRAILING);
credentialsPanel.add(userLabel);
userInput = new JTextField();
userLabel.setLabelFor(userInput);
credentialsPanel.add(userInput);
JLabel pwdLabel = new JLabel(I18n.get("settings.password"), JLabel.TRAILING);
credentialsPanel.add(pwdLabel);
pwdInput = new JPasswordField();
pwdLabel.setLabelFor(pwdInput);
credentialsPanel.add(pwdInput);
JLabel enableMasterPwdLabel = new JLabel(I18n.get("settings.usemasterpwd"), JLabel.TRAILING);
credentialsPanel.add(enableMasterPwdLabel);
useMasterPasswordInput = new JCheckBox();
useMasterPasswordInput.setSelected(false);
useMasterPasswordInput.setToolTipText(I18n.get("settings.masterpwddesc"));
enableMasterPwdLabel.setLabelFor(useMasterPasswordInput);
credentialsPanel.add(useMasterPasswordInput);
useMasterPasswordInput.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setMasterPwdInputEnabled(useMasterPasswordInput.isSelected());
}
});
masterPwdLabel = new JLabel(I18n.get("settings.masterpwd"), JLabel.TRAILING);
masterPwdLabel.setEnabled(false);
credentialsPanel.add(masterPwdLabel);
masterPwdInput = new JPasswordField();
masterPwdInput.setToolTipText(I18n.get("settings.masterpwddesc"));
masterPwdInput.setEnabled(false);
masterPwdLabel.setLabelFor(masterPwdInput);
credentialsPanel.add(masterPwdInput);
// Lay out the panel.
SwingUtil.makeCompactGrid(credentialsPanel, 7, 2, // rows, cols
6, 6, // initX, initY
6, 6); // xPad, yPad
main.add(credentialsPanel);
return main;
}
示例14: redraw
import javax.swing.JCheckBox; //导入方法依赖的package包/类
public void redraw() {
if (data.hasResults() && data.areResultsOK()
&& data.getResults().getSaturationSectors().size() > 0) {
if (data.getClasses() == 2) {
this.removeAll();
painter2D = new Convex2DGraph(data, mainWin);
this.setLayout(new BorderLayout());
showLabelsBox = new JCheckBox(
JabaConstants.OPTION_SHOW_ONLY_BOTTLENECK, true);
showLabelsBox.setSelected(false);
showLabelsBox.addActionListener(this);
showLabelsBox.addChangeListener(this);
showLabelsBox.addItemListener(this);
this.add(showLabelsBox, BorderLayout.PAGE_START);
this.add(new JabaCanvas(painter2D), BorderLayout.CENTER);
this.add(new JLabel(JabaConstants.DESCRIPITION_CONVEX_2D_GRAPH),
BorderLayout.PAGE_END);
repaint();
} else if (data.getClasses() == 3) {
this.removeAll();
painter3D = new Convex3DGraph(data, mainWin);
this.setLayout(new BorderLayout());
this.add(make3DOptionPanel(), BorderLayout.EAST);
this.add(new JabaCanvas(painter3D), BorderLayout.CENTER);
this.add(new JLabel(JabaConstants.DESCRIPITION_GRAPH),
BorderLayout.PAGE_END);
repaint();
}
} else {
this.removeAll();
JEditorPane synView = new JTextPane();
synView.setContentType("text/html");
synView.setEditable(false);
JScrollPane synScroll = new JScrollPane(synView);
synScroll
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
synScroll
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
synView.setText("<html><body><center><font face=\"bold\" size=\"3\">Saturation Sectors will be here displayed once you solve the model.</font></center></body></html>");
this.add(synScroll);
repaint();
}
}
示例15: actionPerformed
import javax.swing.JCheckBox; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
JCheckBox firstEntry = null;
JPopupMenu popupMenu = new JPopupMenu();
JPanel menuPanel = new JPanel();
menuPanel.setFocusCycleRoot(true);
popupMenu.add(menuPanel);
menuPanel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.anchor = GridBagConstraints.BASELINE_LEADING;
constraints.weightx = 1;
constraints.gridx = 0;
Set<Integer> visibleColumns = dataPanel.getVisibleColumns();
DataViewTableUIModel dvtm = dataPanel.getModel();
for(int i = 0; i < dvtm.getColumnCount(); i++) {
JCheckBox columnEntry = new JCheckBox(dvtm.getColumnName(i));
columnEntry.setActionCommand(Integer.toString(i));
columnEntry.setSelected(visibleColumns.contains(i));
columnEntry.addActionListener(columnVisibilityToggler);
constraints.gridy += 1;
menuPanel.add(columnEntry, constraints);
if(firstEntry == null) {
firstEntry = columnEntry;
}
}
constraints.gridy += 1;
menuPanel.add(new JSeparator(), constraints);
JCheckBox checkboxItem = new JCheckBox("Fit column width");
checkboxItem.setSelected(dataPanel.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF);
checkboxItem.addActionListener(fitColumnWidthToggler);
constraints.gridy += 1;
menuPanel.add(checkboxItem, constraints);
popupMenu.show(button, 0, button.getHeight());
if(firstEntry == null) {
checkboxItem.requestFocus();
} else {
firstEntry.requestFocus();
}
}