[4215] in java-interest
layout woes
daemon@ATHENA.MIT.EDU (Aaron Shtromas)
Wed Dec 13 17:10:17 1995
Date: Wed, 13 Dec 1995 15:11:35 -0500 (EST)
From: Aaron Shtromas <ams@mci.net>
To: java-interest@java.sun.com
hi java'ers,
could anyone point me to a source of a non-trivial layout, with
a couple of panels/frames containing other components. i've
been trying to lay out a panel with an image on one side and
a control panel on the other. the control panel should contain
a list and a couple of subpanels. each of the subpanels will
contain a label and a column of buttons. it works if the
subpanels are stacked on top of each other, but as soon as i
try to arrange them horizontally, all but the leftmost subpanel
vanishes.
i tried the daeron meyer's PacketLayout as well combinations
of BorderLayout, GridLayout and GridBagLayout with similar
results. here is the code fragment using GridBagLayout that
i was hoping would produce a panel containing sub-panels but
only the 'router' subpanel appears. thanks in advance for
any advice. (am i doing something really dumb?)
-a
Panel ctl;
Panel router; // control panel
Panel speed; // subpanel
Panel proto; // subpanel
public void init() {
ctl = new Panel();
router = new Panel();
speed = new Panel();
GridBagLayout gridbag = new GridBagLayout();
ctl.setLayout(gridbag);
router.setLayout(gridbag);
speed.setLayout(gridbag);
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
label = new Label("Router classs");
gridbag.setConstraints(label, c);
router.add(label);
c.anchor = GridBagConstraints.WEST;
checkbox = new Checkbox("Core", null, false);
gridbag.setConstraints(checkbox, c);
router.add(checkbox);
// more checkboxes packed in router subpanel here
label = new Label("Link speed");
gridbag.setConstraints(label, c);
speed.add(label);
checkbox = new Checkbox("OC-3", null, false);
gridbag.setConstraints(checkbox, c);
speed.add(checkbox);
// more checkboxes packed in speed subpanel here
// pack router subpanel in ctl
c.anchor = GridBagConstraints.NORTHWEST;
c.weightx = 1.0;
c.gridwidth = GridBagConstraints.RELATIVE;
gridbag.setConstraints(router, c);
ctl.add(router);
// pack speed subpanel in ctl
c.anchor = GridBagConstraints.NORTHEAST;
c.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints(speed, c);
ctl.add(speed);
add(ctl);
//....
}
----------------------------------------------------------------
Aaron Shtromas MCI Internet Engineering
ams@mci.net 2100 Reston Parkway
Tel. 703-715-7334 Reston, VA 22091
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com