⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jscrollpane.java

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    if (key == LOWER_RIGHT_CORNER)      {        removeNonNull(lowerRight);        lowerRight = c;        addNonNull(c, JScrollPane.LOWER_RIGHT_CORNER);      }    else if (key == UPPER_RIGHT_CORNER)      {        removeNonNull(upperRight);        upperRight = c;        addNonNull(c, JScrollPane.UPPER_RIGHT_CORNER);      }    else if (key == LOWER_LEFT_CORNER)      {        removeNonNull(lowerLeft);        lowerLeft = c;        addNonNull(c, JScrollPane.LOWER_LEFT_CORNER);      }    else if (key == UPPER_LEFT_CORNER)      {        removeNonNull(upperLeft);        upperLeft = c;        addNonNull(c, JScrollPane.UPPER_LEFT_CORNER);      }    else      throw new IllegalArgumentException("unknown corner " + key);    sync();  }  public void setHorizontalScrollBar(JScrollBar h)  {    if (horizontalScrollBar == h)      return;    JScrollBar old = horizontalScrollBar;    removeNonNull(old);    horizontalScrollBar = h;    addNonNull(h, JScrollPane.HORIZONTAL_SCROLLBAR);    firePropertyChange("horizontalScrollBar", old, h);    sync();  }  public void setHorizontalScrollBarPolicy(int h)  {    if (horizontalScrollBarPolicy == h)      return;        if (h != HORIZONTAL_SCROLLBAR_AS_NEEDED        && h != HORIZONTAL_SCROLLBAR_NEVER        && h != HORIZONTAL_SCROLLBAR_ALWAYS)      throw new IllegalArgumentException("unknown horizontal scrollbar policy");        int old = horizontalScrollBarPolicy;    horizontalScrollBarPolicy = h;    firePropertyChange("horizontalScrollBarPolicy", old, h);    sync();    revalidate();  }  public void setLayout(LayoutManager l)  {    LayoutManager old = super.getLayout();    ScrollPaneLayout tmp = (ScrollPaneLayout) l;    super.setLayout(l);    tmp.syncWithScrollPane(this);    firePropertyChange("layout", old, l);    sync();  }  public void setRowHeader(JViewport v)  {    if (rowHeader == v)      return;        JViewport old = rowHeader;    removeNonNull(old);    rowHeader = v;    addNonNull(v, JScrollPane.ROW_HEADER);    firePropertyChange("rowHeader", old, v);    sync();  }  public void setRowHeaderView(Component c)  {    if (rowHeader == null)      setRowHeader(createViewport());    rowHeader.setView(c);    sync();  }  public void setVerticalScrollBar(JScrollBar v)  {    if (verticalScrollBar == v)      return;        JScrollBar old = verticalScrollBar;    removeNonNull(old);    verticalScrollBar = v;    addNonNull(v, JScrollPane.VERTICAL_SCROLLBAR);    firePropertyChange("verticalScrollBar", old, v);    sync();  }  public void setVerticalScrollBarPolicy(int v)  {    if (verticalScrollBarPolicy == v)      return;        if (v != VERTICAL_SCROLLBAR_AS_NEEDED        && v != VERTICAL_SCROLLBAR_NEVER        && v != VERTICAL_SCROLLBAR_ALWAYS)      throw new IllegalArgumentException("unknown vertical scrollbar policy");            int old = verticalScrollBarPolicy;    verticalScrollBarPolicy = v;    firePropertyChange("verticalScrollBarPolicy", old, v);    sync();    revalidate();  }  public void setWheelScrollingEnabled(boolean b)  {    if (wheelScrollingEnabled == b)      return;        boolean old = wheelScrollingEnabled;    wheelScrollingEnabled = b;    firePropertyChange("wheelScrollingEnabled", old, b);    sync();  }  public void setViewport(JViewport v)  {    if (viewport == v)      return;        JViewport old = viewport;    removeNonNull(old);    viewport = v;    addNonNull(v, JScrollPane.VIEWPORT);    revalidate();    repaint();    firePropertyChange("viewport", old, v);    sync();    if (accessibleContext != null)      {        AccessibleJScrollPane asp = (AccessibleJScrollPane) accessibleContext;        asp.resetViewPort();      }  }  public void setViewportBorder(Border b)  {    if (viewportBorder == b)      return;        Border old = viewportBorder;    viewportBorder = b;    firePropertyChange("viewportBorder", old, b);    sync();  }      public void setViewportView(Component view)  {    if (getViewport() == null)      {        setViewport(createViewport());      }	    if (view != null)      {        getViewport().setView(view);      }    sync();  }  public boolean isValidateRoot()  {    return true;  }  /**   * Creates a new <code>JScrollPane</code> without a view. The scrollbar   * policy is set to {@link #VERTICAL_SCROLLBAR_AS_NEEDED} and   * {@link #HORIZONTAL_SCROLLBAR_AS_NEEDED}.   */  public JScrollPane()   {    this(null);  }  /**   * Creates a new <code>JScrollPane</code> that embeds the specified   * <code>view</code> component, displaying vertical and horizontal scrollbars   * as needed.   *   * @param view the component that is embedded inside the JScrollPane   */  public JScrollPane(Component view)   {    this(view,          VERTICAL_SCROLLBAR_AS_NEEDED,          HORIZONTAL_SCROLLBAR_AS_NEEDED);  }  /**   * Creates a new <code>JScrollPane</code> without a view; The scrollbar   * policies are set to <code>vsbPolicy</code> and <code>hsbPolicy</code>.   *   * @param vsbPolicy the vertical scrollbar policy to set   * @param hsbPolicy the vertical scrollbar policy to set   *   * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_ALWAYS   * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_AS_NEEDED   * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_NEVER   * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_ALWAYS   * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_AS_NEEDED   * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_NEVER   */  public JScrollPane(int vsbPolicy, int hsbPolicy)   {    this(null, vsbPolicy, hsbPolicy);  }  /**   * Creates a new <code>JScrollPane</code> that embeds the specified   * <code>view</code> component; The scrollbar   * policies are set to <code>vsbPolicy</code> and <code>hsbPolicy</code>.   *   * @param vsbPolicy the vertical scrollbar policy to set   * @param hsbPolicy the vertical scrollbar policy to set   *   * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_ALWAYS   * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_AS_NEEDED   * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_NEVER   * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_ALWAYS   * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_AS_NEEDED   * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_NEVER   */  public JScrollPane(Component view, int vsbPolicy, int hsbPolicy)   {    setVerticalScrollBarPolicy(vsbPolicy);    setVerticalScrollBar(createVerticalScrollBar());    setHorizontalScrollBarPolicy(hsbPolicy);    setHorizontalScrollBar(createHorizontalScrollBar());    viewport = createViewport();    if (view != null)      getViewport().setView(view);    add(viewport,0);    setLayout(new ScrollPaneLayout());    setOpaque(false);    updateUI();  }    public JScrollBar createHorizontalScrollBar()  {    return new ScrollBar(SwingConstants.HORIZONTAL);  }  public JScrollBar createVerticalScrollBar()  {    return new ScrollBar(SwingConstants.VERTICAL);  }      protected JViewport createViewport()  {    return new JViewport();  }  public String getUIClassID()  {    return "ScrollPaneUI";  }    public void updateUI()  {    setUI((ScrollPaneUI) UIManager.getUI(this));  }    /**   * This method returns the scrollpane's UI delegate.   *   * @return The scrollpane's UI delegate.   */  public ScrollPaneUI getUI()  {    return (ScrollPaneUI) ui;  }  /**   * This method sets the scrollpane's UI delegate.   *   * @param ui The scrollpane's UI delegate.   */  public void setUI(ScrollPaneUI ui)  {    super.setUI(ui);  }  protected class ScrollBar     extends JScrollBar    implements UIResource  {    private static final long serialVersionUID = -42032395320987283L;    public ScrollBar(int orientation)    {      super(orientation);    }    public int getBlockIncrement(int direction)    {      Component view = JScrollPane.this.getViewport().getView();      if (view == null || (! (view instanceof Scrollable)))        return super.getBlockIncrement(direction);      else        {          Scrollable s = (Scrollable) view;          return s.getScrollableBlockIncrement(JScrollPane.this.getViewport().getViewRect(),                                                this.getOrientation(),                                               direction);        }    }    public int getUnitIncrement(int direction)    {      Component view = JScrollPane.this.getViewport().getView();      if (view == null || (! (view instanceof Scrollable)))        return super.getUnitIncrement(direction);      else        {          Scrollable s = (Scrollable) view;          return s.getScrollableUnitIncrement(JScrollPane.this.getViewport().getViewRect(),                                               this.getOrientation(),                                              direction);        }    }  }  /**   * Returns the accessible context associated with this   * <code>JScrollPane</code>.   *   * @return the accessible context associated with this   *         <code>JScrollPane</code>   */  public AccessibleContext getAccessibleContext()  {    if (accessibleContext == null)      accessibleContext = new AccessibleJScrollPane();    return accessibleContext;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -