-
/*
-
* TableTest.java
-
*
-
* Created on 08 July 2004, 11:07
-
*/
-
-
/**
-
*
-
* @author admin
-
*/
-
import javax.swing.JTable;
-
-
-
-
-
-
public MyEditor(){
-
-
-
}
-
-
public java.
awt.
Component getTableCellEditorComponent
(JTable table,
Object value,
boolean isSelected,
int row,
int column
){
-
java.
awt.
Component c = super.
getTableCellEditorComponent( table, value, isSelected, row, column
);
-
-
-
jtf.selectAll();
-
//jtf.setText("");
-
//jtf.setCaretPosition(0);
-
-
}
-
-
return c;
-
}
-
-
}
-
public class TableTest
extends javax.
swing.
JFrame {
-
-
/** Creates new form TableTest */
-
public TableTest() {
-
initComponents();
-
-
-
//jTable1.setDefaultEditor(new Object().getClass(), new MyEditor());
-
jTable2.
setDefaultEditor(new Object().
getClass(),
new MyEditor
());
-
-
}
-
-
/** This method is called from within the constructor to
-
* initialize the form.
-
* WARNING: Do NOT modify this code. The content of this method is
-
* always regenerated by the Form Editor.
-
*/
-
private void initComponents() {
-
jTable1 =
new javax.
swing.
JTable();
-
jTable2 =
new javax.
swing.
JTable();
-
jLabel1 =
new javax.
swing.
JLabel();
-
-
-
public void windowClosing
(java.
awt.
event.
WindowEvent evt
) {
-
exitForm(evt);
-
}
-
});
-
-
-
-
{"jtable1", "jtable1", "jtable1", "jtable1"},
-
{"jtable1", "jtable1", "jtable1", "jtable1"},
-
{"jtable1", "jtable1", "jtable1", "jtable1"},
-
{"jtable1", "jtable1", "jtable1", "jtable1"}
-
},
-
-
"Title 1", "Title 2", "Title 3", "Title 4"
-
}
-
));
-
-
-
-
-
{"jtable2", "jtable2", "jtable2", "jtable2"},
-
{"jtable2", "jtable2", "jtable2", "jtable2"},
-
{"jtable2", "jtable2", "jtable2", "jtable2"},
-
{"jtable2", "jtable2", "jtable2", "jtable2"}
-
},
-
-
"Title 1", "Title 2", "Title 3", "Title 4"
-
}
-
));
-
-
-
jLabel1.setText("JTable clear selection on focus loss example by cjard@hotmail.com");
-
getContentPane
().
add(jLabel1, java.
awt.
BorderLayout.
CENTER);
-
-
pack();
-
}
-
-
/** Exit the Application */
-
private void exitForm
(java.
awt.
event.
WindowEvent evt
) {
-
-
}
-
-
/**
-
* @param args the command line arguments
-
*/
-
public static void main
(String args
[]) {
-
new TableTest().show();
-
}
-
-
// Variables declaration - do not modify
-
private javax.
swing.
JLabel jLabel1;
-
private javax.
swing.
JTable jTable1;
-
private javax.
swing.
JTable jTable2;
-
// End of variables declaration
-
-
}