本文整理汇总了Java中javax.swing.ButtonModel.addChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java ButtonModel.addChangeListener方法的具体用法?Java ButtonModel.addChangeListener怎么用?Java ButtonModel.addChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ButtonModel
的用法示例。
在下文中一共展示了ButtonModel.addChangeListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setModel
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
public void setModel(ButtonModel model) {
ButtonModel oldModel = getModel();
if (oldModel != null) {
oldModel.removeChangeListener(this);
}
super.setModel(model);
ButtonModel newModel = getModel();
if (newModel != null) {
newModel.addChangeListener(this);
}
stateChanged(null);
}
示例2: LedViewer
import javax.swing.ButtonModel; //导入方法依赖的package包/类
/**
* LED-Viewer
* @param model Button
* @param editable editierbar?
* @param tooltip Tooltip
* @param colorWhenOn An-Farbe
*/
LedViewer(final ButtonModel model, boolean editable,
final String tooltip, Color colorWhenOn) {
setModel(model);
model.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
LedViewer.this.setToolTipText(
tooltip + " \u2013 " // Streckenstrich ("Minuszeichen")
+ (model.isSelected() ? "leuchtet" : "leuchtet nicht"));
}
});
setSelected(false); // um initialen Tooltip setzen zu lassen
setEnabled(editable);
// Farbverlaeufe setzen
double center = Math.round(RADIUS / 4.0);
double radius = Math.round(RADIUS / 2f);
paintWhenOn = new RoundGradientPaint(center, center,
reduceSaturation(colorWhenOn), radius, colorWhenOn);
paintWhenOff = new RoundGradientPaint(center, center,
colorWhenOn, radius, colorWhenOn.darker().darker());
}
示例3: setModel
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
public void setModel(ButtonModel model) {
ButtonModel oldModel = getModel();
if (oldModel != null) {
oldModel.removeChangeListener(this);
}
super.setModel(model);
ButtonModel newModel = getModel();
if (newModel != null) {
newModel.addChangeListener(this);
}
stateChanged(null);
}
示例4: subscribeActual
import javax.swing.ButtonModel; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super ChangeEvent> observer) {
ButtonModel w = widget;
ChangeEventConsumer aec = new ChangeEventConsumer(observer, w);
observer.onSubscribe(aec);
w.addChangeListener(aec);
if (aec.get() == null) {
aec.onDispose(w);
}
}