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


Java BoundedRangeModel.setValue方法代碼示例

本文整理匯總了Java中javax.swing.BoundedRangeModel.setValue方法的典型用法代碼示例。如果您正苦於以下問題:Java BoundedRangeModel.setValue方法的具體用法?Java BoundedRangeModel.setValue怎麽用?Java BoundedRangeModel.setValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.BoundedRangeModel的用法示例。


在下文中一共展示了BoundedRangeModel.setValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: maintainScrollBar

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 *
 */
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);
	}
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:19,代碼來源:mxGraphComponent.java

示例2: scrollRectToVisible

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 * Horizontally scrolls text to make specified rectangle
 * visible. Uses bounded range model value for
 * scrolling. Repaints TextField.
 */
@Override
void scrollRectToVisible(Rectangle r) {
    final int x = r.x;
    final Insets insets = getTextFieldKit().getInsets();
    final BoundedRangeModel brm = getTextFieldKit().getHorizontalVisibility();
    final int oldValue = brm.getValue();
    final int width = getModelRect().width;
    if (x > width - insets.right) {
        final int newVal = oldValue + (x - width + insets.right) + 2;
        brm.setValue(newVal);
        repaint();
    }
    if (x < insets.left) {
        brm.setValue(oldValue - (insets.left - x) - 2);
        repaint();
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:TextField.java

示例3: scrollRectToVisible

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 * Horizontally scrolls text to make specified rectangle
 * visible. Uses bounded range model value for
 * scrolling. Repaints TextField.
 */
@Override
void scrollRectToVisible(Rectangle r) {
    int x = r.x;
    Insets insets = getTextFieldKit().getInsets();
    BoundedRangeModel brm = getTextFieldKit().getHorizontalVisibility();
    int oldValue = brm.getValue();
    int width = getModelRect().width;
    if (x > width - insets.right) {
        int newVal = oldValue + (x - width + insets.right) + 2;
        brm.setValue(newVal);
        repaint();
    }
    if (x < insets.left) {
        brm.setValue(oldValue - (insets.left - x) - 2);
        repaint();
    }
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:23,代碼來源:TextField.java

示例4: componentResized

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
@Override
     public void componentResized(ComponentEvent event) {
boolean adjustViewportToBottom = false;

BoundedRangeModel model = scrollBar.getModel();
if ((model.getValue() == model.getMaximum() - model.getExtent())
		|| model.getExtent() >= model.getMaximum()) {
	adjustViewportToBottom = true;
}

model.setExtent(viewport.getHeight());
model.setMaximum(viewport.getView().getHeight());

if (adjustViewportToBottom || !isActive) {
	model.setValue(viewport.getView().getHeight() - viewport.getHeight());
}
     }
 
開發者ID:georgy,項目名稱:gmc,代碼行數:18,代碼來源:SplitTextPane.java

示例5: setValue

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
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); }
        });
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:HeapProgress.java

示例6: scrollToCenter

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 * 
 */
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);
	}
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:17,代碼來源:mxGraphComponent.java

示例7: maintainScrollBar

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 *
 */
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);
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:14,代碼來源:mxGraphComponent.java

示例8: scrollToCenter

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 * 
 */
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);
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:13,代碼來源:mxGraphComponent.java

示例9: maintainScrollBar

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 *
 */
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);
	}
}
 
開發者ID:md-k-sarker,項目名稱:OWLAx,代碼行數:14,代碼來源:mxGraphComponent.java

示例10: scrollToCenter

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 * 
 */
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);
	}
}
 
開發者ID:md-k-sarker,項目名稱:OWLAx,代碼行數:13,代碼來源:mxGraphComponent.java

示例11: clear

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
public void clear() {
	BoundedRangeModel progressModel = progressBar.getModel();
	progressModel.setValue(0);
	progressModel.setMinimum(0);
	progressModel.setMaximum(0);
	progressBar.setString("");
}
 
開發者ID:link-intersystems,項目名稱:GitDirStat,代碼行數:8,代碼來源:ProgressBarMonitor.java

示例12: addMessage

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/** thread safe. */
public void addMessage(final String message) {
  final Runnable runner = () -> {
    try {
      final Document doc = text.getDocument();
      // save history entry
      final IEditDelegate delegate = frame.getEditDelegate();
      final String error;
      if (delegate == null) {
        error = "You can only add comments during your turn";
      } else {
        error = delegate.addComment(message);
      }
      if (error != null) {
        doc.insertString(doc.getLength(), error + "\n", italic);
      }
    } catch (final BadLocationException e) {
      ClientLogger.logQuietly(e);
    }
    final BoundedRangeModel scrollModel = scrollPane.getVerticalScrollBar().getModel();
    scrollModel.setValue(scrollModel.getMaximum());
  };
  // invoke in the swing event thread
  if (SwingUtilities.isEventDispatchThread()) {
    runner.run();
  } else {
    SwingUtilities.invokeLater(runner);
  }
}
 
開發者ID:triplea-game,項目名稱:triplea,代碼行數:30,代碼來源:CommentPanel.java

示例13: mouseDragged

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
public void mouseDragged(MouseEvent e) {
    if (p == null) {
        //do nothing
    } else {
        BoundedRangeModel hModel = scrollPane.getHorizontalModel();
        BoundedRangeModel vModel = scrollPane.getVerticalModel();
        hModel.setValue(hModel.getValue() + (p.x - e.getX()));
        vModel.setValue(vModel.getValue() + (p.y - e.getY()));
    }
}
 
開發者ID:heqichen,項目名稱:openblocks,代碼行數:11,代碼來源:BlockCanvas.java

示例14: setValueOnDragging

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
void setValueOnDragging(final MouseEvent e, final int currentMouseX, final int currentMouseY, final int initialModelValue) {
    BoundedRangeModel model = scrollbar.getModel();
    int extent = model.getExtent();
    int viewSize = model.getMaximum() - model.getMinimum();
    int availableScrollingSize = viewSize - extent;
    int thumbSize = getThumbSize(Math.round(getTrackSize() * extent / viewSize));
    int availableTrackSize = getTrackSize() - thumbSize;
    int offset = getOffset(e, currentMouseX, currentMouseY);
    int modelIncrement = availableTrackSize != 0 ? offset * availableScrollingSize / availableTrackSize : 0;
    model.setValue(initialModelValue + modelIncrement);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:12,代碼來源:BasicScrollBarUI.java

示例15: updateScrollbar

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
private void updateScrollbar() {
    if (null == scrollBar) {
        return;
    }
    if (null == model || model.getSize() == 0) {
        internalScrollbarValueIsAdjusting = true;
        scrollBar.getModel().setRangeProperties(0, 0, 0, 0, false);
        internalScrollbarValueIsAdjusting = false;
        scrollBar.setEnabled(false);
        return;
    }
    if (! scrollBar.isEnabled()) {
        scrollBar.setEnabled(true);
    }
    int size = model.getSize();
    int firstDispIdx = getFirstDisplayedIdx();
    int displayedCount = getRowCount() * getColumnCount();
    int lastDispIdx = firstDispIdx + displayedCount - 1;
    if (lastDispIdx >= size) {
        lastDispIdx = size - 1;
    }
    BoundedRangeModel scrollModel = scrollBar.getModel();
    internalScrollbarValueIsAdjusting = true;
    scrollModel.setMinimum(0);
    scrollModel.setMaximum(size - 1);
    scrollModel.setValue(firstDispIdx);
    scrollModel.setExtent(displayedCount - 1);
    internalScrollbarValueIsAdjusting = false;
    scrollBar.setUnitIncrement(getColumnCount());
    scrollBar.setBlockIncrement(displayedCount);
}
 
開發者ID:Sofd,項目名稱:sofd_swing,代碼行數:32,代碼來源:JGridList.java


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