import java.awt.<em>;
import javax.swing.</em>;
import javax.swing.table.DefaultTableCellRenderer;
public class Janela extends JFrame{
//Componentes gráficos
Container tela = this.getContentPane();
JTable tabela;
JScrollPane scroll;
String colunas[] ={“Colocação”,“Time”,“Pontos”};
String linhas[][] = {
{"1","2","3"},
{"4","5","6"},
{"7","8","9"},
{"10","11","12"},
{"13","14","15"},
{"16","17","18"},
{"19","20","21"},
{"22","23","24"},
{"25","26","27"},
{"28","29","30"},
{"31","32","33"},
{"34","35","36"},
{"37","38","39"},
{"40","41","42"},
{"43","44","45"},
{"46","47","48"},
{"49","50","51"},
{"52","53","54"},
{"55","56","57"},
{"58","59","60"}
};
//Construtor
public Janela(){
//Criar a Tabela(JTable)
tabela = new JTable(linhas,colunas);
//Mudando cores,fontes,tamanhos etc.
//Mudando a cor de fundo da Tela
tela.setBackground(new Color(148,206,232));
//Mudando a fonte da Tabela
tabela.setFont(new Font("Verdana",0,12));
//Mudando cor do fundo do nome das colunas
tabela.getTableHeader().setBackground(new Color(0,255,64));
tabela.getTableHeader().setFont(new Font("Comic Sans MS",1,15));
//Inserindo ícone na Tabela
//Mudando a cor das linhas
tabela.setDefaultRenderer(Object.class,
new DefaultTableCellRenderer(){
public Component getTableCellRendererComponent(
JTable table, Object value,boolean isSelected,
boolean hasFocus,int linha,int coluna){
super.getTableCellRendererComponent(table,value,
isSelected,hasFocus,linha,coluna);
if(linha == 0){
setBackground(new Color(255,255,128));
setForeground(Color.BLACK);
}else if (linha>=1&&linha<=4){
setBackground( new Color(135,220,248));
}else if (linha>=5 && linha<=11){
setBackground( new Color(136,145,217));
}else if (linha>=16){
setBackground( new Color(231,24,24));
setForeground(Color.WHITE);
}else {
setBackground(null);
setForeground(null);
}
return this;
}
});
//Criar o painel de Scroll com a Tabela
scroll = new JScrollPane(tabela);
//Acertando o tamanho do painel de scroll(com JTable)
scroll.setBounds(30,30,300,339);
//Adicionando o painel de scroll na tela
this.setLayout(null);//Informa que vou organizar a janela
tela.add(scroll);
//Mexendo nas configurações
//Alterando o Título da Janela
this.setTitle(“Classificação”);
//Alterando o tamanho da Janela
this.setSize(350,400);
//Alterando para fechar a Janela
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
//Alterando para mostrar a Janela
this.setVisible(true);
}
}