[quote=Mark_Ameba]Eu uso todos esses que voce falou.
Um JFrame principal com um JDesktopPane dentro.
Varios JInternalFrames com um JPanel dentro.
Depois coloco os JInternalFrame dentor do JDesktopPane.
JDialog não uso muito.[/quote]
Cara, tentei fazer pelo jeito que vc sugeriu:
[code]package gui;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JDesktopPane;
import java.awt.Rectangle;
import java.awt.Dimension;
import javax.swing.JButton;
public class ZeroOne extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JDesktopPane jDesktopPane = null;
private JButton btOne = null;
private JButton btTwo = null;
/**
* This is the default constructor
*/
public ZeroOne(){
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize(){
this.setSize(773, 377);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setContentPane( getJContentPane() );
this.setTitle( "JFrame" );
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane(){
if( jContentPane == null ){
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJDesktopPane(), null);
jContentPane.add(getBtOne(), null);
jContentPane.add(getBtTwo(), null);
}
return jContentPane;
}
/**
* This method initializes jDesktopPane
*
* @return javax.swing.JDesktopPane
*/
private JDesktopPane getJDesktopPane(){
if( jDesktopPane == null ){
jDesktopPane = new JDesktopPane();
jDesktopPane.setBounds(new Rectangle(78, 15, 640, 314));
}
return jDesktopPane;
}
/**
* This method initializes btOne
*
* @return javax.swing.JButton
*/
private JButton getBtOne(){
if( btOne == null ){
btOne = new JButton();
btOne.setBounds(new Rectangle(5, 62, 64, 19));
btOne.setText("ONE");
btOne.addActionListener( new java.awt.event.ActionListener() {
public void actionPerformed( java.awt.event.ActionEvent e ){
System.out.println( "actionPerformed()" ); // TODO Auto-generated Event stub actionPerformed()
btOneExecute( e );
}
} );
}
return btOne;
}
private void btOneExecute( java.awt.event.ActionEvent e ){
this.jDesktopPane.add( new TelaOne() );
}
/**
* This method initializes btTwo
*
* @return javax.swing.JButton
*/
private JButton getBtTwo(){
if( btTwo == null ){
btTwo = new JButton();
btTwo.setBounds(new Rectangle(6, 115, 64, 20));
btTwo.setText("TWO");
btTwo.addActionListener( new java.awt.event.ActionListener() {
public void actionPerformed( java.awt.event.ActionEvent e ){
System.out.println( "actionPerformed()" ); // TODO Auto-generated Event stub actionPerformed()
btOneTwoExecute( e );
}
} );
}
return btTwo;
}
private void btOneTwoExecute( java.awt.event.ActionEvent e ){
this.jDesktopPane.add( new TelaTwo() );
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ZeroOne().setVisible(true);
}
});
}
} // @jve:decl-index=0:visual-constraint=“10,10”
[/code]
/**
*
*/
package gui;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import java.awt.Color;
/**
* @author zap
*
*/
public class TelaOne extends JInternalFrame {
private JPanel jContentPane = null;
private JLabel lbInformativo = null;
/**
*
*/
public TelaOne(){
// TODO Auto-generated constructor stub
super();
initialize();
}
/**
* @param title
*/
public TelaOne( String title ){
super( title );
// TODO Auto-generated constructor stub
initialize();
}
/**
* @param title
* @param resizable
*/
public TelaOne( String title, boolean resizable ){
super( title, resizable );
// TODO Auto-generated constructor stub
initialize();
}
/**
* @param title
* @param resizable
* @param closable
*/
public TelaOne( String title, boolean resizable, boolean closable ){
super( title, resizable, closable );
// TODO Auto-generated constructor stub
initialize();
}
/**
* @param title
* @param resizable
* @param closable
* @param maximizable
*/
public TelaOne( String title, boolean resizable, boolean closable, boolean maximizable ){
super( title, resizable, closable, maximizable );
// TODO Auto-generated constructor stub
initialize();
}
/**
* @param title
* @param resizable
* @param closable
* @param maximizable
* @param iconifiable
*/
public TelaOne( String title, boolean resizable, boolean closable, boolean maximizable, boolean iconifiable ){
super( title, resizable, closable, maximizable, iconifiable );
// TODO Auto-generated constructor stub
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize(){
this.setSize( 300, 200 );
this.setContentPane( getJContentPane() );
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane(){
if( jContentPane == null ){
lbInformativo = new JLabel();
lbInformativo.setText("Esta eh a Tela ONE");
lbInformativo.setForeground(new Color(102, 153, 0));
lbInformativo.setBackground(new Color(255, 204, 0));
jContentPane = new JPanel();
jContentPane.setLayout( new BorderLayout() );
jContentPane.add(lbInformativo, BorderLayout.NORTH);
}
return jContentPane;
}
}
/**
*
*/
package gui;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JInternalFrame;
import java.awt.FlowLayout;
import javax.swing.JLabel;
import java.awt.Color;
/**
* @author zap
*
*/
public class TelaTwo extends JInternalFrame {
private JPanel jContentPane = null;
private JLabel lbInformativo = null;
/**
* This is the xxx default constructor
*/
public TelaTwo(){
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize(){
this.setSize( 300, 200 );
this.setContentPane( getJContentPane() );
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane(){
if( jContentPane == null ){
lbInformativo = new JLabel();
lbInformativo.setText("Esta eh a Tela TWO");
lbInformativo.setBackground(new Color(255, 255, 153));
lbInformativo.setForeground(new Color(255, 0, 51));
jContentPane = new JPanel();
jContentPane.setLayout(new FlowLayout());
jContentPane.add(lbInformativo, null);
}
return jContentPane;
}
}
Mas quando clico no botao nao carrega as Telas para o JDesktopPane