本文整理匯總了Java中javax.swing.JSlider.setModel方法的典型用法代碼示例。如果您正苦於以下問題:Java JSlider.setModel方法的具體用法?Java JSlider.setModel怎麽用?Java JSlider.setModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JSlider
的用法示例。
在下文中一共展示了JSlider.setModel方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: RangeOptionUI
import javax.swing.JSlider; //導入方法依賴的package包/類
/**
* Creates a new {@code RangeOptionUI} for the given
* {@code RangeOption}.
*
* @param option The {@code RangeOption} to make a user interface for
* @param editable boolean whether user can modify the setting
*/
public RangeOptionUI(final RangeOption option, boolean editable) {
super(option, editable);
JSlider slider = getComponent();
slider.setModel(new DefaultBoundedRangeModel(option.getValueRank(), 0,
0, option.getItemValues().size()-1));
Hashtable<Integer, JComponent> labels
= new Hashtable<>();
int index = 0;
for (String string : option.getItemValues().values()) {
if (option.localizeLabels()) {
labels.put(index, Utility.localizedLabel(string));
} else {
labels.put(index, new JLabel(string));
}
index++;
}
slider.setLabelTable(labels);
slider.setValue(option.getValueRank());
slider.setMajorTickSpacing(1);
slider.setSnapToTicks(true);
}
示例2: PercentageOptionUI
import javax.swing.JSlider; //導入方法依賴的package包/類
/**
* Creates a new {@code PercentageOptionUI} for the given
* {@code PercentageOption}.
*
* @param option The {@code PercentageOption} to make a user
* interface for.
* @param editable boolean whether user can modify the setting
*/
public PercentageOptionUI(final PercentageOption option, boolean editable) {
super(option, editable);
JSlider slider = getComponent();
slider.setModel(new DefaultBoundedRangeModel(option.getValue(), 0, 0, 100));
Hashtable<Integer, JComponent> labels
= new Hashtable<>();
labels.put(0, new JLabel("0 %"));
labels.put(25, new JLabel("25 %"));
labels.put(50, new JLabel("50 %"));
labels.put(75, new JLabel("75 %"));
labels.put(100, new JLabel("100 %"));
slider.setLabelTable(labels);
slider.setValue(option.getValue());
slider.setMajorTickSpacing(5);
slider.setSnapToTicks(false);
}
示例3: setupInstance
import javax.swing.JSlider; //導入方法依賴的package包/類
protected void setupInstance(JSlider instance) {
super.setupInstance(instance);
instance.setPaintTicks(paintTicks);
instance.setPaintTrack(paintTrack);
instance.setPaintLabels(paintLabels);
instance.setInverted(isInverted);
if (sliderModel != null) instance.setModel(sliderModel.createInstance());
instance.setMajorTickSpacing(majorTickSpacing);
instance.setMinorTickSpacing(minorTickSpacing);
instance.setSnapToTicks(snapToTicks);
}