Java Code Examples for javax.swing.BoundedRangeModel#setValue()
The following examples show how to use
javax.swing.BoundedRangeModel#setValue() .
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: mxGraphComponent.java From blog-codes with Apache License 2.0 | 6 votes |
/** * */ protected void maintainScrollBar(boolean horizontal, double factor, boolean center) { JScrollBar scrollBar = (horizontal) ? getHorizontalScrollBar() : getVerticalScrollBar(); if (scrollBar != null) { BoundedRangeModel model = scrollBar.getModel(); int newValue = (int) Math.round(model.getValue() * factor) + (int) Math.round((center) ? (model.getExtent() * (factor - 1) / 2) : 0); model.setValue(newValue); } }
Example 2
Source File: mxGraphComponent.java From blog-codes with Apache License 2.0 | 5 votes |
/** * */ public void scrollToCenter(boolean horizontal) { JScrollBar scrollBar = (horizontal) ? getHorizontalScrollBar() : getVerticalScrollBar(); if (scrollBar != null) { final BoundedRangeModel model = scrollBar.getModel(); final int newValue = ((model.getMaximum()) / 2) - model.getExtent() / 2; model.setValue(newValue); } }
Example 3
Source File: HeapProgress.java From netbeans with Apache License 2.0 | 5 votes |
private static void setValue(final BoundedRangeModel model, final int val) { if (SwingUtilities.isEventDispatchThread()) { model.setValue(val); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { model.setValue(val); } }); } }
Example 4
Source File: HeapProgress.java From visualvm with GNU General Public License v2.0 | 5 votes |
private static void setValue(final BoundedRangeModel model, final int val) { if (SwingUtilities.isEventDispatchThread()) { model.setValue(val); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { model.setValue(val); } }); } }
Example 5
Source File: IteratingRule.java From netbeans with Apache License 2.0 | 4 votes |
public final void perform() { Heap heap = context.getHeap(); @SuppressWarnings("unchecked") List<JavaClass> classes = heap.getAllClasses(); List<JavaClass> matching = new ArrayList<JavaClass>(); int count = 0; for (JavaClass cls : classes) { if (classNamePattern.matcher(cls.getName()).matches()) { matching.add(cls); count += cls.getInstancesCount(); } if (context.isInterruped()) { return; } } BoundedRangeModel progress = context.getProgress(); progress.setMaximum((count != 0) ? count : 1); for (JavaClass actCls : matching) { @SuppressWarnings("unchecked") List<Instance> instances = actCls.getInstances(); for (Instance inst : instances) { Logger.getLogger(IteratingRule.class.getName()).log(Level.FINE, "Executing rule on {0} instance", inst); // NOI18N perform(inst); progress.setValue(progress.getValue() + 1); if (context.isInterruped()) { return; } } } if (count == 0) { progress.setValue(1); } summary(); }
Example 6
Source File: IteratingRule.java From visualvm with GNU General Public License v2.0 | 4 votes |
public final void perform() { Heap heap = context.getHeap(); @SuppressWarnings("unchecked") List<JavaClass> classes = heap.getAllClasses(); List<JavaClass> matching = new ArrayList<JavaClass>(); int count = 0; for (JavaClass cls : classes) { if (classNamePattern.matcher(cls.getName()).matches()) { matching.add(cls); count += cls.getInstancesCount(); } if (context.isInterruped()) { return; } } BoundedRangeModel progress = context.getProgress(); progress.setMaximum((count != 0) ? count : 1); for (JavaClass actCls : matching) { @SuppressWarnings("unchecked") List<Instance> instances = actCls.getInstances(); for (Instance inst : instances) { Logger.getLogger(IteratingRule.class.getName()).log(Level.FINE, "Executing rule on {0} instance", inst); // NOI18N perform(inst); progress.setValue(progress.getValue() + 1); if (context.isInterruped()) { return; } } } if (count == 0) { progress.setValue(1); } summary(); }