Package javax.swing

Examples of javax.swing.JViewport


    // Add your handling code here:

    Container container = pnlInScroll.getParent();
    if (container instanceof JViewport)
    {
      JViewport viewport = (JViewport) container;
      Point point = viewport.getViewPosition();
      int newX = point.x - (evt.getX() - downX);
      int newY = point.y - (evt.getY() - downY);

      int maxX = pnlInScroll.getWidth() - viewport.getWidth();
      int maxY = pnlInScroll.getHeight() - viewport.getHeight();

      if (newX < 0)
      {
        newX = 0;
      }
      if (newX > maxX)
      {
        newX = maxX;
      }
      if (newY < 0)
      {
        newY = 0;
      }
      if (newY > maxY)
      {
        newY = maxY;
      }

      viewport.setViewPosition(new Point(newX, newY));
    }
  }//GEN-LAST:event_pnlLinksMouseDragged
View Full Code Here


   * JTable normally restricts its size to just what's needed by its
   * model.
   */
  public boolean getScrollableTracksViewportHeight() {
    if (getParent() instanceof JViewport) {
      JViewport parent = (JViewport) getParent();
      return (parent.getHeight() > getPreferredSize().height);
    }
    return false;
  }
View Full Code Here

    // TF:10/03/2009:Added an efficiency measure of only painting the empty rows if they're needed
    int topRow;
    Rectangle parentVisibleRect = null;
    if (this.getParent() instanceof JViewport) {
      JViewport port = (JViewport)this.getParent();
      topRow = this.rowAtPoint(new Point(0, port.getViewRect().y));
      parentVisibleRect = port.getVisibleRect();
    }
    else {
      topRow = this.rowAtPoint(this.getCellRect(0, 0, true).getLocation());
    }
    if (topRow + visibleRows < rowCount) {
View Full Code Here

     * @since 02/01/2008
     */
    private void scrollRowToVisible(int pRow) {
        if (!(table.getParent() instanceof JViewport))
            return;
        JViewport viewport = (JViewport)table.getParent();
        java.awt.Rectangle rect = table.getCellRect(pRow, 0, true);
        java.awt.Rectangle viewRect = viewport.getViewRect();
        rect.setLocation(rect.x - viewRect.x, rect.y - viewRect.y);
        viewport.scrollRectToVisible(rect);
    }
View Full Code Here

     * @since 02/01/2008
     */
    private void scrollRowToVisible(int pRow) {
        if (!(table.getParent() instanceof JViewport))
            return;
        JViewport viewport = (JViewport)table.getParent();
        java.awt.Rectangle rect = table.getCellRect(pRow, 0, true);
        java.awt.Rectangle viewRect = viewport.getViewRect();
        rect.setLocation(rect.x - viewRect.x, rect.y - viewRect.y);
        viewport.scrollRectToVisible(rect);
    }
View Full Code Here

            left += table.getColumnModel().getColumn(1).getWidth();
        }
        int right = table.getColumnModel().getColumn(column - 1).getWidth() + left;
        int bottom = 0;
        if (table.getParent() instanceof JViewport) {
            JViewport sp = (JViewport) table.getParent();
            bottom = sp.getHeight();
        }
        else {
            bottom = table.getHeight();
        }
        if (table.getTableHeader() != null) {
View Full Code Here

     *            the row to scroll to
     * @return
     */

    public static void scrollToRow(JTable t, int r) {
        JViewport viewport = (JViewport) t.getParent();
        viewport.setViewPosition(new java.awt.Point(0, t.getRowHeight() * r));
    }
View Full Code Here

    public void setBackground(Color bg) {
        super.setBackground(bg);
        // TF:19/3/08:We want our colour to apply to any numbers in the left hand margin for a numbered text area.
        if (getParent() != null && getParent().getParent() instanceof JScrollPane) {
          JScrollPane scrollPane = (JScrollPane)getParent().getParent();
          JViewport viewport = scrollPane.getRowHeader();
          if (viewport != null && viewport.getView() != null) {
            viewport.getView().setBackground(bg);
          }
        }
        this.overriddenBackgroundColour = bg;
    }
View Full Code Here

    public void setBackground(Color bg) {
        super.setBackground(bg);
        // TF:19/3/08:We want our colour to apply to any numbers in the left hand margin for a numbered text area.
        if (getParent() != null && getParent().getParent() instanceof JScrollPane) {
          JScrollPane scrollPane = (JScrollPane)getParent().getParent();
          JViewport viewport = scrollPane.getRowHeader();
          if (viewport != null && viewport.getView() != null) {
            viewport.getView().setBackground(bg);
          }
        }
        this.overriddenBackgroundColour = bg;
    }
View Full Code Here

   * JTable normally restricts its size to just what's needed by its
   * model.
   */
  public boolean getScrollableTracksViewportHeight() {
    if (getParent() instanceof JViewport) {
      JViewport parent = (JViewport) getParent();
      return (parent.getHeight() > getPreferredSize().height);
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of javax.swing.JViewport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.