Search code examples
javaswingnetbeansjscrollpanejscrollbar

NetBeans: how to add ScrollBar to JPanel


I am developing a small desktop application in NetBeans. On my UI, I place a JPanel and put a single JLabel on it. The content of this JLabel is generated dynamically, so if the content is very large then it goes out of screen.So is there any way in which I can specify a fixed size for the JPanel and of course ScrollBars should appear when the text exceeds the screen size.


Solution

  • Use JScrollPane to contain Your big JPanel.