Class ScrollablePanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable
Direct Known Subclasses:
AbstractAiProviderPanel, AgiConfigPanel, AgiPanel, AsiContainerAboutPanel, AsiContainerSettingsPanel, ContextProviderPanel, RequestConfigPanel, ResourcePanel, SessionConfigPanel, SupportPanel, ToolkitPanel, ToolPanel

public class ScrollablePanel extends JPanel implements Scrollable
A flexible JPanel that implements the Scrollable interface, allowing for configurable scrolling behavior. This is useful for panels placed in a JScrollPane.
Author:
anahata
See Also:
  • Field Details

    • scrollableTracksViewportWidth

      private boolean scrollableTracksViewportWidth
      Whether this panel's width should always match the viewport's width.

      When true, horizontal scrolling is effectively disabled and components are expected to wrap or scale.

    • scrollableTracksViewportHeight

      private boolean scrollableTracksViewportHeight
      Whether this panel's height should always match the viewport's height.

      When true, vertical scrolling is effectively disabled.

  • Constructor Details

    • ScrollablePanel

      public ScrollablePanel()
      Default constructor. Initializes the panel for vertical scrolling, which is the most common use case.
    • ScrollablePanel

      public ScrollablePanel(int orientation)
      Creates a new ScrollablePanel with a specific scrolling orientation.
      Parameters:
      orientation - The scrolling orientation, either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
  • Method Details

    • getPreferredScrollableViewportSize

      public Dimension getPreferredScrollableViewportSize()

      Returns the component's preferred size as the viewport size, assuming the parent scroll pane will manage the actual visible area.

      Specified by:
      getPreferredScrollableViewportSize in interface Scrollable
    • getScrollableUnitIncrement

      public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)

      Returns a fixed increment of 24 pixels, optimized for smooth scrolling of chat and context components.

      Specified by:
      getScrollableUnitIncrement in interface Scrollable
    • getScrollableBlockIncrement

      public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)

      Returns the full height (or width) of the visible rectangle to support "page down/up" scrolling behavior.

      Specified by:
      getScrollableBlockIncrement in interface Scrollable
    • getScrollableTracksViewportWidth

      public boolean getScrollableTracksViewportWidth()

      Returns the configured scrollableTracksViewportWidth state.

      Specified by:
      getScrollableTracksViewportWidth in interface Scrollable
    • getScrollableTracksViewportHeight

      public boolean getScrollableTracksViewportHeight()

      Returns the configured scrollableTracksViewportHeight state.

      Specified by:
      getScrollableTracksViewportHeight in interface Scrollable
    • setScrollableTracksViewportWidth

      public void setScrollableTracksViewportWidth(boolean scrollableTracksViewportWidth)
      Sets whether this panel should track the viewport's width.
      Parameters:
      scrollableTracksViewportWidth - true to track width.
    • setScrollableTracksViewportHeight

      public void setScrollableTracksViewportHeight(boolean scrollableTracksViewportHeight)
      Sets whether this panel should track the viewport's height.
      Parameters:
      scrollableTracksViewportHeight - true to track height.