本文整理汇总了Java中javax.swing.BoundedRangeModel.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java BoundedRangeModel.setValue方法的具体用法?Java BoundedRangeModel.setValue怎么用?Java BoundedRangeModel.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.BoundedRangeModel
的用法示例。
在下文中一共展示了BoundedRangeModel.setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: maintainScrollBar
import javax.swing.BoundedRangeModel; //导入方法依赖的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);
}
}
示例2: scrollRectToVisible
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
/**
* Horizontally scrolls text to make specified rectangle
* visible. Uses bounded range model value for
* scrolling. Repaints TextField.
*/
@Override
void scrollRectToVisible(Rectangle r) {
final int x = r.x;
final Insets insets = getTextFieldKit().getInsets();
final BoundedRangeModel brm = getTextFieldKit().getHorizontalVisibility();
final int oldValue = brm.getValue();
final int width = getModelRect().width;
if (x > width - insets.right) {
final int newVal = oldValue + (x - width + insets.right) + 2;
brm.setValue(newVal);
repaint();
}
if (x < insets.left) {
brm.setValue(oldValue - (insets.left - x) - 2);
repaint();
}
}
示例3: scrollRectToVisible
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
/**
* Horizontally scrolls text to make specified rectangle
* visible. Uses bounded range model value for
* scrolling. Repaints TextField.
*/
@Override
void scrollRectToVisible(Rectangle r) {
int x = r.x;
Insets insets = getTextFieldKit().getInsets();
BoundedRangeModel brm = getTextFieldKit().getHorizontalVisibility();
int oldValue = brm.getValue();
int width = getModelRect().width;
if (x > width - insets.right) {
int newVal = oldValue + (x - width + insets.right) + 2;
brm.setValue(newVal);
repaint();
}
if (x < insets.left) {
brm.setValue(oldValue - (insets.left - x) - 2);
repaint();
}
}
示例4: componentResized
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
@Override
public void componentResized(ComponentEvent event) {
boolean adjustViewportToBottom = false;
BoundedRangeModel model = scrollBar.getModel();
if ((model.getValue() == model.getMaximum() - model.getExtent())
|| model.getExtent() >= model.getMaximum()) {
adjustViewportToBottom = true;
}
model.setExtent(viewport.getHeight());
model.setMaximum(viewport.getView().getHeight());
if (adjustViewportToBottom || !isActive) {
model.setValue(viewport.getView().getHeight() - viewport.getHeight());
}
}
示例5: setValue
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
private static void setValue(final BoundedRangeModel model, final int val) {
if (SwingUtilities.isEventDispatchThread()) {
model.setValue(val);
} else {
SwingUtilities.invokeLater(new Runnable() {
public void run() { model.setValue(val); }
});
}
}
示例6: scrollToCenter
import javax.swing.BoundedRangeModel; //导入方法依赖的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);
}
}
示例7: maintainScrollBar
import javax.swing.BoundedRangeModel; //导入方法依赖的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);
}
}
示例8: scrollToCenter
import javax.swing.BoundedRangeModel; //导入方法依赖的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);
}
}
示例9: maintainScrollBar
import javax.swing.BoundedRangeModel; //导入方法依赖的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);
}
}
示例10: scrollToCenter
import javax.swing.BoundedRangeModel; //导入方法依赖的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);
}
}
示例11: clear
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
public void clear() {
BoundedRangeModel progressModel = progressBar.getModel();
progressModel.setValue(0);
progressModel.setMinimum(0);
progressModel.setMaximum(0);
progressBar.setString("");
}
示例12: addMessage
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
/** thread safe. */
public void addMessage(final String message) {
final Runnable runner = () -> {
try {
final Document doc = text.getDocument();
// save history entry
final IEditDelegate delegate = frame.getEditDelegate();
final String error;
if (delegate == null) {
error = "You can only add comments during your turn";
} else {
error = delegate.addComment(message);
}
if (error != null) {
doc.insertString(doc.getLength(), error + "\n", italic);
}
} catch (final BadLocationException e) {
ClientLogger.logQuietly(e);
}
final BoundedRangeModel scrollModel = scrollPane.getVerticalScrollBar().getModel();
scrollModel.setValue(scrollModel.getMaximum());
};
// invoke in the swing event thread
if (SwingUtilities.isEventDispatchThread()) {
runner.run();
} else {
SwingUtilities.invokeLater(runner);
}
}
示例13: mouseDragged
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
public void mouseDragged(MouseEvent e) {
if (p == null) {
//do nothing
} else {
BoundedRangeModel hModel = scrollPane.getHorizontalModel();
BoundedRangeModel vModel = scrollPane.getVerticalModel();
hModel.setValue(hModel.getValue() + (p.x - e.getX()));
vModel.setValue(vModel.getValue() + (p.y - e.getY()));
}
}
示例14: setValueOnDragging
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
void setValueOnDragging(final MouseEvent e, final int currentMouseX, final int currentMouseY, final int initialModelValue) {
BoundedRangeModel model = scrollbar.getModel();
int extent = model.getExtent();
int viewSize = model.getMaximum() - model.getMinimum();
int availableScrollingSize = viewSize - extent;
int thumbSize = getThumbSize(Math.round(getTrackSize() * extent / viewSize));
int availableTrackSize = getTrackSize() - thumbSize;
int offset = getOffset(e, currentMouseX, currentMouseY);
int modelIncrement = availableTrackSize != 0 ? offset * availableScrollingSize / availableTrackSize : 0;
model.setValue(initialModelValue + modelIncrement);
}
示例15: updateScrollbar
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
private void updateScrollbar() {
if (null == scrollBar) {
return;
}
if (null == model || model.getSize() == 0) {
internalScrollbarValueIsAdjusting = true;
scrollBar.getModel().setRangeProperties(0, 0, 0, 0, false);
internalScrollbarValueIsAdjusting = false;
scrollBar.setEnabled(false);
return;
}
if (! scrollBar.isEnabled()) {
scrollBar.setEnabled(true);
}
int size = model.getSize();
int firstDispIdx = getFirstDisplayedIdx();
int displayedCount = getRowCount() * getColumnCount();
int lastDispIdx = firstDispIdx + displayedCount - 1;
if (lastDispIdx >= size) {
lastDispIdx = size - 1;
}
BoundedRangeModel scrollModel = scrollBar.getModel();
internalScrollbarValueIsAdjusting = true;
scrollModel.setMinimum(0);
scrollModel.setMaximum(size - 1);
scrollModel.setValue(firstDispIdx);
scrollModel.setExtent(displayedCount - 1);
internalScrollbarValueIsAdjusting = false;
scrollBar.setUnitIncrement(getColumnCount());
scrollBar.setBlockIncrement(displayedCount);
}