Guest User

Untitled

a guest
Mar 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. package tabelas;
  2.  
  3. import javax.swing.JFrame;
  4. import javax.swing.JScrollPane;
  5. import javax.swing.JTable;
  6. import javax.swing.table.DefaultTableModel;
  7.  
  8. public class Tabelas {
  9.  
  10. public static void main(String[] args) {
  11. // TODO code application logic here
  12. JFrame j = new JFrame("Bora mecao");
  13. j.setBounds(0,0,400,400);
  14.  
  15. JTable tabela = new JTable();
  16. tabela.setBounds(10,10,200,200);
  17.  
  18. j.add(tabela);
  19.  
  20. String[] colunas = {"Marca", "Local"};
  21.  
  22. DefaultTableModel modelo = (new DefaultTableModel(){
  23. @Override
  24. public boolean isCellEditable(int row, int column){
  25. return false;
  26. }
  27. });
  28.  
  29. modelo.setColumnIdentifiers(colunas);
  30. modelo.setRowCount(0);
  31.  
  32. Object[] objetos = new Object[2];
  33. objetos[0] = "LG";
  34. objetos[1] = "Chalé";
  35.  
  36. tabela.setModel(modelo);
  37.  
  38. JScrollPane scroll = new JScrollPane(tabela);
  39. contentPane.add(scroll);
  40.  
  41. j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  42. j.setLayout(null);
  43. j.setVisible(true);
  44.  
  45. }
  46.  
  47. }
Add Comment
Please, Sign In to add comment