...
private MeinDialog meinDialog;
...
jTable1.setCellSelectionEnabled(true);
jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jTable1MouseReleased(evt);
}
});
...
private void jTable1MouseReleased(java.awt.event.MouseEvent evt) {
if(evt.getClickCount() == 2){
meinDialog = new MeinDialog(this, true);
meinDialog.setLocationRelativeTo(this);
meinDialog.setVisible(true);
}
}
...
class MeinDialog extends JDialog{
private JTextField tf;
private JButton bt;
public MeinDialog(Frame parent, boolean modal){
super(parent, "Editor", modal);
setSize(200,70);
tf = new JTextField((String) jTable1.getValueAt(jTable1.getSelectedRow(), jTable1.getSelectedColumn()));
tf.selectAll();
bt = new JButton("OK");
add(tf, BorderLayout.NORTH);
add(bt, BorderLayout.SOUTH);
getRootPane().setDefaultButton(bt);
bt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jTable1.setValueAt(tf.getText(), jTable1.getSelectedRow(), jTable1.getSelectedColumn());
dispose();
}
});
}
}
...