spv42
24-01-2007, 12:12
Salve,
Io ho una JTable con un mio CellEditor su una determinata cella.
Bene, ho installato sul celleditor un KeyLeistener ed un MouseListener.
con questi due pezzi di codice IDENTICI si comporta in modo diverso
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() > 1) {
System.out.println("MOUSE CLICK");
System.out.println(listTable.getModel().getValueAt(listTable.getSelectedRow(), 2).toString());
campo.setText(listTable.getModel().getValueAt(listTable.getSelectedRow(), 2).toString());
riempicelle();
tabella.changeSelection(riga, 2, false, false);
tabella.editCellAt(riga, 2, null);
campo.setFocusable(false);
popup.setVisible(false);
if(!e.isConsumed()) e.consume();
}
}
if(e.getKeyCode() == KeyEvent.VK_ENTER ) {
System.out.println("ENTER");
System.out.println(listTable.getModel().getValueAt(listTable.getSelectedRow(), 2).toString());
campo.setText(listTable.getModel().getValueAt(listTable.getSelectedRow(), 2).toString());
riempicelle();
tabella.changeSelection(riga, 2, false, false);
tabella.editCellAt(riga, 2);
campo.setFocusable(false);
popup.setVisible(false);
if(!e.isConsumed()) e.consume();
}
Nel primo caso la cella(riga,2) non acquisisce il Focus!!!
Nel secondo caso si (Comportamento VOLUTO).
Qualcuno sà spiegarmi perchè e come risolvere il problema del Focus Acuisito con il MouseEvent???
Grazie
Io ho una JTable con un mio CellEditor su una determinata cella.
Bene, ho installato sul celleditor un KeyLeistener ed un MouseListener.
con questi due pezzi di codice IDENTICI si comporta in modo diverso
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() > 1) {
System.out.println("MOUSE CLICK");
System.out.println(listTable.getModel().getValueAt(listTable.getSelectedRow(), 2).toString());
campo.setText(listTable.getModel().getValueAt(listTable.getSelectedRow(), 2).toString());
riempicelle();
tabella.changeSelection(riga, 2, false, false);
tabella.editCellAt(riga, 2, null);
campo.setFocusable(false);
popup.setVisible(false);
if(!e.isConsumed()) e.consume();
}
}
if(e.getKeyCode() == KeyEvent.VK_ENTER ) {
System.out.println("ENTER");
System.out.println(listTable.getModel().getValueAt(listTable.getSelectedRow(), 2).toString());
campo.setText(listTable.getModel().getValueAt(listTable.getSelectedRow(), 2).toString());
riempicelle();
tabella.changeSelection(riga, 2, false, false);
tabella.editCellAt(riga, 2);
campo.setFocusable(false);
popup.setVisible(false);
if(!e.isConsumed()) e.consume();
}
Nel primo caso la cella(riga,2) non acquisisce il Focus!!!
Nel secondo caso si (Comportamento VOLUTO).
Qualcuno sà spiegarmi perchè e come risolvere il problema del Focus Acuisito con il MouseEvent???
Grazie