scheide
April 7th, 2004, 01:34 AM
I've got a JDialog window that contains only a three column JTable, with a checkbox in the first column, looking like this:
CB | Item Nbr | Item Description
---------------------------------------------------
I have code (not part of the dialog window) that loops through each item in the table and as it successfully processes the item, I set the checkbox selected.
The problem I'm having is I want to display the dialog modally and so that it appears on top of the main window, execute the item processing code (which is in the main window) and update the checkbox on the modal window row by row.
All efforts so far have failed. It seems the modal window doesn't want to paint completely (I see just a gray square) and it doesn't refresh and get repainted as each item is processed (the code does get executed, it's just the gui isn't refreshed) -- the dialog and table don't get fully painted until all the components in the table have processed... thus all the checkboxes are selected at first appearance, rather than being checked one at a time.
Currently the code is structured sorta like this and I'm looking for any ideas to make it work properly:
pseduocode, don't worry about the syntax:
setupTable()
{
Runnable r = new Runnable()
{
dialog.show(true); //show JDialog that has table on it
}
SwingUtilities.invokeLater(r);
processComponents();
}
//---------------
processComponents()
{
for (int i =0; i < table.getRowCount(); i++}
{
table.setSelectedRow(i);
if (blah blah blah)
{
dothis dothat etc
table.setValueAt(true, i, 0); //update checkbox
table.invalidate();
table.repaint();
}
}
}
CB | Item Nbr | Item Description
---------------------------------------------------
I have code (not part of the dialog window) that loops through each item in the table and as it successfully processes the item, I set the checkbox selected.
The problem I'm having is I want to display the dialog modally and so that it appears on top of the main window, execute the item processing code (which is in the main window) and update the checkbox on the modal window row by row.
All efforts so far have failed. It seems the modal window doesn't want to paint completely (I see just a gray square) and it doesn't refresh and get repainted as each item is processed (the code does get executed, it's just the gui isn't refreshed) -- the dialog and table don't get fully painted until all the components in the table have processed... thus all the checkboxes are selected at first appearance, rather than being checked one at a time.
Currently the code is structured sorta like this and I'm looking for any ideas to make it work properly:
pseduocode, don't worry about the syntax:
setupTable()
{
Runnable r = new Runnable()
{
dialog.show(true); //show JDialog that has table on it
}
SwingUtilities.invokeLater(r);
processComponents();
}
//---------------
processComponents()
{
for (int i =0; i < table.getRowCount(); i++}
{
table.setSelectedRow(i);
if (blah blah blah)
{
dothis dothat etc
table.setValueAt(true, i, 0); //update checkbox
table.invalidate();
table.repaint();
}
}
}