Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Adding JScrollPane to JInternalFrame

843805Nov 27 2005 — edited Dec 22 2005
Hello, I have been having a rather difficult time adding a a jscrollpane to my jinternalframe. I have a panel that I am adding some objects to. I add that panel to a jscrollpane, then add the jscrollpane to the container of the JInternalFrame. I get no errors, but when I run this thing, the panel spills out over the JInternalFrame, the panel is bigger than the internal frame. When I take the jscrollpane off of it and just add the panel directly to the JInternalFrame, it fits jsut fine. However, I need the scrollbar to view all of the material. Any ideas? Here is a piece of my code.

    JInternalFrame internal = new JInternalFrame("New Tree",true,true,true,true);
	    
	 Container c = internal.getContentPane();
	
//this panel is something I created earlier and have added stuff to it
//panel is of the type java.awt.panel
        panel.setBackground(Color.white);
        JScrollPane jsp = new JScrollPane();
        jsp.setViewportView(panel);
        c.add(jsp);

        internal.setSize(700,400);
        internal.setOpaque(true);
        internal.setVisible(true);

//I add it to a desktop pane a little later on
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 19 2006
Added on Nov 27 2005
15 comments
302 views