P
poorichard
hi,all
I'd to start editing the cell at row and column programatically,
the method JTable.editCellAt(row,col) is for that,
but there is something wrong in my code ,I think,
the whole code is as follows,
public class FrameTest {
Logger logger = Logger.getLogger(FrameTest.class.getName());
static int width = 500;
static int height = 300;
JFrame frame;
public FrameTest(){
logger.setLevel(Level.ALL);
createUI();
}
JTable table;
public void createUI(){
logger.fine("start createUI");
frame = new JFrame("TestFrame");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setPreferredSize(new Dimension(width,height));
initTable();
table.requestFocusInWindow();
boolean d = table.editCellAt(0, 1);
frame.add(new JScrollPane(table));
frame.pack();
frame.setVisible(true);
}
DefaultTableModel tableModel;
static final String[] columnNames = {"a","b","c","d","e","f","g","h"};
private void initTable(){
tableModel = new DefaultTableModel(columnNames,2);
table = new JTable(tableModel);
table.setRowSelectionAllowed(false);
table.requestFocusInWindow();
boolean isEditing = table.editCellAt(0, 1);
logger.info("isEditing?:"+isEditing);
}
public static void main(String[] args){
new FrameTest();
}
}
it can't work yet in my PC,
the platform I used is Eclipse3.2/3.1 and JDK1.5/1.6,
is there something wrong?
(I had post it half an hour ago,but it not show ,
so I post it again )
best regards,
Richard
I'd to start editing the cell at row and column programatically,
the method JTable.editCellAt(row,col) is for that,
but there is something wrong in my code ,I think,
the whole code is as follows,
public class FrameTest {
Logger logger = Logger.getLogger(FrameTest.class.getName());
static int width = 500;
static int height = 300;
JFrame frame;
public FrameTest(){
logger.setLevel(Level.ALL);
createUI();
}
JTable table;
public void createUI(){
logger.fine("start createUI");
frame = new JFrame("TestFrame");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setPreferredSize(new Dimension(width,height));
initTable();
table.requestFocusInWindow();
boolean d = table.editCellAt(0, 1);
frame.add(new JScrollPane(table));
frame.pack();
frame.setVisible(true);
}
DefaultTableModel tableModel;
static final String[] columnNames = {"a","b","c","d","e","f","g","h"};
private void initTable(){
tableModel = new DefaultTableModel(columnNames,2);
table = new JTable(tableModel);
table.setRowSelectionAllowed(false);
table.requestFocusInWindow();
boolean isEditing = table.editCellAt(0, 1);
logger.info("isEditing?:"+isEditing);
}
public static void main(String[] args){
new FrameTest();
}
}
it can't work yet in my PC,
the platform I used is Eclipse3.2/3.1 and JDK1.5/1.6,
is there something wrong?
(I had post it half an hour ago,but it not show ,
so I post it again )
best regards,
Richard