本文整理匯總了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;
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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");
}
}
示例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;
}
示例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());
}
示例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);
}
}
示例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);
}
}