fabiofalciPJ 17 de mar. de 2005
tu nao poderia ao inves de abrir um outro JFrame, abrir um JDialog? q nem
o codigo abaixo
public class MyPanel extends JPanel & #123;
protected JDialog dialog ;
public MyPanel & #40;) {
this . initialize & #40;);
& #125;
protected void initialize & #40;) {
JButton b = new JButton & #40;"Open");
b . setPreferredSize & #40;new Dimension(100, 24));
this . add & #40;b, BorderLayout.CENTER);
b . addActionListener & #40;new ActionListener() {
public void actionPerformed & #40;ActionEvent e) {
openDialog & #40;);
& #125;
& #125;);
& #125;
public void openDialog & #40;) {
JButton aux = new JButton & #40;"Close");
aux . addActionListener & #40;new ActionListener() {
public void actionPerformed & #40;ActionEvent e) {
dialog . dispose & #40;);
& #125;
& #125;);
aux . setPreferredSize & #40;new Dimension(100, 24));
dialog = new JDialog & #40;frame, true);
JPanel panel = new JPanel & #40;);
panel . add & #40;aux);
dialog . setContentPane & #40;panel);
dialog . pack & #40;);
dialog . show & #40;);
& #125;
static JFrame frame ;
public static void main & #40;String[] args) {
frame = new JFrame & #40;);
frame . setDefaultCloseOperation & #40;JFrame.EXIT_ON_CLOSE);
MyPanel panel = new MyPanel & #40;);
frame . setContentPane & #40;panel);
frame . pack & #40;);
frame . show & #40;);
& #125;
& #125;