Article View: borland.public.jbuilder.java.swing
Article #9363JScrollPane doesn't appear in JPanel
From: Jeff Marendo
Date: Tue, 18 Apr 2000 00:00
Date: Tue, 18 Apr 2000 00:00
62 lines
2907 bytes
2907 bytes
Hello,
I'm making an applet that has a JTabbedPane with two tabs. Each tab has a
JPanel associated with it that uses a BorderLayout and contains a
JScrollPane in the center location. I have two other JPanels (one for each
tab) that each have their layouts set to 'null'. These panels have several
components on them and vary in size (they're named SmallDummyPanel and
LargeDummyPanel).
Generally, this is what I'm doing: 1. add a panel (e.g. LargeDummyPanel
instance) to a JScrollPane instance. 2. add that scroll panel to one of the
panels that has a border layout. 3. create a tab by adding that panel to the
JTabbedPane instance. 4. add that instance to 'this', which is the applet.
The problem is, I'm not seeing the actual vertical and horizontal scrollbars
appear for the panel that contains my LargeDummyPanel instance. When I use
the JScrollPane constants for always showing them, only the corners appear
with no bars between them. My code is below if anyone can give me some help.
Thanks in advance.
public class TabbedApplet extends JApplet
JTabbedPane tabPane = new JTabbedPane()
public void paint(Graphics g)
super.paint(g);
getParent().validate();
}
};
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
SmallDummyPanel sdp = new SmallDummyPanel();
LargeDummyPanel ldp = new LargeDummyPanel();
JScrollPane scroll1 = new JScrollPane();
JScrollPane scroll2 = new JScrollPane
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
BorderLayout borderLayout1 = new BorderLayout();
BorderLayout borderLayout2 = new BorderLayout();
...
private void jbInit() throws Exception
this.setSize(new Dimension(500,400));
p1.setLayout(borderLayout1);
scroll1.add(sdp);
p1.add(scroll1, BorderLayout.CENTER);
tabPane.addTab("Tab 1", p1);
p2.setLayout(borderLayout2);
scroll2.add(ldp);
p2.add(scroll2, BorderLayout.CENTER);
tabPane.addTab("Tab 2", p2);
this.getContentPane().add(tabPane, BorderLayout.CENTER);
}
The other panel sizes are: LargeDummyPanel - (600,400); SmallDummyPanel -
(400,300). The size, min size and preferred size are all being set with
those same values, respectively. Also, the size of the frame the applet
sits in is (500, 420).
jeff
Technical Details
Message-ID:
<38fcd824@dnews>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,2517369386e172b3,start X-Google-Attributes: gid111d45,public From: "Jeff Marendo" <marendoj@commos.com> Subject: JScrollPane doesn't appear in JPanel Date: 2000/04/18 Message-ID: <38fcd824@dnews> X-Deja-AN: 612876782 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Trace: 18 Apr 2000 14:48:20 -0800, 24.95.56.21 Organization: CommTech Corporation X-MSMail-Priority: Normal Reply-To: "Jeff Marendo" <marendoj@commos.com> Newsgroups: borland.public.jbuilder.java.swing