Aquí les dejo un ejemplo creado a mano de un JDialog el código esta comentado así que no necesita mas explicación
package mx.com.programita;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/**
* @author www.JaverosAnonimos.tk
*/
public class TestJDialog extends javax.swing.JDialog implements ActionListener{
public TestJDialog(JFrame jframe, boolean modal){
JButton boton;
//Se pone el titulo a la ventana
this.setTitle("Mi JDialog");
//Se crea un Layout y se agrega al contenedor del dialog
this.getContentPane().setLayout(new FlowLayout());
//Se crea el botón
boton= new JButton("Probar Mensaje");
//Se agrega el boton al contenedor del dialog
this.getContentPane().add(boton);
//Se agrega el Listener al botón
boton.addActionListener(this);
//Se hace la ventana visible
this.setBounds(400, 200, 300, 300);
//Se hace la ventana visible
this.setVisible(true);
}
public static void main(String args[]) {
//Se crea un JDialog Recibe un JFrame y se indica el modal true o false
TestJDialog dialog = new TestJDialog(new JFrame(), true);
}
//Este método ejecuta el código del botón al pulsarlo
public void actionPerformed (ActionEvent e){
JOptionPane.showMessageDialog(rootPane,"www.JaverosAnonimos.tk");
}
}
ALFA (Morza) era mejor el anterior diseño del blog
ResponderBorrarGracias, me ayudaste mucho pero al codigo this.setModal(modal); donde solo recibes el boolean pero no lo aplicas.
ResponderBorrarPublicar un comentario