本文整理了Java中javax.swing.JSlider.setModel()
方法的一些代码示例,展示了JSlider.setModel()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSlider.setModel()
方法的具体详情如下:
包路径:javax.swing.JSlider
类名称:JSlider
方法名:setModel
暂无
代码示例来源:origin: org.zaproxy/zap
/**
* Calling this method has <strong>no</strong> effect. It's using a custom {@code BoundedRangeModel}.
*/
@Override
public void setModel(BoundedRangeModel newModel) {
if (!(newModel instanceof PositiveValuesBoundedRangeModel)) {
return;
}
super.setModel(newModel);
}
代码示例来源:origin: antlr/intellij-plugin-v4
@NotNull
public static JSlider createTreeViewSlider(final UberTreeViewer viewer) {
JSlider scaleSlider;
if ( isTrackpadZoomSupported ) {
scaleSlider = new JSlider();
scaleSlider.setModel(((TrackpadZoomingTreeView) viewer).scaleModel);
}
else {
int sliderValue = (int) ((viewer.getScale() - 1.0) * 1000);
scaleSlider = new JSlider(JSlider.HORIZONTAL, -999, 1000, sliderValue);
scaleSlider.addChangeListener(
new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int v = ((JSlider) e.getSource()).getValue();
if ( viewer.hasTree() ) {
viewer.setScale(v/1000.0+1.0);
}
}
});
}
return scaleSlider;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-vmd-game
private void clearImagePreview() {
this.sliderWidth.removeChangeListener(this.sliderListener);
this.sliderHeight.removeChangeListener(this.sliderListener);
this.sliderWidth.setModel(new DefaultBoundedRangeModel());
this.sliderHeight.setModel(new DefaultBoundedRangeModel());
this.sliderWidth.setValue(0);
this.sliderHeight.setValue(0);
this.sliderWidth.addChangeListener(sliderListener);
this.sliderHeight.addChangeListener(sliderListener);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-vmd-game
private void clearImagePreview() {
this.sliderWidth.removeChangeListener(this.sliderListener);
this.sliderHeight.removeChangeListener(this.sliderListener);
this.sliderWidth.setModel(new DefaultBoundedRangeModel());
this.sliderHeight.setModel(new DefaultBoundedRangeModel());
this.sliderWidth.setValue(0);
this.sliderHeight.setValue(0);
this.sliderWidth.addChangeListener(sliderListener);
this.sliderHeight.addChangeListener(sliderListener);
}
代码示例来源:origin: stackoverflow.com
final JSlider slider = new JSlider();
slider.setModel(new MyBoundedRangeModel(0, 0, -100, 100));
ChangeListener l = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (e instanceof MyChangeEvent) {
MyChangeEvent me = (MyChangeEvent) e;
if (me.getChangedProperties().contains("value")) {
System.out.println("new value: " +
((BoundedRangeModel) e.getSource()).getValue());
}
if (me.getChangedProperties().contains("maximum")) {
System.out.println("new max: " +
((BoundedRangeModel) e.getSource()).getMaximum());
}
} else {
// do something else or nothing
}
}
};
slider.getModel().addChangeListener(l);
代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets
private void $completeSetup() {
allComponentsCreated = true;
if (log.isDebugEnabled()) {
log.debug(this);
}
// inline complete setup of $JPanel0
add($Table0, BorderLayout.NORTH);
add(slider, BorderLayout.SOUTH);
// inline complete setup of $Table0
$Table0.add(title, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
$Table0.add($JLabel0, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
$Table0.add(hour, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
$Table0.add(labelH, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
$Table0.add(minute, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
// apply 7 data bindings
JAXXUtil.applyDataBinding(this, $bindings.keySet());
// apply 5 property setters
minuteModel.setCalendarField(java.util.Calendar.MINUTE);
hour.setModel(new SpinnerNumberModel(0, 0, 23, 1));
minute.setModel(minuteModel);
slider.setModel(new DefaultBoundedRangeModel(0, 1, 0, 60 * 24));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-vmd-game
this.sliderWidth.setModel(modelWidth);
this.sliderHeight.setModel(modelHeight);
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime-swing-widget
private void $completeSetup() {
allComponentsCreated = true;
$JPanel0.add($Table1, BorderLayout.NORTH);
$JPanel0.add(slider, BorderLayout.SOUTH);
$Table1.add(title, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
$Table1.add($JLabel2, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
$Table1.add(hour, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
$Table1.add(labelH, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
$Table1.add(minute, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
applyDataBinding("title.text");
applyDataBinding("hour.enabled");
hour.setModel((new SpinnerNumberModel(0,0,23,1)));
applyDataBinding("hour.value");
applyDataBinding("minute.enabled");
minute.setModel((new SpinnerNumberModel(0,0,59,1)));
applyDataBinding("minute.value");
applyDataBinding("slider.enabled");
slider.setModel((new DefaultBoundedRangeModel(0,1,0,60*24)));
applyDataBinding("slider.value");
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/skinlf
/**
* Constructor for the ProgressTest object
*/
ProgressTest() {
setLayout(new BorderLayout());
final BoundedRangeModel model = new DefaultBoundedRangeModel(0, 0, 0, 100);
JProgressBar progress = new JProgressBar(model);
add("South", progress);
JSlider slider = new JSlider(model);
add("North", slider);
slider = new JSlider(JSlider.VERTICAL);
slider.setModel(model);
add("West", slider);
progress = new JProgressBar(JProgressBar.VERTICAL);
progress.setModel(model);
add("East", progress);
new Timer(50, new ActionListener() {
int counter = 0;
public void actionPerformed(ActionEvent e) {
if (model.getValue() >= 100) {
counter += 20;
if (counter >= 500) model.setValue(0);
} else {
model.setValue(model.getValue() + 2);
counter = 0;
}
}
}).start();
}
}
代码示例来源:origin: org.xworker/xworker_core
public static void createModel(ActionContext actionContext){
Thing self = (Thing) actionContext.get("self");
JSlider parent = (JSlider) actionContext.get("parent");
for(Thing child : self.getChilds()){
BoundedRangeModel l = (BoundedRangeModel) child.doAction("create", actionContext);
if(l != null){
parent.setModel(l);
break;
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-vmd-game
this.sliderWidth.setModel(new DefaultBoundedRangeModel());
this.sliderHeight.setModel(new DefaultBoundedRangeModel());
代码示例来源:origin: com.github.insubstantial/substance
/**
* Unconfigures a JSlider from this ColorSliderModel.
*/
public void unconfigureColorSlider(JSlider slider) {
if (slider.getClientProperty("ColorSliderModel") == this) {
// XXX - This creates a NullPointerException ??
//slider.setUI((SliderUI) UIManager.getUI(slider));
slider.setModel(new DefaultBoundedRangeModel());
slider.putClientProperty("ColorSliderModel", null);
slider.putClientProperty("ColorComponentIndex", null);
removeColorSlider(slider);
}
}
代码示例来源:origin: org.java.net.substance/substance
/**
* Unconfigures a JSlider from this ColorSliderModel.
*/
public void unconfigureColorSlider(JSlider slider) {
if (slider.getClientProperty("ColorSliderModel") == this) {
// XXX - This creates a NullPointerException ??
//slider.setUI((SliderUI) UIManager.getUI(slider));
slider.setModel(new DefaultBoundedRangeModel());
slider.putClientProperty("ColorSliderModel", null);
slider.putClientProperty("ColorComponentIndex", null);
removeColorSlider(slider);
}
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
/**
* Unconfigures a JSlider from this model.
*/
@Override
public void unconfigureSlider(JSlider slider) {
if (slider.getClientProperty("colorSliderModel") == this) {
// XXX - This creates a NullPointerException ??
//slider.setUI((SliderUI) UIManager.getUI(slider));
slider.setModel(new DefaultBoundedRangeModel());
slider.putClientProperty("colorSliderModel", null);
slider.putClientProperty("colorComponentIndex", null);
removeColorSlider(slider);
}
}
代码示例来源:origin: org.java.net.substance/substance
/**
* Configures a JSlider for this ColorSliderModel.
* If the JSlider is already configured for another ColorSliderModel,
* it is unconfigured first.
*/
public void configureColorSlider(int component, JSlider slider) {
if (slider.getClientProperty("ColorSliderModel") != null) {
((ColorSliderModel) slider.getClientProperty("ColorSliderModel"))
.unconfigureColorSlider(slider);
}
if ( ! (slider.getUI() instanceof ColorSliderUI)) {
slider.setUI(new ColorSliderUI(slider));
}
slider.setModel(getBoundedRangeModel(component));
slider.putClientProperty("ColorSliderModel", this);
slider.putClientProperty("ColorComponentIndex", new Integer(component));
addColorSlider(slider);
}
代码示例来源:origin: link-intersystems/blog
loadSpeedSlider.setPaintLabels(true);
loadSpeedSlider.setBounds(161, 12, 429, 43);
loadSpeedSlider.setModel(loadPersonsSpeedModel);
add(loadSpeedSlider);
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
/**
* Configures a JSlider for this model.
* If the JSlider is already configured for another model,
* it is unconfigured first.
*/
@Override
public void configureSlider(int componentIndex, JSlider slider) {
if (slider.getClientProperty("colorSliderModel") != null) {
((DefaultColorSliderModel) slider.getClientProperty("colorSliderModel")).unconfigureSlider(slider);
}
if (!(slider.getUI() instanceof ColorSliderUI)) {
slider.setUI((ColorSliderUI) ColorSliderUI.createUI(slider));
}
slider.setModel(getBoundedRangeModel(componentIndex));
slider.putClientProperty("colorSliderModel", this);
slider.putClientProperty("colorComponentIndex", componentIndex);
addColorSlider(slider);
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
/**
* Configures a JSlider for this model.
* If the JSlider is already configured for another model,
* it is unconfigured first.
*/
@Override
public void configureSlider(int componentIndex, JSlider slider) {
if (slider.getClientProperty("colorSliderModel") != null) {
((DefaultColorSliderModel) slider.getClientProperty("colorSliderModel")).unconfigureSlider(slider);
}
if (!(slider.getUI() instanceof PaletteColorSliderUI)) {
slider.setUI((PaletteColorSliderUI) PaletteColorSliderUI.createUI(slider));
}
BoundedRangeModel brm = getBoundedRangeModel(componentIndex);
slider.setModel(brm);
slider.putClientProperty("colorSliderModel", this);
slider.putClientProperty("colorComponentIndex", componentIndex);
addColorSlider(slider);
}
代码示例来源:origin: com.github.insubstantial/substance
/**
* Configures a JSlider for this ColorSliderModel.
* If the JSlider is already configured for another ColorSliderModel,
* it is unconfigured first.
*/
public void configureColorSlider(int component, JSlider slider) {
if (slider.getClientProperty("ColorSliderModel") != null) {
((ColorSliderModel) slider.getClientProperty("ColorSliderModel"))
.unconfigureColorSlider(slider);
}
if ( ! (slider.getUI() instanceof ColorSliderUI)) {
slider.setUI(new ColorSliderUI(slider));
slider.createStandardLabels(16);
}
slider.setModel(getBoundedRangeModel(component));
slider.putClientProperty("ColorSliderModel", this);
slider.putClientProperty("ColorComponentIndex", component);
addColorSlider(slider);
}
代码示例来源:origin: sc.fiji/bigdataviewer-core
private synchronized void setNumTimepointsSynchronized( final int numTimepoints )
{
if ( numTimepoints < 1 || state.getNumTimepoints() == numTimepoints )
return;
else if ( numTimepoints == 1 && state.getNumTimepoints() > 1 )
remove( sliderTime );
else if ( numTimepoints > 1 && state.getNumTimepoints() == 1 )
add( sliderTime, BorderLayout.SOUTH );
state.setNumTimepoints( numTimepoints );
if ( state.getCurrentTimepoint() >= numTimepoints )
{
final int timepoint = numTimepoints - 1;
state.setCurrentTimepoint( timepoint );
for ( final TimePointListener l : timePointListeners )
l.timePointChanged( timepoint );
}
sliderTime.setModel( new DefaultBoundedRangeModel( state.getCurrentTimepoint(), 0, 0, numTimepoints - 1 ) );
revalidate();
requestRepaint();
}
内容来源于网络,如有侵权,请联系作者删除!