问题描述
我是这个地方的业余爱好者,期待正确地写出我的疑问。我需要有 10 点声誉才能添加图像。我插入了图片的链接。
如果我“by DNI”离开搜索引擎,则所选行会在控制台绘图 (System.out.print
) 中正确显示,但如果我编写 DNI 模式来定位符合该模式的用户,我选择其中一个,我想要的那个没有按照那个模式显示,而是显示了表中的第一个(没有通过 DNI 搜索)。好像没有检测到表已经更新,继续保持默认值(DNI jTextField
为空)。
有什么问题吗?
代码:
public void filtrar_dni() {
int columna = 0;
TRSFiltro.setRowFilter(RowFilter.regexFilter(textfield_buscar.getText(),columna));
}
代码(KeyTyped)jtextfield_DNI:
private void textfield_buscarKeyTyped(java.awt.event.KeyEvent evt) {
Character letra = evt.getKeyChar();
evt.setKeyChar(Character.toupperCase(letra));
textfield_buscar.addKeyListener(new KeyAdapter(){
public void keyreleased(final KeyEvent e){
String texto = (textfield_buscar.getText());
textfield_buscar.setText(texto);
filtrar_dni();
}
});
TRSFiltro = new tablerowsorter<DefaultTableModel>((DefaultTableModel) tabla_clientes.getModel());
tabla_clientes.setRowSorter(TRSFiltro);
}
代码 - 当您点击表格中的一行时:
private void tabla_clientesMouseClicked(java.awt.event.MouseEvent evt) {
int nFilasSelec = tabla_clientes.getSelectedRowCount();
if(nFilasSelec>=0)
button_deseleccion.setEnabled(true);
else
button_deseleccion.setEnabled(false);
int filasselec[] = tabla_clientes.getSelectedRows();
DefaultTableModel modelotabla = (DefaultTableModel) tabla_clientes.getModel();
for(int i=0; i<filasselec.length; i++){
String DNI = (String)modelotabla.getValueAt(filasselec[i],0);
String nombre = (String) modelotabla.getValueAt(filasselec[i],1);
String apellidos = (String)modelotabla.getValueAt(filasselec[i],2);
String telefono = (String)modelotabla.getValueAt(filasselec[i],3);
String direccion = (String)modelotabla.getValueAt(filasselec[i],4);
String ciudad = (String)modelotabla.getValueAt(filasselec[i],5);
String email = (String)modelotabla.getValueAt(filasselec[i],6);
Cliente c = new Cliente(nombre,apellidos,DNI,telefono,direccion,ciudad,email);
System.out.println(c.toString());
}
}
为什么从 JTable
中选择一行时不检测 DNI 过滤?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)