0

I have a programm I am supposed to show off on a screen that is significantly smaller than the one it was developed on and it makes it unusable due to an autosized textfield getting downsized to 0. In order to solve this problem, I want to set the size of the tables to a max size so that the textfields have enough space.

basically, I have a customtablemodel in a JTable in a JScrollPane in a JPanel with BoxLayout in a Applet.

Now, I know this isn't the best solution, since I have to scroll in the tables, but I need to be able to show the programm off at least.

firsttablepane = new JScrollPane(firsttable);
firstmodel.addColumn("Vorname");
firstmodel.addColumn("Nachname");
firstmodel.addColumn("Benutzername");
firstmodel.addColumn("Access");
firsttable.setModel(firstmodel);
try {
  gui.guirs1 = gui.sqlc.executeSQLStatement("SELECT LID,Loginname,Vorname,Nachname,Access FROM login WHERE Geloescht=0;", (byte) 1);
  while(gui.guirs1.next()) {
    try {
      firstmodel.addRow(new Object[] {
        gui.guirs1.getString("Vorname"), gui.guirs1.getString("Nachname"), gui.guirs1.getString("Loginname"), gui.guirs1.getString("Access")
      });
    } catch(Exception exce) {
      exce.printStackTrace();
    }
  }
  ListSelectionModel listMod = firsttable.getSelectionModel();
  listMod.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  //buff.populate(gui.guirs)                                                                                              ;
  //gui.sqlc.closeConnection();
} catch(SQLException e1) {
  e1.printStackTrace();
}
firsttable.setAutoscrolls(false);
firsttable.setDragEnabled(false);
firsttable.setAutoCreateColumnsFromModel(false);
leftpanel.add(firsttablepane, BorderLayout.LINE_START);
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1
    For better help sooner, post an [SSCCE](http://sscce.org/). – Andrew Thompson Apr 06 '13 at 23:16
  • 1
    You can supply text fields with a preferred size hint through the `columns` property. I also tend to find the preferred size value to the minimum size property as well, but that's me. You could also turn of column auto-resizing on the table, which will allow the table to fill horizontally... – MadProgrammer Apr 06 '13 at 23:24
  • 1
    Also see [How to resize JTable column to string length?](http://stackoverflow.com/q/5820238/1048330) – tenorsax Apr 07 '13 at 00:59
  • 1
    something wrong with the code you are not showing ... – kleopatra Apr 07 '13 at 07:13

0 Answers0