Announcement

Collapse
No announcement yet.

JScrollPane mit einem JPanel füllen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • JScrollPane mit einem JPanel füllen

    hallo leute,

    ich habe ein problem ein JPanel in ein JScrollPane reinzustellen. das jpanel ist etwa doppelt so groß wie das jscrollpane. es wird aber nur der teil des jpanel angezeigt der die größe des jscrollpane hat. scrollbar werden auch nicht angezeigt,obwohl ich sie gesetzt habe.

    vielleicht kann mir ja jemand einen tipp geben.

    danke gruß thorsten

  • #2
    Hallo Thorsten,<br>
    hast Du in Deinem JPanel getPreferredSize() gesetzt?<br>
    Es ist auch nicht schlecht, wenn man das Interface Scrollable<br>
    implementiert, z.B.:
    <pre>
    /**
    * --- The Scrollable Implementation ---
    */

    public Dimension getPreferredScrollableViewportSize() {
    return getPreferredSize();
    }

    public int getScrollableBlockIncrement(Rectangle visibleRect,
    int orientation,
    int direction) {
    if (orientation == SwingConstants.VERTICAL) {
    return visibleRect.getBounds().height
    - getScrollableUnitIncrement(visibleRect, orientation, direction);
    }
    else {
    return visibleRect.getBounds().width
    - getScrollableUnitIncrement(visibleRect, orientation, direction);
    }
    }

    public int getScrollableUnitIncrement(Rectangle visibleRect,
    int orientation,
    int direction) {
    if (orientation == SwingConstants.VERTICAL) {
    return getGraphics().getFontMetrics(actualFont).getHeight ();
    }
    else {
    return getGraphics().getFontMetrics(actualFont).charWidth ('m');
    }
    }

    public boolean getScrollableTracksViewportHeight() {
    return false;
    }

    public boolean getScrollableTracksViewportWidth() {
    return false;
    }
    </pre>
    Klau

    Comment


    • #3
      Hallo Klaus

      werde es gleich mal probieren. danke.

      gruß thorste

      Comment

      Working...
      X