本文整理汇总了Java中javax.swing.DefaultBoundedRangeModel类的典型用法代码示例。如果您正苦于以下问题:Java DefaultBoundedRangeModel类的具体用法?Java DefaultBoundedRangeModel怎么用?Java DefaultBoundedRangeModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultBoundedRangeModel类属于javax.swing包,在下文中一共展示了DefaultBoundedRangeModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIsKnown
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
public void testIsKnown() {
class M extends DefaultBoundedRangeModel {
@Override
public void setValue(int n) {
super.setValue(n);
if (n > 10) {
super.setValue(10);
throw new CancelException();
}
}
}
M model = new M();
LiveEngine instance = new LiveEngine(model);
Map<?,?> path = instance.trace(Collections.singleton(last), Collections.<Object>singleton(list));
assertEquals("Model stops at 10", 10, model.getValue());
assertEquals("No path found", null, path);
}
示例2: RangeOptionUI
import javax.swing.DefaultBoundedRangeModel; //导入依赖的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);
}
示例3: PercentageOptionUI
import javax.swing.DefaultBoundedRangeModel; //导入依赖的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);
}
示例4: HierarchiesPane
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
public HierarchiesPane(int tabPlacement, Locale locale, boolean child)
{
super(tabPlacement);
addMouseListener(this);
popupMenu = new JPopupMenu();
if(child) {
swapMenuItem = new JMenuItem("Swap comparator", KeyEvent.VK_S);
addMenuItem(swapMenuItem);
} else {
openMenuItem = new JMenuItem("Move to new window", KeyEvent.VK_W);
addMenuItem(openMenuItem);
}
//int h = getHeight();
int h = getPreferredSize().height;
if(h > 0)
h -= thumbWidth * 2;
if(h < thumbWidth)
h = 2 * thumbWidth;
splitter = new DefaultBoundedRangeModel((h + 1)/2, 0, 0, h);
splitter.addChangeListener(this);
setLocale(locale);
}
示例5: PopupVolumeButton
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
public PopupVolumeButton(final PlayBin playbin) {
this(new DefaultBoundedRangeModel() {
private static final long serialVersionUID = 1462054216375236024L;
@Override
public int getMaximum() {
return 100;
}
@Override
public int getMinimum() {
return 0;
}
@Override
public int getValue() {
return (int) ((playbin.getVolume() * 100.0) + 0.5);
}
@Override
public void setValue(int percent) {
playbin.setVolume(Math.max(Math.min((double) percent, 100d), 0d) / 100.0d);
}
});
}
示例6: testgetHorizontalVisibility
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
public Result testgetHorizontalVisibility() {
InstrumentedJTextField ijt = new InstrumentedJTextField();
InstrumentedUILog.clear();
if (!ijt.getHorizontalVisibility().getClass().equals(DefaultBoundedRangeModel.class)) {
return failed ("getHorizontalVisibility returns a wrong type value");
}
InstrumentedUILog.clear();
if (ijt.getHorizontalVisibility() == null) {
return failed("getHorizontalVisibility returns null");
}
if (!InstrumentedUILog
.equals(new Object[][] {
{ "JTextField.getHorizontalVisibility"},
} )) {
InstrumentedUILog.printLogAsArray();
return failed("expected getHorizontalVisibility not to call any additional methods");
}
return passed();
}
示例7: RangeOptionUI
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
/**
* Creates a new <code>RangeOptionUI</code> for the given
* <code>RangeOption</code>.
*
* @param option The <code>RangeOption</code> to make a user interface for
* @param editable boolean whether user can modify the setting
*/
public RangeOptionUI(GUI gui, final RangeOption option, boolean editable) {
super(gui, option, editable);
JSlider slider = getComponent();
slider.setModel(new DefaultBoundedRangeModel(option.getValueRank(), 0, 0, option.getItemValues().size() - 1));
Hashtable<Integer, JComponent> labels = new Hashtable<Integer, JComponent>();
int index = 0;
for (String string : option.getItemValues().values()) {
if (option.localizeLabels()) {
labels.put(index, new JLabel(Messages.message(string)));
} else {
labels.put(index, new JLabel(string));
}
index++;
}
slider.setLabelTable(labels);
slider.setValue(option.getValueRank());
slider.setMajorTickSpacing(1);
slider.setSnapToTicks(true);
}
示例8: PercentageOptionUI
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
/**
* Creates a new <code>PercentageOptionUI</code> for the given
* <code>PercentageOption</code>.
*
* @param option The <code>PercentageOption</code> to make a user interface for
* @param editable boolean whether user can modify the setting
*/
public PercentageOptionUI(GUI gui, final PercentageOption option, boolean editable) {
super(gui, option, editable);
JSlider slider = getComponent();
slider.setModel(new DefaultBoundedRangeModel(option.getValue(), 0, 0, 100));
Hashtable<Integer, JComponent> labels = new Hashtable<Integer, JComponent>();
labels.put(new Integer(0), new JLabel("0 %"));
labels.put(new Integer(25), new JLabel("25 %"));
labels.put(new Integer(50), new JLabel("50 %"));
labels.put(new Integer(75), new JLabel("75 %"));
labels.put(new Integer(100), new JLabel("100 %"));
slider.setLabelTable(labels);
slider.setValue(option.getValue());
slider.setMajorTickSpacing(5);
slider.setSnapToTicks(false);
}
示例9: initComponents
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
private void initComponents() {
setLayout(new BorderLayout());
// if (UIUtils.isNimbus()) {
progressDelegateModel = new DefaultBoundedRangeModel(4, 1, 0, 10);
progressDelegate = new JProgressBar(progressDelegateModel);
add(progressDelegate, BorderLayout.CENTER);
// } else {
// setBorder(new ThinBevelBorder(BevelBorder.LOWERED));
// setOpaque(false);
// }
}
示例10: createThumbs
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
protected void createThumbs(int n) {
thumbNum = n;
sliderModels = new BoundedRangeModel[n];
thumbRenderers = new Icon[n];
fillColors = new Color[n];
for (int i = 0; i < n; i++) {
sliderModels[i] = new DefaultBoundedRangeModel(50, 0, 0, 100);
thumbRenderers[i] = null;
fillColors[i] = null;
}
}
示例11: createModel
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
public BoundedRangeModel createModel(final int min, final int max) {
return new DefaultBoundedRangeModel(value.get(), 0, min, max) {
@Override
public void setValue(final int n) {
super.setValue(n);
set(n);
}
};
}
示例12: copy
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
private DefaultBoundedRangeModel copy (BoundedRangeModel m)
{
return new DefaultBoundedRangeModel(
m.getValue(),
m.getExtent(),
m.getMinimum(),
m.getMaximum());
}
示例13: SliderWithSpinnerModel
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
/**
* Constructs a new model. Precondition:
* <code>minimum <= value <= maximum</code>.
*/
public SliderWithSpinnerModel(double value, double minimum,
double maximum, double increment, double precision) {
minimum = Math.min(minimum, value);
maximum = Math.max(maximum, value);
this.precision = precision;
this.increment = increment;
this.boundedRangeModel = new DefaultBoundedRangeModel(
(int) (value / precision), 0, (int) (minimum / precision),
(int) (maximum / precision));
}
示例14: ClassySharkExporter
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
public ClassySharkExporter(ClassySharkDumpStrategy dumpStrategy) {
super();
JFrame owner = new JFrame("ClassySharkExporter");
JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
int result = fileChooser.showOpenDialog(owner);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
final JDialog dialog = new JDialog(owner, "ClassyShark Exporter", true);
BoundedRangeModel model = new DefaultBoundedRangeModel();
JProgressBar progressBar = new JProgressBar(model);
dialog.add(progressBar);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.setResizable(false);
dialog.setPreferredSize(new Dimension(300, 100));
dialog.pack();
dialog.setLocationRelativeTo(owner);
BoundedRangeModelTask task = new BoundedRangeModelTask(model, dumpStrategy);
task.go(() -> dialog.setVisible(false), selectedFile);
dialog.setVisible(true);
dialog.dispose();
System.exit(0);
}
}
示例15: ModernSlider
import javax.swing.DefaultBoundedRangeModel; //导入依赖的package包/类
public ModernSlider(int orientation, int min, int max, int value) {
this.orientation = JSlider.HORIZONTAL;
sliderModel = new DefaultBoundedRangeModel(value, 0, min, max);
sliderModel.addChangeListener(changeListener);
updateUI();
init();
}