All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.actelion.research.gui.swing.SwingCheckBox Maven / Gradle / Ivy

There is a newer version: 2024.11.2
Show newest version
package com.actelion.research.gui.swing;

import com.actelion.research.gui.generic.GenericActionEvent;
import com.actelion.research.gui.generic.GenericCheckBox;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SwingCheckBox extends SwingComponent implements GenericCheckBox,ActionListener {
	private JCheckBox mCheckBox;

	public SwingCheckBox(String text) {
		super(new JCheckBox(text));
		mCheckBox = (JCheckBox)getComponent();
		mCheckBox.addActionListener(this);
	}

	@Override
	public boolean isSelected() {
		return mCheckBox.isSelected();
	}

	@Override
	public void setSelected(boolean b) {
		mCheckBox.setSelected(b);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		fireEvent(new GenericActionEvent(this, GenericActionEvent.WHAT_STATE_TOGGLED, ((JCheckBox)e.getSource()).isSelected() ? 1 : 0));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy