简体   繁体   中英

Add scrollbar in undecorated JFrame

I am using a JFrame in a java application and I needed to have it undecorated, so I just set setUndecorated(true) . I am using 3 panels in frame. Top, left and right. All frames have setLayout(null) .

Now I want to add scroll bar in right panel. I tried every thing available but I can't get it. Is there any way that I can have scroll bar?

You can use a JScrollPane for that purpose.

It is a container that automatically provides scroll-bar if the contents exceed it's size.


Secondly, using setLayout(null) is a bad practice. Actually it is worse than a bad practice. You should avoid with all efforts you can muster.

Try using suitable LayoutManager .

Here is a nice tutorial for using them.
You can also have a look at Visual Guide to Layout Managers .

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM