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


Java JScrollBar.getModel方法代碼示例

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


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

示例1: maintainScrollBar

import javax.swing.JScrollBar; //導入方法依賴的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: scrollToCenter

import javax.swing.JScrollBar; //導入方法依賴的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

示例3: maintainScrollBar

import javax.swing.JScrollBar; //導入方法依賴的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

示例4: scrollToCenter

import javax.swing.JScrollBar; //導入方法依賴的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

示例5: checkScrollBar

import javax.swing.JScrollBar; //導入方法依賴的package包/類
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 scrollBarModel = scrollBar.getModel();
    int value = scrollBarModel.getValue();
    int extent = scrollBarModel.getExtent();
    int maximum = scrollBarModel.getMaximum();

    boolean valueChanged = previousScrollBarValue != value;
    boolean maximumChanged = previousScrollBarMaximum != maximum;

    //  Check if the user has manually repositioned the scrollbar
    if (valueChanged && !maximumChanged) {
        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) {
        //  Scroll the viewport to the end.
        scrollBar.removeAdjustmentListener(scrollBarAdjustmentListener);
        value = maximum - extent;
        scrollBar.setValue(value);
        scrollBar.addAdjustmentListener(scrollBarAdjustmentListener);
    }

    previousScrollBarValue = value;
    previousScrollBarMaximum = maximum;
}
 
開發者ID:chipKIT32,項目名稱:chipKIT-importer,代碼行數:33,代碼來源:SerialMonitorDisplayPane.java


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