本文整理匯總了Java中java.awt.Adjustable.getOrientation方法的典型用法代碼示例。如果您正苦於以下問題:Java Adjustable.getOrientation方法的具體用法?Java Adjustable.getOrientation怎麽用?Java Adjustable.getOrientation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Adjustable
的用法示例。
在下文中一共展示了Adjustable.getOrientation方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isAdjNeeded
import java.awt.Adjustable; //導入方法依賴的package包/類
/**
* 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;
}
示例2: calculateNeeded
import java.awt.Adjustable; //導入方法依賴的package包/類
/**
* 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));
}
示例3: calculateNeeded
import java.awt.Adjustable; //導入方法依賴的package包/類
/**
* 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));
}
示例4: setUnitIncrement
import java.awt.Adjustable; //導入方法依賴的package包/類
public void setUnitIncrement (Adjustable adj, int u)
{
if (adj.getOrientation()==Adjustable.HORIZONTAL)
gtkScrolledWindowSetHScrollIncrement (u);
else
gtkScrolledWindowSetVScrollIncrement (u);
}
示例5: adjustmentValueChanged
import java.awt.Adjustable; //導入方法依賴的package包/類
@Override
public void adjustmentValueChanged(AdjustmentEvent evt) {
Adjustable source = evt.getAdjustable();
// getValueIsAdjusting() returns true if the user is currently
// dragging the scrollbar's knob and has not picked a final value
if (evt.getValueIsAdjusting()) {
// The user is dragging the knob
return;
} else {
((javax.swing.JScrollBar) source).getParent().repaint();
}
// Determine which scrollbar fired the event
int orient = source.getOrientation();
if (orient == Adjustable.HORIZONTAL) {
// Event from horizontal scrollbar
} else {
// Event from vertical scrollbar
}
// Determine the type of event
int type = evt.getAdjustmentType();
switch (type) {
case AdjustmentEvent.UNIT_INCREMENT:
// Scrollbar was increased by one unit
break;
case AdjustmentEvent.UNIT_DECREMENT:
// Scrollbar was decreased by one unit
break;
case AdjustmentEvent.BLOCK_INCREMENT:
// Scrollbar was increased by one block
break;
case AdjustmentEvent.BLOCK_DECREMENT:
// Scrollbar was decreased by one block
break;
case AdjustmentEvent.TRACK:
// The knob on the scrollbar was dragged
break;
}
// Get current value
//int value = evt.getValue();
}
示例6: adjustmentValueChanged
import java.awt.Adjustable; //導入方法依賴的package包/類
public void adjustmentValueChanged(AdjustmentEvent evt) {
Adjustable source = evt.getAdjustable();
// getValueIsAdjusting() returns true if the user is currently
// dragging the scrollbar's knob and has not picked a final value
if (evt.getValueIsAdjusting()) {
// The user is dragging the knob
return;
} else {
((javax.swing.JScrollBar) source).getParent().repaint();
}
// Determine which scrollbar fired the event
int orient = source.getOrientation();
if (orient == Adjustable.HORIZONTAL) {
// Event from horizontal scrollbar
} else {
// Event from vertical scrollbar
}
// Determine the type of event
int type = evt.getAdjustmentType();
switch (type) {
case AdjustmentEvent.UNIT_INCREMENT:
// Scrollbar was increased by one unit
break;
case AdjustmentEvent.UNIT_DECREMENT:
// Scrollbar was decreased by one unit
break;
case AdjustmentEvent.BLOCK_INCREMENT:
// Scrollbar was increased by one block
break;
case AdjustmentEvent.BLOCK_DECREMENT:
// Scrollbar was decreased by one block
break;
case AdjustmentEvent.TRACK:
// The knob on the scrollbar was dragged
break;
}
// Get current value
//int value = evt.getValue();
}
示例7: adjustmentValueChanged
import java.awt.Adjustable; //導入方法依賴的package包/類
public void adjustmentValueChanged(AdjustmentEvent evt) {
Adjustable source = evt.getAdjustable();
// getValueIsAdjusting() returns true if the user is currently
// dragging the scrollbar's knob and has not picked a final value
//if (evt.getValueIsAdjusting()) {
// The user is dragging the knob
// do not return...
//return;
//}
// Determine which scrollbar fired the event
int orient = source.getOrientation();
if (orient == Adjustable.HORIZONTAL) {
// Event from horizontal scrollbar
} else {
// Event from vertical scrollbar
}
// Determine the type of event
int type = evt.getAdjustmentType();
switch (type) {
case AdjustmentEvent.UNIT_INCREMENT:
// Scrollbar was increased by one unit
break;
case AdjustmentEvent.UNIT_DECREMENT:
// Scrollbar was decreased by one unit
break;
case AdjustmentEvent.BLOCK_INCREMENT:
// Scrollbar was increased by one block
break;
case AdjustmentEvent.BLOCK_DECREMENT:
// Scrollbar was decreased by one block
break;
case AdjustmentEvent.TRACK:
// The knob on the scrollbar was dragged
break;
}
// Get current value
int value = evt.getValue();
triggerScrolled(source,value);
}