當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultBoundedRangeModel類代碼示例

本文整理匯總了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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:LiveEngineTest.java

示例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);
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:33,代碼來源:RangeOptionUI.java

示例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);
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:27,代碼來源:PercentageOptionUI.java

示例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);
   }
 
開發者ID:nomencurator,項目名稱:taxonaut,代碼行數:26,代碼來源:HierarchiesPane.java

示例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);
        }
    });
}
 
開發者ID:gstreamer-java,項目名稱:gstreamer1.x-java,代碼行數:27,代碼來源:PopupVolumeButton.java

示例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();
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:21,代碼來源:JTextFieldTest.java

示例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);
}
 
開發者ID:vishal-mittal,項目名稱:SOEN6471-FreeCol,代碼行數:31,代碼來源:RangeOptionUI.java

示例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);
}
 
開發者ID:vishal-mittal,項目名稱:SOEN6471-FreeCol,代碼行數:25,代碼來源:PercentageOptionUI.java

示例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);
//        }
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:DiscreteProgress.java

示例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;
    }
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:12,代碼來源:MultiThumbSlider.java

示例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);
		}
	};
}
 
開發者ID:Njol,項目名稱:Motunautr,代碼行數:10,代碼來源:MonitoredValue.java

示例12: copy

import javax.swing.DefaultBoundedRangeModel; //導入依賴的package包/類
private DefaultBoundedRangeModel copy (BoundedRangeModel m)
{
    return new DefaultBoundedRangeModel(
            m.getValue(),
            m.getExtent(),
            m.getMinimum(),
            m.getMaximum());
}
 
開發者ID:Audiveris,項目名稱:audiveris,代碼行數:9,代碼來源:SheetAssembly.java

示例13: SliderWithSpinnerModel

import javax.swing.DefaultBoundedRangeModel; //導入依賴的package包/類
/**
 * Constructs a new model. Precondition:
 * <code>minimum &lt;= value &lt;= 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));
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:15,代碼來源:SliderWithSpinner.java

示例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);
    }
}
 
開發者ID:borisf,項目名稱:classyshark-export,代碼行數:30,代碼來源:ClassySharkExporter.java

示例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();
}
 
開發者ID:CollapsedDom,項目名稱:Stud.IP-Client,代碼行數:8,代碼來源:ModernSlider.java


注:本文中的javax.swing.DefaultBoundedRangeModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。