Example usage for javax.swing DefaultBoundedRangeModel DefaultBoundedRangeModel

List of usage examples for javax.swing DefaultBoundedRangeModel DefaultBoundedRangeModel

Introduction

In this page you can find the example usage for javax.swing DefaultBoundedRangeModel DefaultBoundedRangeModel.

Prototype

public DefaultBoundedRangeModel() 

Source Link

Document

Initializes all of the properties with default values.

Usage

From source file:Main.java

public static void main(String[] args) {
    BoundedRangeModel model = new DefaultBoundedRangeModel();
    BlockedColorLayerUI layerUI = new BlockedColorLayerUI();
    JPanel p = new JPanel(new GridLayout(2, 1, 12, 12));

    p.add(new JLayer<JProgressBar>(new JProgressBar(model), layerUI));

    JPanel box = new JPanel();
    box.add(new JButton(new AbstractAction("+10") {
        private int i = 0;

        @Override/*from w ww .  ja v  a  2  s .  c  o m*/
        public void actionPerformed(ActionEvent e) {
            model.setValue(i = (i >= 100) ? 0 : i + 10);
        }
    }));

    p.repaint();

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(p, BorderLayout.NORTH);
    panel.add(box, BorderLayout.SOUTH);

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.getContentPane().add(panel);
    f.setSize(320, 240);
    f.setVisible(true);
}

From source file:Bounded.java

public Bounded() {
    try {/*w  w w . j  av a2s.c  o  m*/
        DefaultBoundedRangeModel model = new DefaultBoundedRangeModel();
        ChangeListener myListener = new MyChangeListener();
        model.addChangeListener(myListener);

        System.out.println(model.toString());
        System.out.println("Now setting minimum to 50 . . .");
        model.setMinimum(50);
        System.out.println(model.toString());
        System.out.println("Now setting maximum to 40 . . .");
        model.setMaximum(40);
        System.out.println(model.toString());
        System.out.println("Now setting maximum to 50 . . .");
        model.setMaximum(50);
        System.out.println(model.toString());
        System.out.println("Now setting extent to 30 . . .");
        model.setExtent(30);
        System.out.println(model.toString());

        System.out.println("Now setting several properties . . .");
        if (!model.getValueIsAdjusting()) {
            model.setValueIsAdjusting(true);
            System.out.println(model.toString());
            model.setMinimum(0);
            model.setMaximum(100);
            model.setExtent(20);
            model.setValueIsAdjusting(false);
        }
        System.out.println(model.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Sketch.java

public JogShuttle() {
    init(new DefaultBoundedRangeModel());
}

From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java

private JScrollBar createJScrollBar() {
    JScrollBar b = new JScrollBar(JScrollBar.HORIZONTAL);
    b.setModel(new DefaultBoundedRangeModel());
    b.setEnabled(false);/*www  . ja v  a2 s .  c o  m*/
    return b;
}

From source file:Sketch.java

public void setModel(BoundedRangeModel m) {
    BoundedRangeModel old = model;
    if (old != null)
        old.removeChangeListener(this);

    if (m == null)
        model = new DefaultBoundedRangeModel();
    else//from  w w  w . j  a  va 2s .co  m
        model = m;
    model.addChangeListener(this);

    firePropertyChange("model", old, model);
}

From source file:apidemo.PanScrollZoomDemo.java

/**
 * Creates a new demo instance.//w w w.j  a  va 2s.  c  om
 * 
 * @param frameTitle  the frame title.
 */
public PanScrollZoomDemo(final String frameTitle) {

    super(frameTitle);

    this.toolBar = createToolbar();
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(this.toolBar, BorderLayout.SOUTH);

    final JFreeChart chart = createChart();

    this.scrollBar.setModel(new DefaultBoundedRangeModel());
    recalcScrollBar(chart.getPlot());

    this.chartPanel = new ChartPanel(chart) {
        public void autoRangeBoth() {
            System.out.println("Use 'Fit all' button");
        }
    };

    chart.addChangeListener(this);

    // enable zoom
    actionPerformed(new ActionEvent(this, 0, ACTION_CMD_ZOOM_BOX));

    // MouseListeners for pan function
    this.chartPanel.addMouseListener(this);
    //        this.chartPanel.addMouseMotionListener(this);

    // remove popup menu to allow panning
    // with right mouse pressed
    this.chartPanel.setPopupMenu(null);

    getContentPane().add(this.chartPanel);
}

From source file:apidemo.PanScrollZoomDemo.java

/**
 * Creates the toolbar.//from w  w  w  .  j  av a2s. c om
 * 
 * @return the toolbar.
 */
private JToolBar createToolbar() {
    final JToolBar toolbar = new JToolBar();

    final ButtonGroup groupedButtons = new ButtonGroup();

    // ACTION_CMD_PAN
    this.panButton = new JToggleButton();
    prepareButton(this.panButton, ACTION_CMD_PAN, " Pan ", "Pan mode");
    groupedButtons.add(this.panButton);
    toolbar.add(this.panButton);

    // ACTION_CMD_ZOOM_BOX
    this.zoomButton = new JToggleButton();
    prepareButton(this.zoomButton, ACTION_CMD_ZOOM_BOX, " Zoom ", "Zoom mode");
    groupedButtons.add(this.zoomButton);
    this.zoomButton.setSelected(true); // no other makes sense after startup
    toolbar.add(this.zoomButton);

    // end of toggle-button group for select/pan/zoom-box
    toolbar.addSeparator();

    // ACTION_CMD_ZOOM_IN
    this.zoomInButton = new JButton();
    prepareButton(this.zoomInButton, ACTION_CMD_ZOOM_IN, " + ", "Zoom in");
    toolbar.add(this.zoomInButton);

    // ACTION_CMD_ZOOM_OUT
    this.zoomOutButton = new JButton();
    prepareButton(this.zoomOutButton, ACTION_CMD_ZOOM_OUT, " - ", "Zoom out");
    toolbar.add(this.zoomOutButton);

    // ACTION_CMD_ZOOM_TO_FIT
    this.fitButton = new JButton();
    prepareButton(this.fitButton, ACTION_CMD_ZOOM_TO_FIT, " Fit ", "Fit all");
    toolbar.add(this.fitButton);

    toolbar.addSeparator();

    this.scrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    //   int ht = (int) zoomButton.getPreferredSize().getHeight();
    //   scrollBar.setPreferredSize(new Dimension(0, ht));
    this.scrollBar.setModel(new DefaultBoundedRangeModel());

    toolbar.add(this.scrollBar);

    this.zoomOutButton.setEnabled(false);
    this.fitButton.setEnabled(false);
    this.scrollBar.setEnabled(false);

    toolbar.setFloatable(false);
    return toolbar;
}