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


Java Adjustable.VERTICAL屬性代碼示例

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


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

示例1: getVerticalScrollBar

public final JScrollBar getVerticalScrollBar(ColorPalette cp) {
	for(int index = 0; index<cp.getComponentCount(); index++) {
		Component comp = cp.getComponent(index);
		if(comp instanceof JScrollBar) {
			JScrollBar jsb = (JScrollBar)comp;
			if(jsb.getOrientation()==Adjustable.VERTICAL) {
				return jsb;
			}
		}
	}
	
	int max = getVerticalScrollMax(cp);
	if(max>1) {
		JScrollBar vBar = new JScrollBar(Adjustable.VERTICAL, 0, 0, 0, max);
		vBar.addAdjustmentListener(scrollBarListener);
		cp.add(vBar);
		vBar.putClientProperty("JComponent.sizeVariant", "mini");
		vBar.setCursor(Cursor.getDefaultCursor());
		updateScrollBarBounds(cp);
		return vBar;
	}
	
	
	return null;
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:25,代碼來源:ScrollableColorPaletteUI.java

示例2: scrollBy

/**
 * Scroll by.
 *
 * @param orientation
 *            the orientation
 * @param offset
 *            the offset
 */
public void scrollBy(int orientation, int offset) {
	RBlockViewport bodyLayout = this.bodyLayout;
	if (bodyLayout != null) {
		switch (orientation) {
		case Adjustable.HORIZONTAL:
			this.scrollHorizontalTo(bodyLayout.x - offset);
			break;
		case Adjustable.VERTICAL:
			this.scrollVerticalTo(bodyLayout.y - offset);
			break;
		default:
			break;
		}
	}
}
 
開發者ID:oswetto,項目名稱:LoboEvolution,代碼行數:23,代碼來源:RBlock.java

示例3: scrollToSBValue

/**
 * Scroll to sb value.
 *
 * @param orientation
 *            the orientation
 * @param value
 *            the value
 */
private void scrollToSBValue(int orientation, int value) {
	Insets insets = this.getInsets(this.hasHScrollBar, this.hasVScrollBar);
	switch (orientation) {
	case Adjustable.HORIZONTAL:
		int xOrigin = insets.left - value;
		this.scrollHorizontalTo(xOrigin);
		break;
	case Adjustable.VERTICAL:
		int yOrigin = insets.top - value;
		this.scrollVerticalTo(yOrigin);
		break;
	default:
		break;
	}
}
 
開發者ID:oswetto,項目名稱:LoboEvolution,代碼行數:23,代碼來源:RBlock.java

示例4: isAdjNeeded

/**
 * Determines whether a specified adjustable should
 * be displayed using scrollbar display policy
 * @param adj scrollbar
 * @return true if scrollbar should be displayed, false otherwise
 */
private boolean isAdjNeeded(Adjustable adj) {
    if (adj == null) {
        return false;
    }
    switch (scrollable.getAdjustableMode(adj)) {
        case Scrollable.ALWAYS:
            return true;
        case Scrollable.NEVER:
            return false;
        case Scrollable.AS_NEEDED:
            return calculateNeeded(adj);
        case Scrollable.HORIZONTAL_ONLY:
            return adj.getOrientation() == Adjustable.HORIZONTAL;
        case Scrollable.VERTICAL_ONLY:
            return adj.getOrientation() == Adjustable.VERTICAL;
    }
    return true;
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:24,代碼來源:ScrollStateController.java

示例5: calculateNeeded

/**
 * Only for Scrollable.AS_NEEDED scrollbar display policy:
 *  determines if the specified scrollbar should be visible.
 *  Scrollbar is shown only if child component can be scrolled in
 *  corresponding direction, i. e. the size of the child exceeds
 *  container size, and there's enough space for
 *  scrollbar itself.
 * @param adj scrollbar
 * @return true if scrollbar is needed, false otherwise
 */
private boolean calculateNeeded(Adjustable adj) {
    Insets ins = scrollable.getInsets();
    Component comp = scrollable.getComponent();
    final int GAP = ins.left + ins.right;
    boolean isVertical = (adj.getOrientation() == Adjustable.VERTICAL);
    Dimension viewSize = comp.getSize();
    viewSize.width -= getHrzInsets(ins);
    viewSize.height -= getVrtInsets(ins);
    int viewWidth = viewSize.width;
    int viewHeight = viewSize.height;
    int spOtherSize = isVertical ? viewWidth : viewHeight;
    int spSize = isVertical ? viewHeight : viewWidth;

    int compSize = 0;
    int adjSize = (isVertical ? scrollable.getAdjustableWidth()
                             : scrollable.getAdjustableHeight());
    Dimension prefSize = scrollable.getSize();
    compSize = isVertical ? prefSize.height : prefSize.width;
    return ((spSize < compSize) && (spOtherSize > adjSize + GAP));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:30,代碼來源:ScrollStateController.java

示例6: testGetBlockIncrement

public void testGetBlockIncrement() throws Exception {
    assertEquals(10, bar.getBlockIncrement());
    bar = new JScrollBar(Adjustable.VERTICAL, 0, 32, 0, 150);
    assertEquals(32, bar.getBlockIncrement());
    assertEquals(bar.getModel().getExtent(), bar.getBlockIncrement());
    propertyChangeController = new PropertyChangeController();
    bar.addPropertyChangeListener(propertyChangeController);
    bar.setBlockIncrement(40);
    assertTrue(propertyChangeController.isChanged("blockIncrement"));
    propertyChangeController.reset();
    bar.setBlockIncrement(40);
    assertFalse(propertyChangeController.isChanged("blockIncrement"));
    assertEquals(40, bar.getBlockIncrement());
    assertEquals(32, bar.getModel().getExtent());
    bar.setValues(0, 50, 0, 200);
    assertEquals(40, bar.getBlockIncrement());
    assertEquals(50, bar.getModel().getExtent());
    assertEquals(0, testList.size());
    assertEquals(40, bar.getBlockIncrement(1));
    assertEquals(40, bar.getBlockIncrement(-1));
    assertEquals(40, bar.getBlockIncrement(241));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:JScrollBarTest.java

示例7: calculateNeeded

/**
 * Only for Scrollable.AS_NEEDED scrollbar display policy:
 *  determines if the specified scrollbar should be visible.
 *  Scrollbar is shown only if child component can be scrolled in
 *  corresponding direction, i. e. the size of the child exceeds
 *  container size, and there's enough space for
 *  scrollbar itself.
 * @param adj scrollbar
 * @return true if scrollbar is needed, false otherwise
 */
private boolean calculateNeeded(Adjustable adj) {
    Insets ins = scrollable.getInsets();
    Component comp = scrollable.getComponent();
    final int GAP = ins.left + ins.right;
    boolean isVertical = (adj.getOrientation() == Adjustable.VERTICAL);
    Dimension viewSize = comp.getSize();
    viewSize.width -= getHrzInsets(ins);
    viewSize.height -= getVrtInsets(ins);
    int viewWidth = viewSize.width;
    int viewHeight = viewSize.height;
    int spOtherSize = isVertical ? viewWidth : viewHeight;
    int spSize = isVertical ? viewHeight : viewWidth;

    int compSize = 0;
    int adjSize = (isVertical ? scrollable.getAdjustableWidth()
                             : scrollable.getAdjustableHeight());
    if (comp != null) {
        Dimension prefSize = scrollable.getSize();
        compSize = isVertical ? prefSize.height
                             : prefSize.width;
    }
    return ((spSize < compSize) &&
            (spOtherSize > adjSize + GAP));
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:34,代碼來源:ScrollStateController.java

示例8: getPreferredSize

@Override
public Dimension getPreferredSize(JComponent c) {
	if (this.scrollbar.getOrientation() == Adjustable.VERTICAL) {
		return new Dimension(SCROLLBAR_WIDTH, 53 + 10);
	} else {
		return new Dimension(100, SCROLLBAR_WIDTH);
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:8,代碼來源:ScrollBarUI.java

示例9: getMinimumSize

@Override
public Dimension getMinimumSize(JComponent c) {
	if (this.scrollbar.getOrientation() == Adjustable.VERTICAL) {
		return new Dimension(SCROLLBAR_WIDTH, 40);
	} else {
		return new Dimension(40, SCROLLBAR_WIDTH);
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:8,代碼來源:ScrollBarUI.java

示例10: isScrollbarVisible

/**
 * Tells if a scrollbar is visible.
 *
 * @param orientation {@code Adjustable.HORIZONTAL} or
 * {@code Adjustable.VERTICAL}
 * @return trus if the bar is visible.
 */
public boolean isScrollbarVisible(int orientation) {
    if (orientation == Adjustable.HORIZONTAL) {
        return getViewportSize().getHeight() < getHeight() - getHScrollbarHeight();
    } else if (orientation == Adjustable.VERTICAL) {
        return getViewportSize().getWidth() < getWidth() - getVScrollbarWidth();
    } else {
        return false;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:ScrollPaneOperator.java

示例11: performGesture

public void performGesture(Automaton automaton) {
    Point location = automaton.getPointerLocation();

    switch (direction) {
        case Adjustable.HORIZONTAL:
            automaton.mouseMove((int) (location.getX()) + pixels, (int) location.getY());
            break;
        case Adjustable.VERTICAL:
            automaton.mouseMove((int) location.getX(), (int) location.getY() + pixels);
            break;
        default:
            throw new Defect("Only allowed Adjustable.HORIZONTAL and Adjustable.VERTICAL");
    }
}
 
開發者ID:google-code-export,項目名稱:windowlicker,代碼行數:14,代碼來源:MouseMoveAbsoluteGesture.java

示例12: getVScrollBar

/**
 * Gets the v scroll bar.
 *
 * @return the v scroll bar
 */
private JScrollBar getVScrollBar() {
	JScrollBar sb = this.vScrollBar;
	if (sb == null) {
		// Should never go back to null
		sb = new JScrollBar(Adjustable.VERTICAL);
		sb.addAdjustmentListener(new LocalAdjustmentListener(Adjustable.VERTICAL));
		this.vScrollBar = sb;
	}
	return sb;
}
 
開發者ID:oswetto,項目名稱:LoboEvolution,代碼行數:15,代碼來源:RBlock.java

示例13: testGetSetHorizontalScrollBar

public void testGetSetHorizontalScrollBar() throws Exception {
    assertTrue(pane.getHorizontalScrollBar() instanceof JScrollPane.ScrollBar);
    JScrollBar sb = new JScrollBar(Adjustable.VERTICAL);
    pane.setHorizontalScrollBar(sb);
    assertEquals(sb, pane.getHorizontalScrollBar());
    assertTrue(propertyChangeController.isChanged("horizontalScrollBar"));
    assertEquals(Adjustable.VERTICAL, sb.getOrientation());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:8,代碼來源:JScrollPaneTest.java

示例14: getPreferredSize

@Override
public Dimension getPreferredSize(JComponent c) {
	if (this.scrollbar.getOrientation() == Adjustable.VERTICAL) {
		return new Dimension(18, 53 + 10);
	} else {
		return new Dimension(100, 18);
	}
}
 
開發者ID:rapidminer,項目名稱:rapidminer-5,代碼行數:8,代碼來源:ScrollBarUI.java

示例15: getMinimumSize

@Override
public Dimension getMinimumSize(JComponent c) {
	if (this.scrollbar.getOrientation() == Adjustable.VERTICAL) {
		return new Dimension(18, 40);
	} else {
		return new Dimension(40, 18);
	}
}
 
開發者ID:rapidminer,項目名稱:rapidminer-5,代碼行數:8,代碼來源:ScrollBarUI.java


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