Ich habe ein kleines Programm geschrieben, dass über eine Methode in einen beliebigen Container, nebst GridbagLayout, eine beliebige Komponente einbindet.
Das funktioniert auch an sich tadellos. problematisch ist aber eins.
Sofern ich für die Höhe des einen Container einen höhreren Wert eingebe als für den zweiten, werden trotzdem beide gleich gross dargestellt.
Das ist die Routine die sowohl den äußeren Container erstellt, als auch die beiden besagten inneren Container zwar in das GridBagLayout von a einpflegt aber nicht die höhere Höhe des inneren Panels b berücksichtigt.
Weis Jemand wieso b und c trotz anderer "height" Angabe gleich gross sind ?
Das funktioniert auch an sich tadellos. problematisch ist aber eins.
Sofern ich für die Höhe des einen Container einen höhreren Wert eingebe als für den zweiten, werden trotzdem beide gleich gross dargestellt.
Das ist die Routine die sowohl den äußeren Container erstellt, als auch die beiden besagten inneren Container zwar in das GridBagLayout von a einpflegt aber nicht die höhere Höhe des inneren Panels b berücksichtigt.
Java:
PanelOuter a = new PanelOuter(6, 7, 5, 5);
PanelInner b = new PanelInner(a, a.gbl, 1, 1, 1, 2);
PanelInner c = new PanelInner(a, a.gbl, 1, 3, 1, 1);
Java:
public PanelOuter (int x, int y, int width, int height) {
setLayout(gbl);
......
Grid.Add(this, x, y, width, height);
}
Java:
public PanelInner (Container a, GridBagLayout b, int x, int y, int width, int height) {
.......
Grid.Add(this, a, b, x, y, width, height);
Java:
// Komponente hinzufügen (MasterPane)
public static void Add(Component a, int x, int y, int width, int height) {
Clear(x, y, width, height);
Add(MasterPane, Gbl, a, x, y, width, height, 1, 1, 1, 10, 0, 0, 0, 0, 0, 0);
}
// Komponente hinzufügen (Container b)
public static void Add(Component a, Container b, GridBagLayout c, int x, int y, int width, int height) {
Add(b, c, a, x, y, width, height, 1, 1, 1, 10, 0, 0, 0, 0, 0, 0);
}
// HAUPTROUTINE
public static void Add(Container a, GridBagLayout b, Component c, int x, int y, int width, int height, double weightx, double weighty,
int fill, int anchor, int top, int bottom, int left, int right, int ipadx, int ipady) {
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = x-1;
gbc.gridy = y-1;
gbc.gridwidth = width;
gbc.gridheight = height;
gbc.weightx = weightx;
gbc.weighty = weighty;
gbc.fill = fill;
gbc.anchor = anchor;
gbc.insets = new Insets(top, bottom, left, right);
gbc.ipadx = ipadx;
gbc.ipady = ipady;
b.setConstraints(c, gbc);
a.add(c);
}
Weis Jemand wieso b und c trotz anderer "height" Angabe gleich gross sind ?