AbstractTableModel

2 respostas
J

Boa tarde a todos!

Tenho a seguinte classe:

public class Tabela extends AbstractTableModel
{
     public Tabela( String sql ){}

     public Class getColumnClass( int coluna ) throws IllegalStateException

     public int getColumnCount() throws IllegalStateException{}

     public String getColumnName( int coluna ) throws IllegalStateException{}

     public int getRowCount() throws IllegalStateException{}

     public Object getValueAt( int linha, int coluna ) throws IllegalStateException{}

     public void setQuery( String consulta ) throws SQLException, IllegalStateException{}
}
...
JTable t = new JTable( new Tabela(sql) );
add( new JScrollPane( t ), BorderLayout.CENTER );
...

Acontece que os registros, vindos da tabela do banco, são listados normalmente.
É possível ajustar a largura dos campos, para que toda vez que os registros
forem exibidos, não precisar alterar?

Por exemplo, o campo código, não precisa ser visualmente tão grande, quanto o campo observação!
Como definir isso?

2 Respostas

E

http://www.exampledepot.com/egs/javax.swing.table/ColSize.html

J

Opa, é isso mesmo! Obrigado

Criado 12 de agosto de 2011
Ultima resposta 12 de ago. de 2011
Respostas 2
Participantes 2