Pessoal, é o seguinte.
Crei um Frame principal coloquei nele
um JDesktopPane. Estou chamando um JInternalFrame.
Quando chamo o JInternalFrame ele abre maximizado, ocupando todo
o tamanho do JDesktopPane.
Só que no construtor dele eu defini outros tamanhos.
Me parece que o método pack(), do Frame principal é que
faz ele ocupar todo o tamanho do JDesktopPane, mas nao sei
como alterar isto.
Alguém tem um exemplo, uma solução?
Valeu.
package projetoteste;
/**
*
* @author andersonc
*/
public class formMunicipios extends javax.swing.JInternalFrame {
/** Creates new form formMunicipios */
public formMunicipios() {
initComponents();
iniciar ();
}
private void iniciar(){
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
}
private void initComponents() {
jToolBar1 = new javax.swing.JToolBar();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
getContentPane().setLayout(null);
jButton1.setText("Sair");
jToolBar1.add(jButton1);
jButton2.setText("Salvar");
jToolBar1.add(jButton2);
jButton3.setText("Novo");
jToolBar1.add(jButton3);
jButton4.setText("Proxmo");
jButton4.setPreferredSize(new java.awt.Dimension(47, 30));
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jToolBar1.add(jButton4);
getContentPane().add(jToolBar1);
jToolBar1.setBounds(0, 0, 190, 30);
pack();
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JToolBar jToolBar1;
// End of variables declaration
}
package projetoteste;
import javax.swing.*;
public class formPrincipal extends javax.swing.JFrame {
JInternalFrame formun;
/** Creates new form formPrincipal */
public formPrincipal() {
initComponents();
iniciar();
}
private void iniciar (){
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0, 0, screenSize.width, screenSize.height);
formun = new formMunicipios();
getContentPane().add(formun);
}
private void initComponents() {
jDesktopPane1 = new javax.swing.JDesktopPane();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jItemSair = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jitemMun = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jDesktopPane1.setBackground(java.awt.Color.white);
getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER);
jMenu1.setText("Arquivo");
jItemSair.setText("Sair");
jItemSair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jItemSairActionPerformed(evt);
}
});
jMenu1.add(jItemSair);
jMenuBar1.add(jMenu1);
jMenu2.setText("Cadastro");
jitemMun.setText("Municipios");
jitemMun.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jitemMunActionPerformed(evt);
}
});
jMenu2.add(jitemMun);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
pack();
}
private void jitemMunActionPerformed(java.awt.event.ActionEvent evt) {
formun.setVisible(true);
}
private void jItemSairActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new formPrincipal().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JDesktopPane jDesktopPane1;
private javax.swing.JMenuItem jItemSair;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jitemMun;
// End of variables declaration
}
[color=red]Mensagem do Moderador: ao postar codigos utilize as tags [ code ] [ /code ][/color]