Hi
kann mir bitte kurz jemand helfen, irgendwie krieg ich einfach nicht hin dass er mir die 2 listen dann die buttons dann wieder die liste gescheit ins fenster packt. hab schon alles mögliche mit den constraints versucht aber irgendwie funzt es hier nicht so wie ich will :-/
ausführbarer Code:
Btw.: hab ich schon mal gesagt dass ich Constraints hasse?! *grummel*
vielen lieben dank falls jemand es rausfindet
greez
kann mir bitte kurz jemand helfen, irgendwie krieg ich einfach nicht hin dass er mir die 2 listen dann die buttons dann wieder die liste gescheit ins fenster packt. hab schon alles mögliche mit den constraints versucht aber irgendwie funzt es hier nicht so wie ich will :-/
ausführbarer Code:
Code:
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.HashMap;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class Test extends JFrame {
private static final long serialVersionUID = 1L;
Vector<HashMap<String, String>> res = null;
JCheckBox all = new JCheckBox();
public JComboBox ComboBox;
JList List1;
JList List2;
JList List3;
JButton transfer1;
JButton transfer2;
public Test()
{
this.setLayout(new GridBagLayout());
addComponentInLayout(getContentPanel(),
0, 0, 1, 1,
0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,0,0,0));
addComponentInLayout(createContents(),
0, 1, 1, 1,
1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0));
this.setBounds(550, 250, 825, 425);
this.setVisible(true);
}
private JPanel getContentPanel() {
JPanel contentPanel = new JPanel();
contentPanel.setLayout(new FlowLayout());
JLabel welcomeLabel = new JLabel("Konfiguration");
welcomeLabel.setFont(new java.awt.Font("MS Sans Serif", Font.BOLD, 11));
contentPanel.add(welcomeLabel);
return contentPanel;
}
private JPanel createContents() {
List1 = new JList();
List1.setVisibleRowCount(10);
JScrollPane scroll1 = new JScrollPane(List1);
scroll1.setBackground(Color.white);
List3 = new JList();
List3.setVisibleRowCount(10);
JScrollPane scroll2 = new JScrollPane(List3);
scroll2.setBackground(Color.white);
List2 = new JList();
List2.setVisibleRowCount(10);
JScrollPane scroll3 = new JScrollPane(List2);
scroll3.setBackground(Color.white);
transfer1 = new JButton("->");
transfer2 = new JButton("<-");
String[] testperiods = {"1","2","3"};
ComboBox = new JComboBox(testperiods );
all.setEnabled(false);
JPanel sub = new JPanel();
sub.setLayout(new GridBagLayout());
JPanel subsub = new JPanel();
subsub.setLayout(new GridBagLayout());
addComponentInContainer(sub,ComboBox,
0, 0, 4, 1,
1.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20,2,0,0));
addComponentInContainer(sub, scroll1,
0, 1, 1, 1,
0.25, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(10,2,0,0));
addComponentInContainer(sub, scroll2,
1, 1, 1, 1,
0.25, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(10,2,0,0));
addComponentInContainer(sub, subsub,
2, 1, 1, 1,
0.25, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10,2,0,0));
addComponentInContainer(sub,scroll3,
2, 1, 1, 1,
0.25, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(10,2,0,10));
addComponentInContainer(subsub, transfer1,
0, 1, 1, 1,
1.0, 0.5, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,2,0,0));
addComponentInContainer(subsub, transfer2,
0, 2, 1, 1,
1.0, 0.5, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,2,0,0));
return sub;
}
//Fügt eine Componenten in das GridbagLayout ein
public void addComponentInLayout(Component aComp, int gridX, int gridY,
int gridWidth, int gridHeight, double weightX, double weightY, int anchor,
int fill, Insets insets) {
GridBagConstraints theConstraints = new GridBagConstraints(gridX, gridY, gridWidth, gridHeight, weightX,
weightY, anchor, fill, insets, 0, 0);
add(aComp, theConstraints);
}
// Fügt eine Componenten in ein z.B. Panel ein.
public void addComponentInContainer(JComponent aPanel, Component aComp,
int gridX, int gridY, int gridWidth, int gridHeight, double weightX,
double weightY, int anchor, int fill, Insets insets) {
GridBagConstraints theConstraints = new GridBagConstraints(gridX, gridY, gridWidth, gridHeight, weightX,
weightY, anchor, fill, insets, 0, 0);
aPanel.add(aComp, theConstraints);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Test a = new Test();
}
}
Btw.: hab ich schon mal gesagt dass ich Constraints hasse?! *grummel*
vielen lieben dank falls jemand es rausfindet
greez