Como mostrar uma JTable em uma janela JFrame

4 respostas
Thiago_de_Paula_Bese

Olá Pessoal

Quem puder ajudar, com grande favor, como faço para mostrar uma jtable em uma janela JFrame.

Grato.

4 Respostas

R

Dê uma olhada neste tutorial:

http://www.guj.com.br/article.show.logic?id=140

diego.sas

Thiago de Paula Beserra:
Olá Pessoal

Quem puder ajudar, com grande favor, como faço para mostrar uma jtable em uma janela JFrame.

Grato.

Boa noite espero que o exemplo o ajude.

package jtable;

import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;

public class ExeJtable extends JFrame {

    private JLabel lExe;
    private JPanel pane1, pane2, pane4;
    private JTable jttable;

    @SuppressWarnings("deprecation")
    public ExeJtable(String Title) {
        super(Title);
        lExe = new JLabel("Exemplo de JTable: ");
        jttable = new JTable(5, 5);
    }

    private void criaMostraGui() {
        // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new GridLayout(2, 1));

        pane1 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        pane1.add(lExe);
        add(pane1);

        pane2 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        pane2.add(jttable);
        add(pane2);
        setLocation(350, 250);
        setSize(250, 200);
        // pack();
        setVisible(true);
    }

    public static ExeJtable visual() {
        ExeJtable acesso = new ExeJtable("JTable");
        acesso.criaMostraGui();
        return acesso;
    }

    public static void main(String[] args) {
        // TODO code application logic here
        visual();
    }
}

– Inserindo as tags code By Lina –

AndreMendes

Use as tags “code” para postar trechos de código.
Fica mais facil para ler.

ViniGodoy

Siga os links da minha assinatura. O que fala sobre TableModel.

Criado 15 de setembro de 2010
Ultima resposta 16 de set. de 2010
Respostas 4
Participantes 5