How to make JFrame or JPanel Scrollable

15,066

Solution 1

Before adding your JPanel, put in a JScrollPane first:

JPanel panel = ...;
JScrollPane scroll = new JScrollPane(panel);
frame.add(scroll, ...);

Solution 2

Just putting your JPanel in a JScrollPane and adding this to the JFrame should do the trick....

Share:
15,066

Related videos on Youtube

Laxman More
Author by

Laxman More

ruby on rails developer

Updated on June 21, 2022

Comments

  • Laxman More
    Laxman More almost 2 years

    i have added multiple component on JPanel & then i add JPanel on JFrame.

    how to make window scrollable ?

    so i can add more component at that frame or window .

  • Josh M
    Josh M over 10 years
    Beat you by 11 seconds. :) (Plus I was able to provide a code sample as well)
  • Laxman More
    Laxman More over 10 years
    i tried following code but not working yet: JScrollPane jsp=new JScrollPane(mainpanel); mainframe.add(jsp);