Guten Morgen!
Ich habe eine Tabelle in ein GridBagLayout eingefügt.
Allerdings: wenn ich dann das Programm starte und die Fenstergröße verkleinere, schrumpft meine Tabelle auf ca. 1qcm zusammen und wird auch nicht mehr groß, wenn ich das Fenster wieder vergrößere.
Was ist da bitte los?! :bahnhof:
Die Klasse Allocation brauche ich hier nur, um ein Object[][] data zum Testen zu haben.
LG Julia :wink:
Ich habe eine Tabelle in ein GridBagLayout eingefügt.
Allerdings: wenn ich dann das Programm starte und die Fenstergröße verkleinere, schrumpft meine Tabelle auf ca. 1qcm zusammen und wird auch nicht mehr groß, wenn ich das Fenster wieder vergrößere.
Was ist da bitte los?! :bahnhof:
Die Klasse Allocation brauche ich hier nur, um ein Object[][] data zum Testen zu haben.
Code:
import javax.swing.*;
import java.awt.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.String;
public class GUI extends JFrame {
Allocation al = new Allocation();
public GUI(Allocation al) {
this.al = al;
String[] columnNames = {"Variable", "Parameter", "Wert", "Beschreibung"};
Object[][] testArray = new Object[5][4];
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 4; j++) {
testArray[i][j] = al.dataMiddle[i][j];
}
}
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ev) {
System.exit(0);
}
});
GridBagLayout gbl = new GridBagLayout();
final Container cp = getContentPane();
setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
JLabel lbl = new JLabel("Links");
gbc.gridx = 0;
gbc.gridy = 0;
gbl.setConstraints(lbl, gbc);
cp.add(lbl);
final JTable table = new JTable(al.dataRight, columnNames);
table.setPreferredScrollableViewportSize(new Dimension(600, 800));
JScrollPane sp = new JScrollPane(table);
gbc.gridy++;
gbl.setConstraints(sp, gbc);
cp.add(sp);
JButton okButton = new JButton("OK");
gbc.gridx = 1;
gbc.gridy++;
gbl.setConstraints(okButton, gbc);
cp.add(okButton);
pack();
}
public void isCorrectEntry (String text) throws NumberFormatException {
if (text.length() > 0) {
double i = Double.parseDouble(text);
}
}
}
LG Julia :wink: