Avatar billede di8leva Nybegynder
23. maj 2005 - 13:21 Der er 7 kommentarer og
1 løsning

JTable, moving columns crashes application, sometimes

We have our own class, which extends JTable (via several steps though)

You can always move one, or two, or maybe five columns, but after a while, when you "pick up" a column, the applications just crashes, without any stacktrace at all.

Can be quite annoying, and very hard to find.

I understand that it's impossible for you to know what the cause is, but maybe you have ideas, or suggestions of what it might be.
Avatar billede mikkelbm Nybegynder
23. maj 2005 - 13:54 #1
It's not an OutOfMemoryError ?

You can't catch this error, but it will be written in the console, if you run your application there.
Avatar billede _carsten Nybegynder
23. maj 2005 - 20:06 #2
I asume that you extend JTable because you have to override one or more methods, could you post them here and the code you added/changed.
Avatar billede di8leva Nybegynder
24. maj 2005 - 14:33 #3
mikkelbm >> We run the app with Java Web Start, and we have told it to write all console output to a log. And the log is empty after a crash :(

carsten >> Yes, we have extended JTable (in five steps) and the methods we override are:
----------
    public TableCellEditor getCellEditor(int rowIndex, int columnIndex)
    {
        int column = convertColumnIndexToModel(columnIndex);
        if(getRowManipulationDropDownTableModel().hasDomainAt(rowIndex, column - _nrOfExtraColumns))
            return setModel(getDropDownCellEditor(), rowIndex, column);
        return super.getCellEditor(rowIndex, columnIndex);
    }
----------
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)
{
    if(e.isAltDown())
        return false;
    return super.processKeyBinding(ks, e, condition, pressed);
}
----------
public boolean editCellAt(int rowIndex, int columnIndex, EventObject e)
{
    if(super.editCellAt(rowIndex, columnIndex, e))
    {
        focus(e);
        activeRow = rowIndex;
        return true;
    }
    return false;
}
----------
public void editingStopped(ChangeEvent e)
{
    super.editingStopped(e);
    getSelectionModel().setSelectionInterval(activeRow, activeRow);
    this.requestFocus();
}
----------
public void editingCanceled(ChangeEvent e)
{
    super.editingCanceled(e);
    getSelectionModel().setSelectionInterval(activeRow, activeRow);
    this.requestFocus();
}
----------
public boolean isCellEditable(int rowIndex, int columnIndex)
{
    return super.isCellEditable(getSortableTableModel().mapRowIndexToDecoratedTable(rowIndex), columnIndex);
}
----------

And then, of course, we have lots of other code in the tables.
Avatar billede _carsten Nybegynder
25. maj 2005 - 18:26 #4
Well - it's a little hard to give a hint on this one, because of the other methods you've added, which we can't see and it proberly wouldn't do any good if we saw them, but this one _nrOfExtraColumns could cause a return of the wrong editor for a column that might contain a value which the editor can't edit - but I'm not sure

Have you tryed setting up a system for moving the table columns, to see if the crash happens at a specific column ?
Avatar billede di8leva Nybegynder
27. maj 2005 - 10:50 #5
carsten >> It happens everywhere, so it's not a special column, and not a special table.

Do you think it can have anything to do with editors? Is the editor called when moving a column? It is not after the column is moved it crashes, but during the move.
Avatar billede _carsten Nybegynder
31. maj 2005 - 21:35 #6
Sorry - I've been out of town for a few days

1. No - getCellEditor a'int called during a column move, but isCellEditable is !!

2. And you have 2 instance varibles which worries me, I can't see what they are doing
    (_nrOfExtraColumns, activeRow) and the method getSortableTableModel() and focus(e).

So, the next hint would be not to override isCellEditable(int rowIndex, int columnIndex) and see what happens, getSortableTableModel() might effect the other overrided methods and there by provide an unexpected call.
Avatar billede di8leva Nybegynder
01. juni 2005 - 10:18 #7
NP

We are going to look deeper into this sometime this, or next week. Now it has started to happen when se sort tables as well (we have written our own sortabletable with a sortabletablemodel)

btw... _nrOfExtraColumns is just that, an integer telling us how many extra columns we have to the left of the tablemodel (we have a copy-column, and a delete-column) and activerow is the last selected row.

I cannot actually remember all these things since some of them were created three years ago, so it's just trial and error from here... but thanks for the attempts.
Avatar billede di8leva Nybegynder
22. juni 2005 - 16:27 #8
Det var en fejl i Java Hotspot.

Det skal vare løst i 1.4.2_08, eller kan man måske lukke før JIT-compilern.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester