当前位置: 首页>>代码示例>>Java>>正文


Java JScrollPane.getHorizontalScrollBar方法代码示例

本文整理汇总了Java中javax.swing.JScrollPane.getHorizontalScrollBar方法的典型用法代码示例。如果您正苦于以下问题:Java JScrollPane.getHorizontalScrollBar方法的具体用法?Java JScrollPane.getHorizontalScrollBar怎么用?Java JScrollPane.getHorizontalScrollBar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JScrollPane的用法示例。


在下文中一共展示了JScrollPane.getHorizontalScrollBar方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: componentMoved

import javax.swing.JScrollPane; //导入方法依赖的package包/类
@Override
      public void componentMoved(ComponentEvent e) {
   if(timer == null) {
JScrollPane   scrollPane = getScrollPane();

if(scrollPane == null) {
    change();
              } else {
    scrollBar = scrollPane.getVerticalScrollBar();
    if(scrollBar == null || 
	!scrollBar.getValueIsAdjusting()) {
	// Try the horizontal scrollbar.
	if((scrollBar = scrollPane.getHorizontalScrollBar())
	    != null && scrollBar.getValueIsAdjusting()) {
                              
	    startTimer();
                      } else {
	    change();
                      }
    } else {
	startTimer();
                  }
}
   }
      }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:Outline.java

示例2: appendText

import javax.swing.JScrollPane; //导入方法依赖的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());
    }
}
 
开发者ID:pascalgn,项目名称:jiracli,代码行数:23,代码来源:ConsoleTextArea.java

示例3: scrollToTop

import javax.swing.JScrollPane; //导入方法依赖的package包/类
/**
 * Scrolls scroll pane to the top left corner.
 */
public static void scrollToTop(final JScrollPane scrollPane) {
	JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar();
	JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar();
	verticalScrollBar.setValue(verticalScrollBar.getMinimum());
	horizontalScrollBar.setValue(horizontalScrollBar.getMinimum());
}
 
开发者ID:igr,项目名称:swingspy,代码行数:10,代码来源:SwingUtil.java

示例4: propertyChange

import javax.swing.JScrollPane; //导入方法依赖的package包/类
public @Override void propertyChange(PropertyChangeEvent evt) {
    String propName = evt.getPropertyName();
    if ("document".equals(propName)) { // NOI18N
        BaseDocument newDoc = (evt.getNewValue() instanceof BaseDocument)
                              ? (BaseDocument)evt.getNewValue() : null;
        modelChanged(listenDoc, newDoc);

    } else if (EditorUI.OVERWRITE_MODE_PROPERTY.equals(propName)) {
        Boolean b = (Boolean)evt.getNewValue();
        overwriteMode = (b != null) ? b.booleanValue() : false;
        updateType();

    } else if ("ancestor".equals(propName) && evt.getSource() == component) { // NOI18N
        // The following code ensures that when the width of the line views
        // gets computed on background after the file gets opened
        // (so the horizontal scrollbar gets added after several seconds
        // for larger files) that the suddenly added horizontal scrollbar
        // will not hide the caret laying on the last line of the viewport.
        // A component listener gets installed into horizontal scrollbar
        // and if it's fired the caret's bounds will be checked whether
        // they intersect with the horizontal scrollbar
        // and if so the view will be scrolled.
        Container parent = component.getParent();
        if (parent instanceof JViewport) {
            parent = parent.getParent(); // parent of viewport
            if (parent instanceof JScrollPane) {
                JScrollPane scrollPane = (JScrollPane)parent;
                JScrollBar hScrollBar = scrollPane.getHorizontalScrollBar();
                if (hScrollBar != null) {
                    // Add weak listener so that editor pane could be removed
                    // from scrollpane without being held by scrollbar
                    hScrollBar.addComponentListener(
                            (ComponentListener)WeakListeners.create(
                            ComponentListener.class, listenerImpl, hScrollBar));
                }
            }
        }
    } else if ("enabled".equals(propName)) {
        Boolean enabled = (Boolean) evt.getNewValue();
        if(component.isFocusOwner()) {
            if(enabled == Boolean.TRUE) {
                if(component.isEditable()) {
                    setVisible(true);
                }
                setSelectionVisible(true);
            } else {
                setVisible(false);
                setSelectionVisible(false);
            }
        }
    } else if (RECTANGULAR_SELECTION_PROPERTY.equals(propName)) {
        boolean origRectangularSelection = rectangularSelection;
        rectangularSelection = Boolean.TRUE.equals(component.getClientProperty(RECTANGULAR_SELECTION_PROPERTY));
        if (rectangularSelection != origRectangularSelection) {
            if (rectangularSelection) {
                setRectangularSelectionToDotAndMark();
                RectangularSelectionTransferHandler.install(component);

            } else { // No rectangular selection
                RectangularSelectionTransferHandler.uninstall(component);
            }
            fireStateChanged();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:66,代码来源:BaseCaret.java

示例5: propertyChange

import javax.swing.JScrollPane; //导入方法依赖的package包/类
public @Override void propertyChange(PropertyChangeEvent evt) {
            String propName = evt.getPropertyName();
            JTextComponent c = component;
            if ("document".equals(propName)) { // NOI18N
                if (c != null) {
                    modelChanged(activeDoc, c.getDocument());
                }

            } else if (EditorUtilities.CARET_OVERWRITE_MODE_PROPERTY.equals(propName)) {
                Boolean b = (Boolean) evt.getNewValue();
                overwriteMode = (b != null) ? b : false;
                updateOverwriteModeLayer(true);
                updateType();

            } else if ("ancestor".equals(propName) && evt.getSource() == component) { // NOI18N
                // The following code ensures that when the width of the line views
                // gets computed on background after the file gets opened
                // (so the horizontal scrollbar gets added after several seconds
                // for larger files) that the suddenly added horizontal scrollbar
                // will not hide the caret laying on the last line of the viewport.
                // A component listener gets installed into horizontal scrollbar
                // and if it's fired the caret's bounds will be checked whether
                // they intersect with the horizontal scrollbar
                // and if so the view will be scrolled.
                Container parent = component.getParent();
                if(parent instanceof JLayeredPane) {
                    parent = parent.getParent();
                }
                if (parent instanceof JViewport) {
                    parent = parent.getParent(); // parent of viewport
                    if (parent instanceof JScrollPane) {
                        JScrollPane scrollPane = (JScrollPane) parent;
                        JScrollBar hScrollBar = scrollPane.getHorizontalScrollBar();
                        if (hScrollBar != null) {
                            // Add weak listener so that editor pane could be removed
                            // from scrollpane without being held by scrollbar
                            hScrollBar.addComponentListener(
                                    (ComponentListener) WeakListeners.create(
                                            ComponentListener.class, listenerImpl, hScrollBar));
                        }
                    }
                }
            } else if ("enabled".equals(propName)) {
                Boolean enabled = (Boolean) evt.getNewValue();
                if (component.isFocusOwner()) {
                    if (enabled == Boolean.TRUE) {
                        if (component.isEditable()) {
                            setVisible(true);
                        }
                        setSelectionVisible(true);
                    } else {
                        setVisible(false);
                        setSelectionVisible(false);
                    }
                }
            } else if (RECTANGULAR_SELECTION_PROPERTY.equals(propName)) {
                boolean origRectangularSelection = rectangularSelection;
                rectangularSelection = Boolean.TRUE.equals(component.getClientProperty(RECTANGULAR_SELECTION_PROPERTY));
                if (rectangularSelection != origRectangularSelection) {
                    if (rectangularSelection) {
                        setRectangularSelectionToDotAndMark();
//                        RectangularSelectionTransferHandler.install(component);

                    } else { // No rectangular selection
//                        RectangularSelectionTransferHandler.uninstall(component);
                    }
                    fireStateChanged(null);
                }
            }
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:71,代码来源:EditorCaret.java


注:本文中的javax.swing.JScrollPane.getHorizontalScrollBar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。