当前位置: 首页>>代码示例>>Java>>正文


Java JCheckBox.addItemListener方法代码示例

本文整理汇总了Java中javax.swing.JCheckBox.addItemListener方法的典型用法代码示例。如果您正苦于以下问题:Java JCheckBox.addItemListener方法的具体用法?Java JCheckBox.addItemListener怎么用?Java JCheckBox.addItemListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JCheckBox的用法示例。


在下文中一共展示了JCheckBox.addItemListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addCheckBoxToPanel

import javax.swing.JCheckBox; //导入方法依赖的package包/类
public void addCheckBoxToPanel(Food food) {
    JFrame frame = this;
    jPanel2.setLayout(new GridLayout(0, 4));
    final JCheckBox box = new JCheckBox(food.getFood());
    box.setActionCommand(String.valueOf(food.getId()));
    box.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (box.isSelected()) {
                jTextArea1.append(box.getText() + "\n");
                selectedFoodIds.add(Integer.parseInt(box.getActionCommand()));
            }
        }
    });
    jPanel2.add(box);
    frame.revalidate();
    frame.repaint();
}
 
开发者ID:seyidkanan,项目名称:my-diploma-work,代码行数:19,代码来源:IngredientsFrame.java

示例2: MessagePreferencesPanel

import javax.swing.JCheckBox; //导入方法依赖的package包/类
public MessagePreferencesPanel() {
    setLayout(null);

    refuseMessages = new JCheckBox("Refuse Messages");
    refuseMessages.setSize(150, 25);
    refuseMessages.setLocation(10, 25);
    refuseMessages.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            updateEnabled();
        }
    });
    add(refuseMessages);

    denyMessageLabel = new JLabel("Refusal Message:");
    denyMessageLabel.setSize(150, 25);
    denyMessageLabel.setLocation(20, 50);
    add(denyMessageLabel);

    denyMessageText = new JTextField(REFUSAL_MESSAGE_DEFAULT);
    denyMessageText.setSize(400, 25);
    denyMessageText.setLocation(25, 75);
    add(denyMessageText);

    setSize(STD_XSIZE, STD_YSIZE);
}
 
开发者ID:addertheblack,项目名称:myster,代码行数:26,代码来源:MessageManager.java

示例3: addEnableControl

import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
 * Add a control for enablement
 * 
 * @param text The label to be associated with the check box
 * @param listener The listener to be notified of updates to the new control
 */
private void addEnableControl(String text, ItemListener listener) {
	JCheckBox enableControl = new JCheckBox("Enable " + text);
	enableControl.setBounds(10, offset, 200, 20);
	enableControl.addItemListener(listener);
	add(enableControl);

	controlToValueName.put(enableControl, text);
	valueNameToControl.put(text, enableControl);
	offset += 25;
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:17,代码来源:WhiskasPanel.java

示例4: createLeftPanel

import javax.swing.JCheckBox; //导入方法依赖的package包/类
private synchronized Component createLeftPanel() {
    SampleResult rootSampleResult = new SampleResult();
    rootSampleResult.setSampleLabel("Root");
    rootSampleResult.setSuccessful(true);
    root = new SearchableTreeNode(rootSampleResult, null);

    treeModel = new DefaultTreeModel(root);
    jTree = new JTree(treeModel);
    jTree.setCellRenderer(new ResultsNodeRenderer());
    jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree.addTreeSelectionListener(this);
    jTree.setRootVisible(false);
    jTree.setShowsRootHandles(true);
    JScrollPane treePane = new JScrollPane(jTree);
    treePane.setPreferredSize(new Dimension(200, 300));

    VerticalPanel leftPane = new VerticalPanel();
    leftPane.add(treePane, BorderLayout.CENTER);
    leftPane.add(createComboRender(), BorderLayout.NORTH);
    autoScrollCB = new JCheckBox(JMeterUtils.getResString("view_results_autoscroll")); // $NON-NLS-1$
    autoScrollCB.setSelected(false);
    autoScrollCB.addItemListener(this);
    leftPane.add(autoScrollCB, BorderLayout.SOUTH);
    return leftPane;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:26,代码来源:ViewResultsFullVisualizer.java

示例5: 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);
    }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:39,代码来源:ReportState.java

示例6: CheckBoxFrame

import javax.swing.JCheckBox; //导入方法依赖的package包/类
public CheckBoxFrame()
{
   super("JCheckBox Test");
   setLayout(new FlowLayout());

   // set up JTextField and set its font
   textField = new JTextField("Watch the font style change", 20);
   textField.setFont(new Font("Serif", Font.PLAIN, 14));
   add(textField); // add textField to JFrame

   boldJCheckBox = new JCheckBox("Bold"); 
   italicJCheckBox = new JCheckBox("Italic"); 
   add(boldJCheckBox); // add bold checkbox to JFrame
   add(italicJCheckBox); // add italic checkbox to JFrame

   // register listeners for JCheckBoxes
   CheckBoxHandler handler = new CheckBoxHandler();
   boldJCheckBox.addItemListener(handler);
   italicJCheckBox.addItemListener(handler);
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:21,代码来源:CheckBoxFrame.java

示例7: jbInit

import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
 * Initial set up
 */
void jbInit() throws Exception {
	String[] tags = notesList.getAllTags().toArray(new String[notesList.getAllTags().size()]);
	tagsBoxes = new JCheckBox[tags.length];
	this.setLayout(borderLayout1);

	for (int i = 0; i < tags.length; i++) {
		JCheckBox item = new JCheckBox(tags[i]);
		tagsBoxes[i] = item;
		item.setSelected(false);
		checkPanel.add(item);
		item.addItemListener(this);
	}

	this.add(checkPanel, BorderLayout.NORTH);
	ColorPanels.color(scrollPane.getViewport(), ColorPanels.contentBG);
	ColorPanels.color(checkPanel, ColorPanels.contentBG);
	ColorPanels.color(filteredNotes, ColorPanels.contentBG);

}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:23,代码来源:TagFilterPanel.java

示例8: resetCheckBoxes

import javax.swing.JCheckBox; //导入方法依赖的package包/类
/**
 * Resets tag filter options when tags are edited in a note
 */
public void resetCheckBoxes() {
	checkPanel.removeAll();
	notesList.update();
	String[] tags = notesList.getAllTags().toArray(new String[notesList.getAllTags().size()]);
	tagsBoxes = new JCheckBox[tags.length];
	this.setLayout(borderLayout1);

	for (int i = 0; i < tags.length; i++) {
		JCheckBox item = new JCheckBox(tags[i]);
		tagsBoxes[i] = item;
		item.setSelected(false);
		checkPanel.add(item);
		item.addItemListener(this);
	}

	this.add(checkPanel, BorderLayout.NORTH);
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:21,代码来源:TagFilterPanel.java

示例9: load

import javax.swing.JCheckBox; //导入方法依赖的package包/类
private void load() {
    types = new ArrayList<FoldType>(FoldUtilities.getFoldTypes(mimeType).values());
    if ("".equals(mimeType)) { // NOI18N
        filterUsedMimeTypes();
    }

    boolean override = isCollapseRedefined();
    boolean currentOverride = 
            isDefinedLocally(PREF_OVERRIDE_DEFAULTS) ? !preferences.getBoolean(PREF_OVERRIDE_DEFAULTS, true) : false;
    if (override != currentOverride) {
        updateOverrideChanged();
    }
    
    for (FoldType ft : types) {
        String name = ft.getLabel();
        
        JCheckBox cb = createCheckBox(ft);
        cb.setText(name);
        cb.putClientProperty("id", ft.code()); // NOI18N
        cb.putClientProperty("type", ft); // NOI18N
        localSwitchboard.add(cb);
        controls.add(cb);
        cb.addItemListener(this);
    }
    
    // watch out for preferences
    this.preferences.addPreferenceChangeListener(this);
    updateEnabledState();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:DefaultFoldingOptions.java

示例10: setupGui

import javax.swing.JCheckBox; //导入方法依赖的package包/类
private void setupGui()
{
	nameLabel = new JLabel(s("name"));
	name = new I18nTextField(BundleCache.getLanguages());

	descriptionLabel = new JLabel(s("description"));
	description = new I18nTextArea(BundleCache.getLanguages());
	description.setTextRows(5);

	moveToLive = new JCheckBox(s("move"));
	moveToLive.addItemListener(new ItemListener()
	{
		@Override
		public void itemStateChanged(ItemEvent e)
		{
			enableMoveToLive(moveToLive.isSelected());
		}
	});

	moveToLiveGroup = new ButtonGroup();
	moveToLiveArrival = new JRadioButton(s("move.arrival"));
	moveToLiveAccept = new JRadioButton(s("move.acceptance"));
	moveToLiveGroup.add(moveToLiveArrival);
	moveToLiveGroup.add(moveToLiveAccept);

	proceedNext = new JCheckBox(s("proceed.next"));
	proceedExplanation = new JLabel("<html>" + s("proceed.explanation"));

	scriptLabel = new JLabel(s("scriptlabel"));
	script = new EquellaSyntaxTextArea(100, 200);
	script.addFocusListener(this);
	script.addCaretListener(this);

	statusbar = new JStatusBar(EditorHelper.getStatusBarSpinner());
}
 
开发者ID:equella,项目名称:Equella,代码行数:36,代码来源:ScriptTab.java

示例11: init

import javax.swing.JCheckBox; //导入方法依赖的package包/类
@Override
public void init() {
    JCheckBox check = new JCheckBox("disable");
    check.addItemListener(this);

    this.label = new JLabel("message");
    this.label.setBorder(BorderFactory.createTitledBorder("label"));
    this.label.setEnabled(!check.isSelected());

    add(BorderLayout.NORTH, check);
    add(BorderLayout.CENTER, this.label);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test4129681.java

示例12: 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();
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:45,代码来源:ConvexHullPanel.java

示例13: make3DOptionPanel

import javax.swing.JCheckBox; //导入方法依赖的package包/类
private JPanel make3DOptionPanel() {
	JPanel omni = new JPanel(new BorderLayout());
	omni.setBorder(BorderFactory.createEmptyBorder(BORDER_SIZE,
			BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
	JPanel res = new JPanel(new SpringLayout());

	//FIRST ROW
	String[] renderMode = {SOLID, WIREFRAME, POINTS};
	renderModeComboBox = new JComboBox(renderMode);
	renderModeComboBox.addActionListener(this);
	res.add(new JLabel("Render mode"));
	res.add(renderModeComboBox);
	//SECOND ROW
	res.add(new JLabel("View labels"));
	showLabels3DBox = new JCheckBox(
			"", true);
	showLabels3DBox.addActionListener(this);
	showLabels3DBox.addChangeListener(this);
	showLabels3DBox.addItemListener(this);
	res.add(showLabels3DBox);
	//THIRD ROW
	res.add(new JLabel("Show only bottlenecks  "));
	showOnlyBottleneckBox = new JCheckBox(
			"", true);
	showOnlyBottleneckBox.addActionListener(this);
	showOnlyBottleneckBox.addChangeListener(this);
	showOnlyBottleneckBox.addItemListener(this);
	res.add(showOnlyBottleneckBox);
	//FOURTH ROW
	String stations[] = new String[data.getStations()+1];
	stations[0] = null;
	for (int i = 0; i < data.getStations(); i++)
		stations[i+1] = data.getStationNames()[i];
	stationList = new JComboBox(stations);
	stationList.addActionListener(this);
	res.add(new JLabel("Select"));
	res.add(new JScrollPane(stationList));
	SpringUtilities.makeCompactGrid(res, 4, 2, //rows, cols
			6, 6, //initX, initY
			6, 6);//xPad, yPad		
	
	//CENTER PANEL
	omni.add(res, BorderLayout.NORTH);
	omni.add(new JLabel(JabaConstants.CONVEX_HULL_VERTEX_EXPLANATION), BorderLayout.CENTER);
	omni.add(new JLabel("   "), BorderLayout.SOUTH);
	return omni;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:48,代码来源:ConvexHullPanel.java

示例14: BoardSlot

import javax.swing.JCheckBox; //导入方法依赖的package包/类
public BoardSlot(BoardPicker bp, String prompt) {
  this.prompt = prompt;
  picker = bp;
  boards = new JComboBox();
  boards.addItem(prompt);

  final String lbn[] = picker.getAllowableLocalizedBoardNames();
  for (String s : lbn) {
    boards.addItem(s);
  }
  boards.setSelectedIndex(lbn.length == 1 ? 1 : 0);
  boards.addActionListener(this);

  reverseCheckBox =
    new JCheckBox(Resources.getString("BoardPicker.flip")); //$NON-NLS-1$
  reverseCheckBox.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      if (getBoard() != null) {
        getBoard().setReversed(reverseCheckBox.isSelected());
        picker.repaint();
      }
    }
  });

  reverseCheckBox.setVisible(false);

  setLayout(new OverlayLayout(this));

  final JPanel p = new JPanel();
  final Box b = Box.createHorizontalBox();
  b.add(boards);
  b.add(reverseCheckBox);
  p.add(b);
  p.setOpaque(false);
  p.setAlignmentX(0.5F);
  final JLabel l = new JLabel(this);
  l.setAlignmentX(0.5F);

  add(p);
  add(l);

  actionPerformed(null);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:44,代码来源:BoardSlot.java

示例15: DrawFrame

import javax.swing.JCheckBox; //导入方法依赖的package包/类
public DrawFrame()
{
   super("Painter");
   
   // create a panel to store the components at the top of the frame
   JPanel topPanel = new JPanel();

   // create a combobox for choosing colors
   colorChoices = new JComboBox<String>(colorNames);
   colorChoices.addItemListener(this);
   topPanel.add(colorChoices);

   // create a combobox for choosing shapes
   shapeChoices = new JComboBox<String>(shapes);
   shapeChoices.addItemListener(this);
   topPanel.add(shapeChoices);      

   // create a checkbox to determine whether the shape is filled
   filledCheckBox = new JCheckBox("Filled");
   filledCheckBox.addItemListener(this);
   topPanel.add(filledCheckBox);

   // create a button for clearing the last drawing
   undoButton = new JButton("Undo");
   undoButton.addActionListener(this);
   topPanel.add(undoButton);
   
   // create a button for clearing all drawings
   clearButton = new JButton("Clear");
   clearButton.addActionListener(this);
   topPanel.add(clearButton);

   // add the top panel to the frame
   add(topPanel, BorderLayout.NORTH);
   
   // create a label for the status bar
   JLabel statusLabel = new JLabel("(0,0)");

   // add the status bar at the bottom
   add(statusLabel, BorderLayout.SOUTH);
         
   // create the DrawPanel with its status bar label
   drawPanel = new DrawPanel(statusLabel);
   
   add(drawPanel); // add the drawing area to the center      
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:47,代码来源:DrawFrame.java


注:本文中的javax.swing.JCheckBox.addItemListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。