100 lines
4.9 KiB
Java
100 lines
4.9 KiB
Java
import java.awt.Color;
|
|
import java.awt.*;
|
|
import javax.swing.*;
|
|
import javax.swing.table.*;
|
|
import javax.swing.event.*;
|
|
import java.awt.event.*;
|
|
public class clsTabelaTempoTotal
|
|
{
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//ATRIBUTOS//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
JTable tblTabela;
|
|
int valor;
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//CONSTRUTOR//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
public clsTabelaTempoTotal(int pLargura, int pAltura)
|
|
{
|
|
tblTabela = new JTable();
|
|
valor = 0;
|
|
atribuirModelo();
|
|
atribuirRenderer();
|
|
tblTabela.setPreferredScrollableViewportSize(new Dimension(pLargura, pAltura));
|
|
tblTabela.setTableHeader(null);
|
|
}
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//FUNÇÕES PÚBLICAS//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//FUNÇÕES PÚBLICAS -> GETTERS AND SETTERS//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//FUNÇÕES PÚBLICAS -> GETTERS AND SETTERS -> TABLE//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
public JTable getTable()
|
|
{
|
|
return tblTabela;
|
|
}
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//FUNÇÕES PÚBLICAS -> WORK//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//FUNÇÕES PÚBLICAS -> WORK -> ATUALIZAR TABELA//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
public void atualizarTabela()
|
|
{
|
|
tblTabela.updateUI();
|
|
}
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//FUNÇÕES PÚBLICAS -> WORK -> INCREMENTAR VALOR//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
public void incrementarValor()
|
|
{
|
|
valor++;
|
|
atualizarTabela();
|
|
}
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//FUNÇÕES PRIVADAS//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//FUNÇÕES PRIVADAS -> ATRIBUIR RENDERER//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
private void atribuirRenderer()
|
|
{
|
|
tblTabela.setDefaultRenderer(Object.class,
|
|
new DefaultTableCellRenderer()
|
|
{
|
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)
|
|
{
|
|
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
|
|
setHorizontalAlignment(CENTER);
|
|
return this;
|
|
}
|
|
}
|
|
);
|
|
}
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
//FUNÇÕES PRIVADAS -> ATRIBUIR MODELO//
|
|
//--------------------------------------------------------------------------------------------------------------------------//
|
|
private void atribuirModelo()
|
|
{
|
|
tblTabela.setModel(
|
|
new AbstractTableModel()
|
|
{
|
|
public int getColumnCount()
|
|
{
|
|
return 1;
|
|
}
|
|
public int getRowCount()
|
|
{
|
|
return 1;
|
|
}
|
|
public Object getValueAt(int row, int col)
|
|
{
|
|
return new Integer(valor);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
} |