JTable如果在编辑状态下,当要保存的时候,比如直接点保存按钮,得到的数据不是编辑状态下的数据,琢磨出一个方法,记录一下:
i和j表示正在被编辑的行号列号
CellEditor ce = md.getCellEditor(i,j);
//CellEditor ce = md.getCellEditor(md.getEditingRow(), md.getEditingColumn());
ce.stopCellEditing();
Object value = ce.getCellEditorValue();
// model.setValueAt(value,md.getEditingRow(), md.getEditingColumn());
model.setValueAt(value,i,j);
获取网卡物理地址:
String cmd="ipconfig /all";
Process p=Runtime.getRuntime().exec(cmd);
BufferedReader bis=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line="";
while((line=bis.readLine())!=null){
if(line.indexOf("Physical Address")!=-1){
Pattern ptn=Pattern.compile("((\\w{2})|(\\d{2})|(\\w+\\d+)|(\\d+\\w+))-.*");
Matcher m=ptn.matcher(line.trim());
while(m.find()){
System.out.println("get mac "+m.group());
}
}
}