本文整理汇总了Java中javax.swing.BoundedRangeModel.addChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java BoundedRangeModel.addChangeListener方法的具体用法?Java BoundedRangeModel.addChangeListener怎么用?Java BoundedRangeModel.addChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.BoundedRangeModel
的用法示例。
在下文中一共展示了BoundedRangeModel.addChangeListener方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSlider
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
private JSlider createSlider(String title, final BoundedRangeModel model, JPanel p, GridBagConstraints gbc, final Runnable runnable) {
gbc.gridy++;
gbc.gridx = 0;
JLabel titleLabel = new JLabel(title);
p.add(titleLabel, gbc);
gbc.gridx = 1;
JSlider slider = new JSlider(model);
p.add(slider, gbc);
if (runnable != null) {
model.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) {
jobs.add(runnable);
}
});
}
return slider;
}
示例2: propertyChange
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
public void propertyChange(final PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (StringConstants.MODEL_PROPERTY_CHANGED.equals(propertyName)) {
BoundedRangeModel oldValue = (BoundedRangeModel)e.getOldValue();
if (oldValue != null) {
oldValue.removeChangeListener(hsbChangeListener);
}
BoundedRangeModel newValue = (BoundedRangeModel)e.getNewValue();
if (newValue != null) {
newValue.addChangeListener(hsbChangeListener);
}
} else if (StringConstants.COMPONENT_ORIENTATION.equals(propertyName)) {
hsbChangeListener.stateChanged(new ChangeEvent(e.getSource()));
}
}
示例3: propertyChange
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
public void propertyChange(final PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (StringConstants.COMPONENT_ORIENTATION.equals(propertyName)) {
uninstallKeyboardActions();
installKeyboardActions();
} else if (StringConstants.MODEL_PROPERTY_CHANGED.equals(propertyName)) {
BoundedRangeModel oldValue = (BoundedRangeModel)e.getOldValue();
if (oldValue != null) {
oldValue.removeChangeListener(modelListener);
}
BoundedRangeModel newValue = (BoundedRangeModel)e.getNewValue();
if (newValue != null) {
newValue.addChangeListener(modelListener);
}
}
if (scrollbar != null) {
scrollbar.revalidate();
scrollbar.repaint();
}
}
示例4: setProgress
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
private static ChangeListener setProgress(final ProgressHandle pHandle) {
final BoundedRangeModel progress = HeapProgress.getProgress();
ChangeListener cl = new ChangeListener() {
public void stateChanged(ChangeEvent e) {
pHandle.progress(progress.getValue());
}
};
progress.addChangeListener(cl);
return cl;
}
示例5: setProgress
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
private static void setProgress(final ProgressHandle pHandle, final int offset) {
final BoundedRangeModel progress = HeapProgress.getProgress();
progress.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
pHandle.progress(progress.getValue()+offset);
}
});
}
示例6: subscribeActual
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super ChangeEvent> observer) {
BoundedRangeModel w = widget;
ChangeEventConsumer aec = new ChangeEventConsumer(observer, w);
observer.onSubscribe(aec);
w.addChangeListener(aec);
if (aec.get() == null) {
aec.onDispose(w);
}
}
示例7: setModel
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
/**
* @param model
*/
public synchronized void setModel(final BoundedRangeModel model) {
if (this.model == model) { return; }
if (this.model != null) {
model.removeChangeListener(changeListener);
}
changeListener = createChangeListener();
model.addChangeListener(changeListener);
this.model = model;
this.repaint();
}
示例8: RotaryController
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
public RotaryController(BoundedRangeModel model) {
this.model = model;
setMinimumSize(new Dimension(50, 50));
setPreferredSize(new Dimension(50, 50));
addMouseListener(new MouseHandler());
addMouseMotionListener(new MouseMotionHandler());
model.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
repaint();
}
});
}
示例9: setModel
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
protected void setModel(BoundedRangeModel model) {
if (this.model != model) {
if (this.model != null) {
this.model.removeChangeListener(this);
}
this.model = model;
if (model != null) {
model.addChangeListener(this);
}
update(false);
}
}
示例10: VolumeSlider
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
/**
*
* Creates a new volume slider controlling the designated volume type (music or sound)
*
* @param type
* the sound type to control.
*
* @param demo
* the sound clip to play on each change. This clip represents an idea of how loud/soft the setting is
*
*/
public VolumeSlider(final SoundType type, final Clip demo) {
super();
final BoundedRangeModel model = new DefaultBoundedRangeModel(SoundSettings.getVolumePercentForType(type), 0, 0, 100) {
private static final long serialVersionUID = 1L;
};
model.addChangeListener(new ChangeListener() {
@Override public void stateChanged(ChangeEvent e) {
type.adjustPercentage(model.getValue() );
// Don't play demo sound unless slider has come to a rest, or that would get annoying real fast.
if (!(model.getValueIsAdjusting() ) && model.getValue() != 0) {
float gain = SoundUtils.resolveDecibelOffsetFromPercentage(model.getValue() );
FloatControl gainControl = (FloatControl) demo.getControl(FloatControl.Type.MASTER_GAIN);
gainControl.setValue(gain);
demo.stop();
demo.setFramePosition(0);
demo.start();
}
}
});
setModel(model);
setOpaque(false);
setBorder(null);
setUI(new MonkeyShinesSliderUI(this) );
}