I have a JTable with rows and column that the user can remove and/or add.
My problem is that if the JTable rows becomes more then 15 and the columns become more then 10 the Jtable slows down. ALOT. When resizing columns with drag the JTable is very slow.
How can I come around this? I have a CellEditor which extends the DefaultCellEditor. Every column has the same editor. The cellrenderer implements the TableCellRenderer and sets a HTMLDocument to every cell. I have one Instance of a JTextPane but I have to do the JTextPane.setDocument in the getTableCellRendererComponent. If I don't set the document in the component the data is not displayed.
speculation about the cause of the low performance is possible, but I don't recommend it. Use a profiler. Here is an example for invoking the profiler that is shipped with the JDK for your situation (JVM options):
Include these options in your normal program call. Then while the program is running you must do the things that take too long all of the time for a couple of seconds, then exit immediately. The result is in java.hprof.txt
If you are doing any I/O bound or computationally intensive stuff, you should not do it in the dispatcher thread. The fundamental behind this is as follows.
The event-dispatching thread is a thread that executes drawing of components and event-handling code. For example the paint() and actionPerformed() methods are automatically executed in the event-dispatching thread. Another way to execute code in the event-dispatching thread from outside event-handling or drawing code, is using SwingUtilities invokeLater() or invokeAndWait() method. Swing lengthy initialization tasks (e.g. I/O bound and computationally expensive tasks), should not occur in the event-dispatching thread because this will hold up the dispatcher thread. If you need to create a new thread for example, to handle a job that�s computationally expensive or I/O bound then you can use the thread utility classes such as SwingWorker or Timer without locking up the event-dispatching thread.