Your SlideShare is downloading. ×
Java Swing - Controle JTable
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Java Swing - Controle JTable

12,998
views

Published on


10 Comments
9 Likes
Statistics
Notes
No Downloads
Views
Total Views
12,998
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
378
Comments
10
Likes
9
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Sérgio Souza Costa Professor - UFMA Doutor em Computação Aplicada (INPE)
  • 2. JTable(Object[][] dados, Object[] nomeColunas) dados nomesColunas
  • 3. Object[][] data = { {"João", "Carlos", “Natação", new Integer(5)}, {"Francisco", "Silva", "Remo", new Integer(3)}, {"Fernando", "Cardoso","Montanismo", new Integer(2)}, {"Luís Inácio", "Silva","Futebol", new Integer(20)}, {"Angela", "Maria","Rapel", new Integer(4)} }; String[] colunas = {"Nome","Sobrenome","Esporte", "Prática (ano)","Vegetariano"}; final JTable table = new JTable(data , colunas );
  • 4. AbstractTableModel TableModel public int getRowCount( ) public int getColumCount( ) public Object getValueAt(int linha, int coluna) getValueAt
  • 5. AbstractTableModel – public String getColumnName(int col) AbstractTableModel getColumnName A B C getColumnName – public boolean isCellEditable(int rowIndex, int columnIndex) false
  • 6. public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } Tipo Exibe como Imagem imagem Boolean checkBox (caixa de seleção) Object String
  • 7. CellRenderer JTable
  • 8. DefaultTableModel() • DefaultTableModel JTable – getValueAt() – setValueAt() – addRow() – addColumn() JTable
  • 9. DefaultTableModel() String[][] dados = new String [][]{ {"SP","Sao Paulo"}, {"RJ","Rio de Janeiro"}, {"RN","Rio Grande do Norte"}, {"PR","Parana"} }; String[] colunas = new String []{"Estado"," Cidade"}; // Adiciona os dados em um modelo DefaultTableModel modelo = new DefaultTableModel(dados, colunas); // e passamos o modelo para criar a jtable JTable jtable = new JTable( modelo );
  • 10.
  • 11.
  • 12.
  • 13. Open Source Software Commercial Software Office and Productivity OpenOffice 2.0 Application Servers JBoss, JFox, Jonas Mathematics and Science Mathematica Object Relational Mapping Software Hibernate ObJectRelationalBridge - OJB Mr. Persister ORM Database Clustering Software C-JDBC Issue Tracking Jira TrackStudio