本文整理匯總了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);
}
}