GUJ
Notícias, artigos e o maior fórum brasileiro sobre Java
home
fórum
notícias
tópicos recentes
empregos
artigos
Bem-vindo ao GUJ.
Crie seu login
, ou digite-o para logar no site.
Usuário:
Senha:
MdiForm centralizado no NetBeans
Índice dos Fóruns
»
Interface Gráfica
Autor
Mensagem
02/02/2012 15:46:50
Assunto:
MdiForm centralizado no NetBeans
andsuriano
JavaBaby
Membro desde: 19/11/2010 18:41:29
Mensagens: 97
Offline
Boa tarde.......
Como faço para que meu mdiForm apareça centralizado????
Não encontrei nada na aba propriedades do netbeans..........
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Telas; import java.awt.Dimension; import java.awt.Toolkit; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JInternalFrame; /** * * @author Usuario */ public class MdiForm extends javax.swing.JFrame { /** * Creates new form MdiForm */ public MdiForm() { 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() { jMenu1 = new javax.swing.JMenu(); jMenu2 = new javax.swing.JMenu(); desktopPane = new javax.swing.JDesktopPane(); menuBar = new javax.swing.JMenuBar(); jMenu3 = new javax.swing.JMenu(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem1 = new javax.swing.JMenuItem(); jMenu1.setText("jMenu1"); jMenu2.setText("jMenu2"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setAlwaysOnTop(true); menuBar.setBorder(null); menuBar.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); menuBar.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N menuBar.setName(""); menuBar.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { menuBarAncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); jMenu3.setText("Forms"); jMenuItem2.setText("Form1"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu3.add(jMenuItem2); jMenuItem1.setText("Form2"); jMenuItem1.setToolTipText(""); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu3.add(jMenuItem1); menuBar.add(jMenu3); setJMenuBar(menuBar); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE) ); pack(); }// </editor-fold> private void menuBarAncestorAdded(javax.swing.event.AncestorEvent evt) { // TODO add your handling code here: } public static void centralizar(JInternalFrame fr){ Dimension d = fr.getDesktopPane().getSize(); fr.setLocation((d.width - fr.getSize().width) / 2, (d.height - fr.getSize().height) / 2); } private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) { Frame1 frm1; try { frm1 = new Frame1(); desktopPane.add(frm1); frm1.setVisible(true); centralizar(frm1); } catch (ClassNotFoundException ex) { Logger.getLogger(MdiForm.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { Logger.getLogger(MdiForm.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(MdiForm.class.getName()).log(Level.SEVERE, null, ex); } } private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } /** * @param args the command line arguments */ public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MdiForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MdiForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MdiForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MdiForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MdiForm().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JDesktopPane desktopPane; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JMenuBar menuBar; // End of variables declaration }
02/02/2012 21:33:06
Assunto:
Re:MdiForm centralizado no NetBeans
ViniGodoy
Moderador
Membro desde: 11/12/2006 08:22:01
Mensagens: 20580
Localização: Curitiba/PR
Offline
Tópico movido para o fórum de interface gráfica.
@ViniGodoy
-
Lattes
Tem dúvidas de Java? Poste no fórum!
Não respondo dúvidas de java via MP!
Ponto V! - Desenvolvimento de Jogos Profissional
-
@Pontov
-
Facebook
Projeto Towel - Swing de uma forma inteligente (Novo lar do ObjectTableModel e do Auto-Filtro).
Ei... você está usando DefaultTableModel no seu projeto??
Não faça isso!
Veja:
http://www.guj.com.br/posts/list/15/199067.java#1001295
Índice dos Fóruns
»
Interface Gráfica
Ir para:
Selecione um Fórum
Notícias
Assuntos gerais (Off-topic)
MundoJ - Artigos, Notícias e Debates
Artigos e Tutoriais
Java Básico
Java Avançado
Ferramentas, Frameworks e Utilitários
Desenvolvimento Web
Interface Gráfica
Google Android e Java Micro Edition (ME)
Certificação Java
Persistência: Hibernate, JPA, JDBC e outros
Java Enterprise Edition (Java EE)
Frameworks e Bibliotecas brasileiros
RIA - Flex, JavaFX e outros
Arquitetura de Sistemas
Metodologias de Desenvolvimento e Testes de Software
JavaScript
Ruby & Ruby on Rails
Outras Linguagens
Powered by
JForum 2.1.8
©
JForum Team