-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
Christian Pesch
Sent: Friday, September 14, 2001 12:36 PM
To: rob anderson
Subject: Re: [Advanced-java] Java Application Starts Minimized


Hi Rob,

I had no problem with it, it was somebody on the [EMAIL PROTECTED] list.
Maybe you want to resend your message to the list.

Christian


Rob anderson schrieb:

> I presume the effect you want is to pop-up the Frame when a message comes
> in?
>
> Have you tried putting the frame.setVisible(true) first? or using
> frame.show()
>
> However, I seem to remember this being a JFrame/Frame problem on previous
> lists - try searching?
>
> Rob
>
> This code seems to work - but only if the setLocation is reissued!
>
> package com.bml.qdg.test;
>
> import javax.swing.*;
> import java.awt.*;
> import java.awt.event.*;
>
> public class FrameTest
> extends JFrame
> {
>
>     public FrameTest()
>     {
>         super("JFrame Test");
>         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>         final OtherFrame otherFrame = new OtherFrame();
>
>         JPanel p = new JPanel(new FlowLayout());
>         JButton btn = new JButton("Click to send message");
>         btn.addActionListener(new ActionListener()
>         {
>             public void actionPerformed(ActionEvent ae)
>             {
>                 otherFrame.doMessage("Message sent");
>             }
>         });
>
>         p.add(btn);
>
>         getContentPane().add(p);
>         pack();
>
>         Toolkit tk = Toolkit.getDefaultToolkit();
>         Dimension screen = tk.getScreenSize();
>         int screenHeight = screen.height;
>         int screenWidth = screen.width;
>         setLocation((screenWidth / 2) - this.getWidth() / 2, (screenHeight
/
> 2) - this.getHeight() / 2);
>         setVisible(true);
>     }
>
>     public static void main(String[] args)
>     {
>         new FrameTest();
>     }
>
>     class OtherFrame
>     extends JFrame
>     {
>
>         public OtherFrame()
>         {
>             super("Other Frame");
>             jta.setLineWrap(true);
>             jta.setWrapStyleWord(true);
>             jta.setEditable(false);
>             getContentPane().add(new JScrollPane(jta));
>             pack();
>             Toolkit tk = Toolkit.getDefaultToolkit();
>             Dimension screen = tk.getScreenSize();
>             int screenHeight = screen.height;
>             int screenWidth = screen.width;
>             setLocation((screenWidth / 2) - this.getWidth() / 2,
> (screenHeight / 2) - this.getHeight() / 2);
>         }
>
>         public void doMessage(String message)
>         {
>             jta.setText(new java.util.Date() + ":" + message + "\n" +
> jta.getText());
>             jta.setCaretPosition(0);
>             Point pos = getLocation();
>             setLocation(pos);
>             setState(Frame.NORMAL);
>             setVisible(true);
>         }
>
>         JTextArea jta = new JTextArea(10,50);
>     }
> }


_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to