Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tabelas;
- import javax.swing.JFrame;
- import javax.swing.JScrollPane;
- import javax.swing.JTable;
- import javax.swing.table.DefaultTableModel;
- public class Tabelas {
- public static void main(String[] args) {
- // TODO code application logic here
- JFrame j = new JFrame("Bora mecao");
- j.setBounds(0,0,400,400);
- JTable tabela = new JTable();
- tabela.setBounds(10,10,200,200);
- j.add(tabela);
- String[] colunas = {"Marca", "Local"};
- DefaultTableModel modelo = (new DefaultTableModel(){
- @Override
- public boolean isCellEditable(int row, int column){
- return false;
- }
- });
- modelo.setColumnIdentifiers(colunas);
- modelo.setRowCount(0);
- Object[] objetos = new Object[2];
- objetos[0] = "LG";
- objetos[1] = "Chalé";
- tabela.setModel(modelo);
- JScrollPane scroll = new JScrollPane(tabela);
- contentPane.add(scroll);
- j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- j.setLayout(null);
- j.setVisible(true);
- }
- }
Add Comment
Please, Sign In to add comment