JFileChooser didn't display well, when calling it for the second time
Hello seniors & friends
I written a cell editor for JTable. its work nice when i click the cell and select a file, its work well. Then again i click the cell in the column, this time it wont display the JFileChooser dialog correctly. it will display like a Jframe becomes visible without initializing its size with setBounds or pack().
This is the code for TableCellEditor
class FileTableCellEditorextends AbstractCellEditorimplements TableCellEditor
{
private JFileChooser fileChooser;
private JPanel panel;
private JFrame owner;
public FileTableCellEditor(JFrame own)
{
owner = own;
panel =new JPanel();
fileChooser =new JFileChooser();
}
public Component getTableCellEditorComponent(JTable table,
Object value,boolean isSelected,int row,int column)
{
return panel;
}
publicboolean shouldSelectCell(EventObject anEvent)
{
int result = fileChooser.showOpenDialog(owner);
System.out.println("Printed after disposing File Dialog." + result + JFileChooser.ERROR_OPTION);
if (result == JFileChooser.APPROVE_OPTION)
{
stopCellEditing();
}
else
{
cancelCellEditing();
}
returntrue;
}
publicvoid cancelCellEditing()
{
fileChooser.setVisible(false);
super.cancelCellEditing();
}
publicboolean stopCellEditing()
{
fileChooser.setVisible(false);
super.stopCellEditing();
returntrue;
}
public Object getCellEditorValue()
{
return fileChooser.getSelectedFile();
}
}
Thanks for all

