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....
Related videos on Youtube
Comments
-
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 .
-
Qwerky over 10 yearsThere's a nice scroll pane tutorial on the swing site: docs.oracle.com/javase/tutorial/uiswing/components/…
-
-
Josh M over 10 yearsBeat you by 11 seconds. :) (Plus I was able to provide a code sample as well)
-
Laxman More over 10 yearsi tried following code but not working yet: JScrollPane jsp=new JScrollPane(mainpanel); mainframe.add(jsp);