Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
cfb67a76cThis file is pinned to the selected release. Download the original to open it in your design tool.
package com.marginallyclever.makelangelo.select;
import javax.swing.*;
import java.awt.*;
/**
* A toggle button that does nothing until you attach an observer.
* @author Dan Royer
* @since 7.24.0
*/
public class SelectToggleButton extends Select {
/**
*
*/
private static final long serialVersionUID = 7096181261934634708L;
private final JToggleButton button;
public SelectToggleButton(String internalName, AbstractAction action) {
super(internalName);
button = new JToggleButton(action);
}
public SelectToggleButton(String internalName, String labelText) {
super(internalName);
button = new JToggleButton(labelText);
button.addActionListener((e) -> {
firePropertyChange(null,null);
});
this.add(button,BorderLayout.CENTER);
}
public void doClick() {
if(button!=null) button.doClick();
}
public void setText(String label) {
if(button!=null) button.setText(label);
}
public void setEnabled(boolean b) {
if(button!=null) button.setEnabled(b);
}
public void setForeground(Color fg) {
if(button!=null) button.setForeground(fg);
}
public boolean isSelected() {
return button.isSelected();
}
}