Componentes Swing some ao abrir JFrame maximizado

E ai galera blz?

Sou iniciante em java e estou tentando aprender sozinho. ;D. Achei uma sintaxe para abrir meu jframe maximizado

jfrm_principal.setExtendedState(jfrm_principal.getExtendedState()|JFrame.MAXIMIZED_BOTH);

funciona, mas ao abrir meu JMenuBar não aparece, nem outros componentes do swing.

Alguém pode me ajudar?

Se você postasse seu código, seria mais fácil de sabermos o que acontece. ^^

Cara, não sei se resolve, mas tenta substituir

jfrm_principal.setExtendedState(jfrm_principal.getExtendedState()|JFrame.MAXIMIZED_BOTH);

por

jfrm_principal.setExtendedState(JFrame.MAXIMIZED_BOTH);

Dá uma olhada no tipo de Layout que vocês está usando, as vezes acontece isso mesmo. Se for o caso, use o Absoluto ou o Livre.

Nicolas Fernandes

Eu estou dando os meus primeiros passos em java usando o netbeans 6.9.1, então por favor não repare na simplicidade do código =D

[code]/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */

/*

  • jfrm_principal.java
  • Created on 27/10/2010, 09:50:31
    */

package formularios;

import javax.swing.JFrame;

/**
*

  • @author Carlos
    */
    public class jfrm_principal extends javax.swing.JFrame {

    /** Creates new form jfrm_principal */
    public jfrm_principal() {
    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”)
      //
      private void initComponents() {

      jmnb_principal = new javax.swing.JMenuBar();
      jmnu_cadastros = new javax.swing.JMenu();
      jmnuItem_clientes = new javax.swing.JMenuItem();
      jMenu2 = new javax.swing.JMenu();

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

      jmnu_cadastros.setText(“Cadastro”);

      jmnuItem_clientes.setText(“Clientes”);
      jmnuItem_clientes.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jmnuItem_clientesActionPerformed(evt);
      }
      });
      jmnu_cadastros.add(jmnuItem_clientes);

      jmnb_principal.add(jmnu_cadastros);

      jMenu2.setText(“Edit”);
      jmnb_principal.add(jMenu2);

      setJMenuBar(jmnb_principal);

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 883, Short.MAX_VALUE)
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 497, Short.MAX_VALUE)
      );

      pack();
      }//

    private void jmnuItem_clientesActionPerformed(java.awt.event.ActionEvent evt) {
    new jfrm_clientes().setVisible(true);
    }

    /**

    • @param args the command line arguments
      /
      public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
      JFrame jfrm_principal = new JFrame();
      /
      jfrm_principal.setExtendedState(jfrm_principal.getExtendedState()|JFrame.MAXIMIZED_BOTH);
      Mesmo trocando não funcionou…
      */
      jfrm_principal.setExtendedState(JFrame.MAXIMIZED_BOTH);
      jfrm_principal.setVisible(true);
      }
      });
      }

    // Variables declaration - do not modify
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jmnb_principal;
    private javax.swing.JMenuItem jmnuItem_clientes;
    private javax.swing.JMenu jmnu_cadastros;
    // End of variables declaration

}
[/code]

Edenilton Fr?s

Kara não funcionou não, mas vlw, vou continuar tentando, se alguém souber de como abrir o form maximizado agradeço!
vlw

LarissaNepomuceno

estou usando o netbeans 6.9.1, não faço nem idéia de como ver o layout

como eu faço isso?

flw galera!