Java Reference
In-Depth Information
getContentPane().add(splitter,BorderLayout.CENTER);
getContentPane().add(createButton,BorderLayout.SOUTH);
createButton.addActionListener(new ButtonListener());
}
private JTable createTable(int nRows){
String[] dataTypes = {"CHAR","VARCHAR","INT","FLOAT","DATE"};
String[] defNull = {"","NULL","NOT NULL"};
String[] defUnique = {"","UNIQUE"};
String[] defPriKey = {"","PRIMARY KEY"};
String[] colNames =
{"Name","DataType","SIZE","NULL","UNIQUE","PRIMARY KEY"};
String[][] rowData = new String[nRows][colNames.length];
for(int i=0;i<nRows;i++){
for(int j=0;j<colNames.length;j++)rowData[i][j]="";
}
JComboBox dTypes = new JComboBox(dataTypes);
JComboBox nullDefs = new JComboBox(defNull);
JComboBox uniqueDefs = new JComboBox(defUnique);
JComboBox primaryKDefs = new JComboBox(defPriKey);
JTable table = new JTable(rowData,colNames);
table.getColumnModel().getColumn(1).
setCellEditor(new DefaultCellEditor(dTypes));
table.getColumnModel().getColumn(3).
setCellEditor(new DefaultCellEditor(nullDefs));
table.getColumnModel().getColumn(4).
setCellEditor(new DefaultCellEditor(uniqueDefs));
table.getColumnModel().getColumn(5).
setCellEditor(new DefaultCellEditor(primaryKDefs));
return table;
}
public String parseTable(){
String tableValues = "";
int rows = table.getRowCount();
int cols = table.getColumnCount();
Search WWH ::




Custom Search