简体   繁体   中英

How to add Scroll to jDesktopPane

I am a beginner and creating a java desktop application in MDI format and so have used the JDesktopPane and Internal Frames. I am using NetBeans Drag and Drop mainly for this. Now i have a requirement to design a page that could have a property to scroll. I need to know how can i work upon this.

I have been through the following code but got no positive result. Link for the referal

I have got a solution. it may not be a proper solution but yes if i tried to add scrollpane as a parent to Desktop Pane it worked.

Add all components to panel and set view port

scrollPane.setViewportView(panel);

Example:

JScrollPane scrollPane = new JScrollPane();
JPanel panel = new JPanel();
panel.add(button1);//add some other componets that are already initialized
....
scrollPane.setViewportView(panel);
add(scrollPane);

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