A
aGuest
Gast
Hi Leute,
sobald ich das Fenster verkleinere/vergrössere, stimmen die Proportionen der Komponenten nicht mehr überrein. Die Buttons, TextFelder und Labels werden riesig, und das ScrollPane wird sehr klein.
Hier ein Codeschnipsel. Folgendes ist im Konstruktor:
bin um jeden Tipp dankbar. Ich verzweifle langsam.
mfG aGuest
sobald ich das Fenster verkleinere/vergrössere, stimmen die Proportionen der Komponenten nicht mehr überrein. Die Buttons, TextFelder und Labels werden riesig, und das ScrollPane wird sehr klein.
Hier ein Codeschnipsel. Folgendes ist im Konstruktor:
Code:
// ----- initialize layout ----- //
JFrame frame = new JFrame();
Container container = frame.getContentPane();
GridBagLayout gbl = new GridBagLayout();
container.setLayout(gbl);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 300;
c.weighty = 400;
c.insets = new Insets(0,5,10,15);
// ----- initialize variables ----- //
model = new Model();
table = new JTable( model );
JLabel LdayDate = new JLabel("Day Date");
JLabel LstartDate = new JLabel("Start Date");
JLabel LendDate = new JLabel("End Date");
dayDate = new Date();
startDate = new Date();
endDate = new Date();
dayDateButton = new DateButton();
dayDateButton.addPropertyChangeListener( "date", this );
startDateButton = new DateButton();
startDateButton.addPropertyChangeListener( "date", this );
endDateButton = new DateButton();
endDateButton.addPropertyChangeListener( "date", this );
loginStatus = new JLabel("Status: ");
loginStatusValue = new JLabel("");
JLabel general = new JLabel("All Values:");
generalInput = new JTextField("");
JLabel subject = new JLabel("Subject:");
subjectInput = new JTextField("");
JLabel header = new JLabel("Header:");
headerInput = new JTextField("");
JLabel attachment = new JLabel("Attachment:");
attachmentInput = new JTextField("");
JLabel from = new JLabel("From:");
fromInput = new JTextField("");
JLabel to = new JLabel("To:");
toInput = new JTextField("");
JLabel schaetzung = new JLabel("erwartet:");
schaetzungOutput = new JLabel("0 Mails");
JButton searchButton = new JButton("Search");
scrollPane = new JScrollPane(table);
if(urlOfConn.length() > 1){
loginStatusValue.setText("connected to " + gUrl);
}else{
loginStatusValue.setText("connection failed");
}
// ----- define positions on gui ----- //
c.gridx = 0; // x-Position
c.gridy = 0; // y-Position
c.gridwidth = 1; // Breite
c.gridheight = 1; // Höhe
gbl.setConstraints(loginStatus, c); // zum GridBagConstraints hinzufügen
container.add(loginStatus);
c.gridx = 1;c.gridy = 0;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(loginStatusValue, c);container.add(loginStatusValue);
c.gridx = 0;c.gridy = 1;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(general, c);container.add(general);
c.gridx = 1;c.gridy = 1;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(generalInput, c);container.add(generalInput);
c.gridx = 0;c.gridy = 2;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(subject, c);container.add(subject);
c.gridx = 1;c.gridy = 2;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(subjectInput, c);container.add(subjectInput);
c.gridx = 0;c.gridy = 3;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(header, c);container.add(header);
c.gridx = 1;c.gridy = 3;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(headerInput, c);container.add(headerInput);
c.gridx = 0;c.gridy = 4;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(attachment, c);container.add(attachment);
c.gridx = 1;c.gridy = 4;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(attachmentInput, c);container.add(attachmentInput);
c.gridx = 0;c.gridy = 5;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(from, c);container.add(from);
c.gridx = 1;c.gridy = 5;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(fromInput, c);container.add(fromInput);
c.gridx = 0;c.gridy = 6;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(to, c);container.add(to);
c.gridx = 1;c.gridy = 6;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(toInput, c);container.add(toInput);
c.gridx = 0;c.gridy = 7;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(LdayDate, c);container.add(LdayDate);
c.gridx = 1;c.gridy = 7;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(dayDateButton, c);container.add(dayDateButton);
c.gridx = 0;c.gridy = 8;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(LstartDate, c);container.add(LstartDate);
c.gridx = 1;c.gridy = 8;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(startDateButton, c);container.add(startDateButton);
c.gridx = 0;c.gridy = 9;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(LendDate, c);container.add(LendDate);
c.gridx = 1;c.gridy = 9;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(endDateButton, c);container.add(endDateButton);
c.gridx = 0;c.gridy = 10;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(schaetzung, c);container.add(schaetzung);
c.gridx = 1;c.gridy = 10;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(schaetzungOutput, c);container.add(schaetzungOutput);
c.gridx = 1;c.gridy = 11;c.gridwidth = 1;c.gridheight = 1;
gbl.setConstraints(searchButton, c);container.add(searchButton);
c.gridx = 0;c.gridy = 12;c.gridwidth = 2;c.gridheight = 10;
gbl.setConstraints(scrollPane, c);container.add(scrollPane);
bin um jeden Tipp dankbar. Ich verzweifle langsam.
mfG aGuest