Como pegar informação de uma Jtable e mostrar na JTextField ?
Jtable
A
6 Respostas
A
jtextfild1.settext(jtable1.getValueAt(jtable1.getSelectedRow(),0).toString());
//eu uso assim
A
taa mais eu ponho isso a onde?
tentei colocar em alguns lugares mais neem foi
Estou toda confusa =/
A
vc tem q colocar no evento mouseClicked da sua jtable ou no evento onChange
A
private void TabelaMouseClicked(java.awt.event.MouseEvent evt){
if (evt.getClickCount()==2){
int lin=Tabela.getSelectedRow();
txtNome.setText(Tabela.getModel().getValueAt(Tabela.getSelectedColumn(),lin).toString());
}
//Fiz isso mas não deu certo
Os parametros são linha/coluna, voce passou coluna/linha
O correto seria:
f (evt.getClickCount()==2){
int lin=Tabela.getSelectedRow();
txtNome.setText(Tabela.getModel().getValueAt(lin,Tabela.getSelectedColumn()).toString());
}
Coloque seu codigo dentro das tags CODE
A
Neem foi =/ o codigo esta assim
private void TabelaMouseClicked(java.awt.event.MouseEvent evt){
if (evt.getClickCount()==2){
int lin=Tabela.getSelectedRow();
txtNome.setText(Tabela.getModel().getValueAt(lin,Tabela.getSelectedColumn()).toString());
System.out.println("Selecionei");
}
quando clica nem aparece a mensaguem e não aparece na txtNome
Criado 17 de março de 2011
Ultima resposta 18 de mar. de 2011
Respostas 6
Participantes 3