Java Code Examples for javax.swing.JCheckBox#setModel()

The following examples show how to use javax.swing.JCheckBox#setModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupsPanel.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
@Override
public void onDataSetChange(DatasetEvent event) {
	Object src = event.getSource();
	if (src instanceof AppGroupDao) {
		removeAll();
		models.clear();
		AppGroupDao dao = (AppGroupDao) src;
		try {
			List<AppGroup> groups = dao.list();
			if (groups.size() > 0) {
				for (AppGroup ag : groups) {
					PayloadButtonModel<AppGroup> model = new PayloadButtonModel<AppGroup>(
							ag);
					JCheckBox button = new JCheckBox(ag.getName(), false);
					button.setModel(model);
					models.add(model);
					add(button);
				}
			}
			else {
				add(new JLabel(Messages.getString(ID.concat(".nogroups"))));
			}
			revalidate();
		}
		catch (SQLException e) {
		}
	}
}
 
Example 2
Source File: GroupListBuilder.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
protected void reload() {
	try {
		List<AppGroup> groups = globals.get(DatabaseManager.class)
				.get(AppGroupDao.class).list();
		container.removeAll();
		gbc.gridy = 0;
		String tmp = Messages.getString("GroupListBuilder.nogroups");
		if (groups.size() > 0) {
			tmp = Messages.getString("GroupListBuilder.groups");
		}
		gbc.insets = new Insets(10, 10, 10, 10);
		container.add(new JLabel(tmp), gbc);
		gbc.gridy++;
		gbc.insets = new Insets(2,20,2,2);
		for (AppGroup ag : groups) {
			JCheckBox cb = new JCheckBox(ag.getName());
			cb.setModel(new PayloadButtonModel<AppGroup>(ag));
			if (app != null && app.memberOf(ag)) {
				cb.setSelected(true);
			}
			cb.addActionListener(this);
			container.add(cb, gbc);

			gbc.gridy++;
		}

		gbc.weightx = 1;
		gbc.weighty = 1;
		container.add(spacer, gbc);
		gbc.weightx = 0;
		gbc.weighty = 0;
		container.revalidate();
	}
	catch (SQLException e) {
		e.printStackTrace();
	}
}
 
Example 3
Source File: ScopeProbePanel.java    From jsyn with Apache License 2.0 5 votes vote down vote up
public ScopeProbePanel(AudioScopeProbeView probeView) {
    this.audioScopeProbeView = probeView;
    setLayout(new BorderLayout());

    setBorder(BorderFactory.createLineBorder(Color.GRAY, 3));

    // Add a colored box to match the waveform color.
    JPanel colorPanel = new JPanel();
    colorPanel.setMinimumSize(new Dimension(40, 40));
    audioScopeProbe = probeView.getModel();
    colorPanel.setBackground(audioScopeProbe.getColor());
    add(colorPanel, BorderLayout.NORTH);

    // Knob for tweaking vertical range.
    verticalScaleKnob = new RotaryTextController(audioScopeProbeView.getWaveTraceView()
            .getVerticalRangeModel(), 5);
    add(verticalScaleKnob, BorderLayout.CENTER);
    verticalScaleKnob.setTitle("YScale");

    // Auto ranging checkbox.
    autoBox = new JCheckBox("Auto");
    autoScaleModel = audioScopeProbeView.getWaveTraceView().getAutoButtonModel();
    autoScaleModel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ToggleButtonModel model = (ToggleButtonModel) e.getSource();
            boolean enabled = !model.isSelected();
            System.out.println("Knob enabled = " + enabled);
            verticalScaleKnob.setEnabled(!model.isSelected());
        }
    });
    autoBox.setModel(autoScaleModel);
    add(autoBox, BorderLayout.SOUTH);

    verticalScaleKnob.setEnabled(!autoScaleModel.isSelected());

    setMinimumSize(new Dimension(80, 100));
    setPreferredSize(new Dimension(80, 150));
    setMaximumSize(new Dimension(120, 200));
}
 
Example 4
Source File: ScopeProbePanel.java    From jsyn with Apache License 2.0 5 votes vote down vote up
public ScopeProbePanel(AudioScopeProbeView probeView) {
    this.audioScopeProbeView = probeView;
    setLayout(new BorderLayout());

    setBorder(BorderFactory.createLineBorder(Color.GRAY, 3));

    // Add a colored box to match the waveform color.
    JPanel colorPanel = new JPanel();
    colorPanel.setMinimumSize(new Dimension(40, 40));
    audioScopeProbe = probeView.getModel();
    colorPanel.setBackground(audioScopeProbe.getColor());
    add(colorPanel, BorderLayout.NORTH);

    // Knob for tweaking vertical range.
    verticalScaleKnob = new RotaryTextController(audioScopeProbeView.getWaveTraceView()
            .getVerticalRangeModel(), 5);
    add(verticalScaleKnob, BorderLayout.CENTER);
    verticalScaleKnob.setTitle("YScale");

    // Auto ranging checkbox.
    autoBox = new JCheckBox("Auto");
    autoScaleModel = audioScopeProbeView.getWaveTraceView().getAutoButtonModel();
    autoScaleModel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ToggleButtonModel model = (ToggleButtonModel) e.getSource();
            boolean enabled = !model.isSelected();
            System.out.println("Knob enabled = " + enabled);
            verticalScaleKnob.setEnabled(!model.isSelected());
        }
    });
    autoBox.setModel(autoScaleModel);
    add(autoBox, BorderLayout.SOUTH);

    verticalScaleKnob.setEnabled(!autoScaleModel.isSelected());

    setMinimumSize(new Dimension(80, 100));
    setPreferredSize(new Dimension(80, 150));
    setMaximumSize(new Dimension(120, 200));
}