1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
@SuppressWarnings("serial") public class Test extends JFrame implements ActionListener
{
public Test()
{
JButton jb_open_dial = new JButton("Open Dialog");
jb_open_dial.setActionCommand("open");
jb_open_dial.addActionListener(this);
add(jb_open_dial);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("0");
setSize(200, 200);
setLocationRelativeTo(null);
}
public void actionPerformed(ActionEvent e)
{
MyDialog dial = new MyDialog(this);
dial.setTitle("Après"); // Ici je tente de changer le titre.
}
}
@SuppressWarnings("serial") class MyDialog extends JDialog
{
public MyDialog(JFrame parent)
{
super(parent);
setProprietes();
}
private void setProprietes()
{
setTitle("Avant");
setSize(200, 200);
setModal(true);
setVisible(true);
}
} |
Partager