本文整理汇总了Java中javax.swing.JScrollBar.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java JScrollBar.getValue方法的具体用法?Java JScrollBar.getValue怎么用?Java JScrollBar.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JScrollBar
的用法示例。
在下文中一共展示了JScrollBar.getValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adjustmentValueChanged
import javax.swing.JScrollBar; //导入方法依赖的package包/类
/**
* Listens to changes of the scroll bar of the text are showing the EULA text, enables the check
* box once the user scrolled to the end of the document.
*/
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
JScrollBar scrollBar = this.scrollPane.getVerticalScrollBar();
if (e.getSource() == scrollBar) {
// the maximum value of the scroll bar assumes that the content is
// not visible anymore, since this is not the case when scrolling
// to the end of the document (the last part is still visible),
// we have to include the visible amount in the comparison
int currentValue = scrollBar.getValue() + scrollBar.getVisibleAmount();
if (currentValue >= scrollBar.getMaximum()) {
// the user scrolled to the end of the document
this.acceptCheckBox.setEnabled(true);
this.acceptCheckBox.requestFocusInWindow();
}
}
}
示例2: print
import javax.swing.JScrollBar; //导入方法依赖的package包/类
public void print(String string) {
System.out.print(string);
Document document = this.textArea.getDocument();
final JScrollBar scrollBar = this.scrollPane.getVerticalScrollBar();
boolean shouldScroll = (scrollBar.getValue() + scrollBar.getSize().getHeight() +
MONOSPACED.getSize() * 2 > scrollBar.getMaximum());
try {
document.insertString(document.getLength(), string, null);
} catch (BadLocationException ignored) {
}
if (shouldScroll) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
scrollBar.setValue(2147483647);
}
});
}
}
示例3: appendText
import javax.swing.JScrollBar; //导入方法依赖的package包/类
public void appendText(final String str) {
if (!EventQueue.isDispatchThread()) {
throw new IllegalStateException("Method must be called on EDT!");
}
final JScrollBar scrollBar;
JScrollPane scrollPane = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, this);
if (scrollPane == null) {
scrollBar = null;
} else {
JScrollBar sb = scrollPane.getHorizontalScrollBar();
if (sb.getValue() + SCROLL_THRESHOLD >= sb.getMaximum()) {
scrollBar = sb;
} else {
scrollBar = null;
}
}
append(str);
if (scrollBar != null) {
scrollBar.setValue(scrollBar.getMaximum());
}
}
示例4: validateThird
import javax.swing.JScrollBar; //导入方法依赖的package包/类
public void validateThird() {
JViewport viewport = this.pane.getViewport();
JScrollBar scroller = this.pane.getHorizontalScrollBar();
if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
throw new Error("unexpected component orientation");
}
int value = scroller.getValue();
if (value != 0) {
throw new Error("unexpected scroll value");
}
int extent = viewport.getExtentSize().width;
if (extent != scroller.getVisibleAmount()) {
throw new Error("unexpected visible amount");
}
int size = viewport.getViewSize().width;
if (size != scroller.getMaximum()) {
throw new Error("unexpected maximum");
}
int pos = size - extent - value;
if (pos != viewport.getViewPosition().x) {
throw new Error("unexpected position");
}
}
示例5: rotate
import javax.swing.JScrollBar; //导入方法依赖的package包/类
/**
* Not Implemented.
*/
public void rotate(int direction) {
Dimension dim = getPreferredSize();
Rectangle rect = getVisibleRect();
if(dim.width>rect.width) rect.width = dim.width;
if(dim.height>rect.height) rect.height = dim.height;
if(proj instanceof CylindricalProjection ) return;
rotation += (direction>0) ? 1:3;
rotation &= 0x3;
JScrollBar hsb = scrollPane.getHorizontalScrollBar();
int x = hsb.getValue();
JScrollBar vsb = scrollPane.getVerticalScrollBar();
int y = vsb.getValue();
if(direction>0) {
hsb.setValue(dim.height - rect.height - y);
vsb.setValue(x);
} else {
hsb.setValue(y);
vsb.setValue(dim.width -rect.width - x);
}
revalidate();
repaint();
}
示例6: scroll
import javax.swing.JScrollBar; //导入方法依赖的package包/类
private static void scroll(JScrollBar scrollBar, MouseWheelEvent e) {
if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
int unitsToScroll = e.getUnitsToScroll();
int direction = unitsToScroll < 0 ? -1 : 1;
if (unitsToScroll != 0) {
int increment = scrollBar.getUnitIncrement(direction);
int oldValue = scrollBar.getValue();
int newValue = oldValue + increment * unitsToScroll;
newValue = Math.max(Math.min(newValue, scrollBar.getMaximum() -
scrollBar.getVisibleAmount()), scrollBar.getMinimum());
if (oldValue != newValue) scrollBar.setValue(newValue);
}
}
}
示例7: scroll
import javax.swing.JScrollBar; //导入方法依赖的package包/类
private static void scroll(JScrollBar scroller, MouseWheelEvent event) {
if (event.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
int direction = event.getUnitsToScroll() < 0 ? -1 : 1;
int increment = scroller.getUnitIncrement(direction);
int amount = event.getScrollAmount();
int oldValue = scroller.getValue();
int newValue = oldValue + increment * amount * direction;
if (oldValue != newValue) scroller.setValue(newValue);
event.consume();
}
}
示例8: func_164247_a
import javax.swing.JScrollBar; //导入方法依赖的package包/类
public void func_164247_a(final JTextArea p_164247_1_, final JScrollPane p_164247_2_, final String p_164247_3_)
{
if (!SwingUtilities.isEventDispatchThread())
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
MinecraftServerGui.this.func_164247_a(p_164247_1_, p_164247_2_, p_164247_3_);
}
});
}
else
{
Document document = p_164247_1_.getDocument();
JScrollBar jscrollbar = p_164247_2_.getVerticalScrollBar();
boolean flag = false;
if (p_164247_2_.getViewport().getView() == p_164247_1_)
{
flag = (double)jscrollbar.getValue() + jscrollbar.getSize().getHeight() + (double)(serverGuiFont.getSize() * 4) > (double)jscrollbar.getMaximum();
}
try
{
document.insertString(document.getLength(), p_164247_3_, (AttributeSet)null);
}
catch (BadLocationException var8)
{
;
}
if (flag)
{
jscrollbar.setValue(Integer.MAX_VALUE);
}
}
}
示例9: mouseReleased
import javax.swing.JScrollBar; //导入方法依赖的package包/类
public void mouseReleased(MouseEvent e)
{
if (start != null)
{
if (zoomGesture)
{
double dx = e.getX() - start.getX();
double w = finderBounds.getWidth();
final JScrollBar hs = graphComponent
.getHorizontalScrollBar();
final double sx;
if (hs != null)
{
sx = (double) hs.getValue() / hs.getMaximum();
}
else
{
sx = 0;
}
final JScrollBar vs = graphComponent.getVerticalScrollBar();
final double sy;
if (vs != null)
{
sy = (double) vs.getValue() / vs.getMaximum();
}
else
{
sy = 0;
}
mxGraphView view = graphComponent.getGraph().getView();
double scale = view.getScale();
double newScale = scale - (dx * scale) / w;
double factor = newScale / scale;
view.setScale(newScale);
if (hs != null)
{
hs.setValue((int) (sx * hs.getMaximum() * factor));
}
if (vs != null)
{
vs.setValue((int) (sy * vs.getMaximum() * factor));
}
}
zoomGesture = false;
start = null;
}
}
示例10: mouseReleased
import javax.swing.JScrollBar; //导入方法依赖的package包/类
public void mouseReleased(MouseEvent e) {
if (start != null) {
if (zoomGesture) {
double dx = e.getX() - start.getX();
double w = finderBounds.getWidth();
final JScrollBar hs = graphComponent.getHorizontalScrollBar();
final double sx;
if (hs != null) {
sx = (double) hs.getValue() / hs.getMaximum();
} else {
sx = 0;
}
final JScrollBar vs = graphComponent.getVerticalScrollBar();
final double sy;
if (vs != null) {
sy = (double) vs.getValue() / vs.getMaximum();
} else {
sy = 0;
}
mxGraphView view = graphComponent.getGraph().getView();
double scale = view.getScale();
double newScale = scale - (dx * scale) / w;
double factor = newScale / scale;
view.setScale(newScale);
if (hs != null) {
hs.setValue((int) (sx * hs.getMaximum() * factor));
}
if (vs != null) {
vs.setValue((int) (sy * vs.getMaximum() * factor));
}
}
zoomGesture = false;
start = null;
}
}
示例11: appendLine
import javax.swing.JScrollBar; //导入方法依赖的package包/类
public void appendLine(final JTextArea textArea, final JScrollPane scrollPane, final String line)
{
try
{
latch.await();
} catch (InterruptedException e){} //Prevent logging until after constructor has ended.
if (!SwingUtilities.isEventDispatchThread())
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
MinecraftServerGui.this.appendLine(textArea, scrollPane, line);
}
});
}
else
{
Document document = textArea.getDocument();
JScrollBar jscrollbar = scrollPane.getVerticalScrollBar();
boolean flag = false;
if (scrollPane.getViewport().getView() == textArea)
{
flag = (double)jscrollbar.getValue() + jscrollbar.getSize().getHeight() + (double)(SERVER_GUI_FONT.getSize() * 4) > (double)jscrollbar.getMaximum();
}
try
{
document.insertString(document.getLength(), line, (AttributeSet)null);
}
catch (BadLocationException var8)
{
;
}
if (flag)
{
jscrollbar.setValue(Integer.MAX_VALUE);
}
}
}