Java Code Examples for javax.swing.BoundedRangeModel#getValue()
The following examples show how to use
javax.swing.BoundedRangeModel#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GanttChart.java From swift-k with Apache License 2.0 | 6 votes |
public void stateChanged(ChangeEvent e) { if (e.getSource() == scalesp) { scale = ((Number) scalesp.getValue()).doubleValue() * INITIAL_SCALE; repaint(); } else if (e.getSource() == hsb.getModel()) { BoundedRangeModel m = hsb.getModel(); if (offset != m.getValue()) { offset = m.getValue(); repaint(); } } else if (e.getSource() == csp.getVerticalScrollBar().getModel()) { if (scrollVerticallyOnNextUpdate) { scrollVerticallyOnNextUpdate = false; csp.getVerticalScrollBar().getModel().setValue(Integer.MAX_VALUE); } } }
Example 2
Source File: SheetAssembly.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
private DefaultBoundedRangeModel copy (BoundedRangeModel m) { return new DefaultBoundedRangeModel( m.getValue(), m.getExtent(), m.getMinimum(), m.getMaximum()); }
Example 3
Source File: SeaGlassScrollPaneUI.java From seaglass with Apache License 2.0 | 5 votes |
private void hsbStateChanged(JViewport viewport, ChangeEvent e) { BoundedRangeModel model = (BoundedRangeModel) (e.getSource()); Point p = viewport.getViewPosition(); int value = model.getValue(); if (scrollpane.getComponentOrientation().isLeftToRight()) { p.x = value; } else { int max = viewport.getViewSize().width; int extent = viewport.getExtentSize().width; int oldX = p.x; /* * Set new X coordinate based on "value". */ p.x = max - extent - value; /* * If setValue() was called before "extent" was fixed, turn * setValueCalled flag on. */ if ((extent == 0) && (value != 0) && (oldX == max)) { setValueCalled = true; } else { /* * When a pane without a horizontal scroll bar was reduced * and the bar appeared, the viewport should show the right * side of the view. */ if ((extent != 0) && (oldX < 0) && (p.x == 0)) { p.x += value; } } } viewport.setViewPosition(p); }
Example 4
Source File: GanttChart.java From swift-k with Apache License 2.0 | 5 votes |
protected void addJob(ApplicationItem ai) { Job j = new Job(ai); j.start(); jobmap.put(ai.getID(), j); jobs.add(j); BoundedRangeModel m = csp.getVerticalScrollBar().getModel(); if (m.getValue() + m.getExtent() == m.getMaximum()) { scrollVerticallyOnNextUpdate = true; } hmodel.fireTableRowsInserted(jobs.size(), jobs.size()); cmodel.fireTableRowsInserted(jobs.size(), jobs.size()); }
Example 5
Source File: BoundedRangeModel2DocumentAdapter.java From blog with Apache License 2.0 | 5 votes |
@Override public void stateChanged(ChangeEvent e) { BoundedRangeModel boundedRangeModel = (BoundedRangeModel) e .getSource(); Object[] formatArgs = new Object[] { boundedRangeModel.getValue() }; String text = format.format(formatArgs); try { document.remove(0, document.getLength()); document.insertString(0, text, null); } catch (BadLocationException e1) { } }
Example 6
Source File: SmartScroller.java From mars-sim with GNU General Public License v3.0 | 4 votes |
private void checkScrollBar(AdjustmentEvent e) { // The scroll bar listModel contains information needed to determine // whether the viewport should be repositioned or not. JScrollBar scrollBar = (JScrollBar)e.getSource(); BoundedRangeModel listModel = scrollBar.getModel(); int value = listModel.getValue(); int extent = listModel.getExtent(); int maximum = listModel.getMaximum(); boolean valueChanged = previousValue != value; boolean maximumChanged = previousMaximum != maximum; // Check if the user has manually repositioned the scrollbar if (valueChanged && !maximumChanged) { if (viewportPosition == START) adjustScrollBar = value != 0; else adjustScrollBar = value + extent >= maximum; } // Reset the "value" so we can reposition the viewport and // distinguish between a user scroll and a program scroll. // (ie. valueChanged will be false on a program scroll) if (adjustScrollBar && viewportPosition == END) { // Scroll the viewport to the end. scrollBar.removeAdjustmentListener( this ); value = maximum - extent; scrollBar.setValue( value ); scrollBar.addAdjustmentListener( this ); } if (adjustScrollBar && viewportPosition == START) { // Keep the viewport at the same relative viewportPosition scrollBar.removeAdjustmentListener( this ); value = value + maximum - previousMaximum; scrollBar.setValue( value ); scrollBar.addAdjustmentListener( this ); } previousValue = value; previousMaximum = maximum; }
Example 7
Source File: PenWidth.java From zxpoly with GNU General Public License v3.0 | 4 votes |
public int getValue() { final BoundedRangeModel model = this.currentModel.get(); return model == null ? -1 : model.getValue(); }
Example 8
Source File: SeaGlassScrollPaneUI.java From seaglass with Apache License 2.0 | 4 votes |
private void vsbStateChanged(JViewport viewport, ChangeEvent e) { BoundedRangeModel model = (BoundedRangeModel) (e.getSource()); Point p = viewport.getViewPosition(); p.y = model.getValue(); viewport.setViewPosition(p); }