Aca les pongo el codigo
Cita:
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Event;
import java.awt.LayoutManager;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Dimension;
import java.awt.Point;
public class Principal extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JButton jButton = null;
private JDialog dialogo = new JDialog(this,"Hola",true);
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setText("Llamado a la siguiente Ventana");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
llamada();
}
});
}
return jButton;
}
private void llamada(){
Ventana vent = new Ventana();
dialogo.add(vent);
dialogo.setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Principal thisClass = new Principal();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_ CLOSE);
thisClass.setVisible(true);
}
});
}
/**
* This is the default constructor
*/
public Principal() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
dialogo.setSize(new Dimension(200, 100));
dialogo.setLocation(new Point(100, 100));
this.setSize(300, 200);
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(new BorderLayout());
jContentPane.add(getJButton(), BorderLayout.NORTH);
}
return jContentPane;
}
}
import java.awt.BorderLayout;
import java.awt.Event;
import java.awt.LayoutManager;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Dimension;
import java.awt.Point;
public class Principal extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JButton jButton = null;
private JDialog dialogo = new JDialog(this,"Hola",true);
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setText("Llamado a la siguiente Ventana");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
llamada();
}
});
}
return jButton;
}
private void llamada(){
Ventana vent = new Ventana();
dialogo.add(vent);
dialogo.setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Principal thisClass = new Principal();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_ CLOSE);
thisClass.setVisible(true);
}
});
}
/**
* This is the default constructor
*/
public Principal() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
dialogo.setSize(new Dimension(200, 100));
dialogo.setLocation(new Point(100, 100));
this.setSize(300, 200);
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(new BorderLayout());
jContentPane.add(getJButton(), BorderLayout.NORTH);
}
return jContentPane;
}
}
Cita:
import java.awt.GridBagLayout;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JLabel;
import sun.java2d.Disposer;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
public class Ventana extends JPanel {
private static final long serialVersionUID = 1L;
private JButton jButton = null;
private JButton jButton1 = null;
private JLabel jLabel = null;
/**
* This is the default constructor
* @param dialogo
* @param i
*/
public Ventana() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridwidth = 2;
gridBagConstraints2.gridy = 0;
jLabel = new JLabel();
jLabel.setText("Esta es una ventana comun");
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.insets = new Insets(0, 0, 0, 0);
gridBagConstraints1.gridy = 1;
gridBagConstraints1.ipadx = 0;
gridBagConstraints1.ipady = -2;
gridBagConstraints1.gridx = 1;
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = new Insets(0, 0, 0, 0);
gridBagConstraints.gridy = 1;
gridBagConstraints.ipadx = 0;
gridBagConstraints.ipady = -1;
gridBagConstraints.gridx = 0;
this.setSize(232, 93);
this.setLayout(new GridBagLayout());
this.add(getJButton(), gridBagConstraints);
this.add(getJButton1(), gridBagConstraints1);
this.add(jLabel, gridBagConstraints2);
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setText("Aceptar");
}
return jButton;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setText("Cancelar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
}
});
}
return jButton1;
}
} // @jve:decl-index=0:visual-constraint="10,25"
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JLabel;
import sun.java2d.Disposer;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
public class Ventana extends JPanel {
private static final long serialVersionUID = 1L;
private JButton jButton = null;
private JButton jButton1 = null;
private JLabel jLabel = null;
/**
* This is the default constructor
* @param dialogo
* @param i
*/
public Ventana() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.gridwidth = 2;
gridBagConstraints2.gridy = 0;
jLabel = new JLabel();
jLabel.setText("Esta es una ventana comun");
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.insets = new Insets(0, 0, 0, 0);
gridBagConstraints1.gridy = 1;
gridBagConstraints1.ipadx = 0;
gridBagConstraints1.ipady = -2;
gridBagConstraints1.gridx = 1;
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.insets = new Insets(0, 0, 0, 0);
gridBagConstraints.gridy = 1;
gridBagConstraints.ipadx = 0;
gridBagConstraints.ipady = -1;
gridBagConstraints.gridx = 0;
this.setSize(232, 93);
this.setLayout(new GridBagLayout());
this.add(getJButton(), gridBagConstraints);
this.add(getJButton1(), gridBagConstraints1);
this.add(jLabel, gridBagConstraints2);
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setText("Aceptar");
}
return jButton;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setText("Cancelar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
}
});
}
return jButton1;
}
} // @jve:decl-index=0:visual-constraint="10,25"