Metodo main

5 respostas
wg_vasconcelos

Bom dia Pessoal!!!!!!!!
Estou com com uma duvida em criar o metodo main que execute esta classe, peguei alguns exemplos na net mas não deu certo, e não entendi pq não deu certo, se puderem me ajudar fico muito agradecido. Segue abaixo o codigo para analisarem. Outra duvida, caso adicione algum botão ou caixa de texto o metodo main irá mudar? Se alguem puder me ajudar ficarei muito agradecido. Muito Obrigada.

/*
 
package teste3;

public class Cadastro extends javax.swing.JPanel {

    /** Creates new form Cadastro */
    public Cadastro() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jTabbedPaneCad = new javax.swing.JTabbedPane();
        jPanelCad = new javax.swing.JPanel();
        jPanelDados = new javax.swing.JPanel();

        org.jdesktop.layout.GroupLayout jPanelCadLayout = new org.jdesktop.layout.GroupLayout(jPanelCad);
        jPanelCad.setLayout(jPanelCadLayout);
        jPanelCadLayout.setHorizontalGroup(
            jPanelCadLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 395, Short.MAX_VALUE)
        );
        jPanelCadLayout.setVerticalGroup(
            jPanelCadLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 264, Short.MAX_VALUE)
        );

        jTabbedPaneCad.addTab("Cadastro", jPanelCad);

        org.jdesktop.layout.GroupLayout jPanelDadosLayout = new org.jdesktop.layout.GroupLayout(jPanelDados);
        jPanelDados.setLayout(jPanelDadosLayout);
        jPanelDadosLayout.setHorizontalGroup(
            jPanelDadosLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 395, Short.MAX_VALUE)
        );
        jPanelDadosLayout.setVerticalGroup(
            jPanelDadosLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 264, Short.MAX_VALUE)
        );

        jTabbedPaneCad.addTab("Dados", jPanelDados);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jTabbedPaneCad, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jTabbedPaneCad, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE))
        );
    }// </editor-fold>


    // Variables declaration - do not modify
    private javax.swing.JPanel jPanelCad;
    private javax.swing.JPanel jPanelDados;
    private javax.swing.JTabbedPane jTabbedPaneCad;
    // End of variables declaration

}

5 Respostas

gui_sv

seria isso ?

public static void main(String[] a){
      new Cadastro();
}
tebosoftware

Se você quiser exibir o JPanel você pode fazer assim

public static void main(String[] args){ JFrame j = new JFrame(); j.add(new Cadastro()); j.pack(); j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); j.setVisible(true); }

se for outra coisa, post ai

P

gui_sv:
seria isso ?

public static void main(String[] a){ new Cadastro(); }

A classe Cadastro é um JPanel. O que ela deve estar querendo é criar uma janela e exibí-lo. Seria isso mesmo, wg_vasconselos?

PS> Esta mensagem foi escrita alguns segundos após o post do tebosoftware. Se quiserem deletá-la, fiquem à vontade.

Até mais,
PH

wg_vasconcelos

tebosoftware:
Se você quiser exibir o JPanel você pode fazer assim

public static void main(String[] args){ JFrame j = new JFrame(); j.add(new Cadastro()); j.pack(); j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); j.setVisible(true); }

se for outra coisa, post ai

Po meu valeu cara, vc quebrou um galhão, valeu mesmo.

Abraço.

tebosoftware

De nada qualquer coisa posta ai.

falow

Criado 14 de outubro de 2008
Ultima resposta 14 de out. de 2008
Respostas 5
Participantes 4