Hi Leute,
warum wird die JTable nicht in meinem JDialog (kein LayoutManager verwendet) angezeigt? Habe Schritt-für-Schritt ein Tutorial befolgt. Muss ich evtl. "setBounds" aufrufen - hab keine Ahnung wo?
Vielen Dank für schnelle und kompetente Hilfe
warum wird die JTable nicht in meinem JDialog (kein LayoutManager verwendet) angezeigt? Habe Schritt-für-Schritt ein Tutorial befolgt. Muss ich evtl. "setBounds" aufrufen - hab keine Ahnung wo?
Java:
public class JDialogRanglisteAufgabe extends javax.swing.JDialog {
/**
* Creates new form JDialogRanglisteAufgabe
*/
public JDialogRanglisteAufgabe(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
myinitComponents();
}
//-------------------------------------------------------------------------------------
private void myinitComponents(){
JTable tabelle = makeJTable();
tabelle.setAutoCreateRowSorter(true);
ArrayList<SortKey> sortierekeys = new ArrayList<>();
sortierekeys.add(new SortKey(1, SortOrder.ASCENDING));
sortierekeys.add(new SortKey(2, SortOrder.ASCENDING));
tabelle.getRowSorter().setSortKeys(sortierekeys);
JScrollPane scrollp = new JScrollPane(tabelle);
scrollp.setPreferredSize(new Dimension(400,150));
Box box = Box.createVerticalBox();
box.add(scrollp);
this.add(box);
this.pack();
}
private static JTable makeJTable(){
return new JTable (daten, spalten);
}
private static final Object[][] daten = {
{"hanseyeah", "5", "50Sek"},
{"Ulli", "0", "100Sek"},
{"KaReN98", "20", "200Sek"},
{"Jens", "10", "300Sek"},
{"lord_opus!", "10", "250Sek"}
};
private static final String[] spalten =
{"Name", "Anzahl der Fehlversuche", "Zeit"};
[...]
Vielen Dank für schnelle und kompetente Hilfe