/[classpath]/classpath/java/awt/Frame.java
ViewVC logotype

Diff of /classpath/java/awt/Frame.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by mkoch, Thu Dec 30 19:02:06 2004 UTC revision 1.28 by mkoch, Tue Jan 11 15:06:04 2005 UTC
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package java.awt;  package java.awt;
40    
41  import java.awt.peer.FramePeer;  import java.awt.peer.FramePeer;
42    import java.lang.ref.WeakReference;
43    import java.util.ArrayList;
44    import java.util.Iterator;
45  import java.util.Vector;  import java.util.Vector;
46    
47  import javax.accessibility.AccessibleContext;  import javax.accessibility.AccessibleContext;
# Line 214  public Line 217  public
217  Frame()  Frame()
218  {  {
219    this("");    this("");
220      noteFrame(this);
221  }  }
222    
223  /**  /**
# Line 229  Frame(String title) Line 233  Frame(String title)
233    this.title = title;    this.title = title;
234    // Top-level frames are initially invisible.    // Top-level frames are initially invisible.
235    visible = false;    visible = false;
236      noteFrame(this);
237  }  }
238    
239  public  public
# Line 236  Frame(GraphicsConfiguration gc) Line 241  Frame(GraphicsConfiguration gc)
241  {  {
242    super(gc);    super(gc);
243    visible = false;    visible = false;
244      noteFrame(this);
245  }  }
246    
247  public  public
# Line 244  Frame(String title, GraphicsConfiguratio Line 250  Frame(String title, GraphicsConfiguratio
250    super(gc);    super(gc);
251    setTitle(title);    setTitle(title);
252    visible = false;    visible = false;
253      noteFrame(this);
254  }  }
255    
256  /**  /**
# Line 396  remove(MenuComponent menu) Line 403  remove(MenuComponent menu)
403  /**  /**
404    * Notifies this frame that it should create its native peer.    * Notifies this frame that it should create its native peer.
405    */    */
406    
407    private static void fireDummyEvent()
408    {
409      EventQueue.invokeLater(new Runnable() { public void run() { } });
410    }
411    
412  public void  public void
413  addNotify()  addNotify()
414  {  {
# Line 403  addNotify() Line 416  addNotify()
416      menuBar.addNotify();      menuBar.addNotify();
417    if (peer == null)    if (peer == null)
418      peer = getToolkit ().createFrame (this);      peer = getToolkit ().createFrame (this);
419    
420      // We now know there's a Frame (us) with a live peer, so we can start the
421      // fundamental queue and dispatch thread, by inserting a dummy event.
422      if (parent != null && parent.isDisplayable())
423        fireDummyEvent();
424      
425    super.addNotify();    super.addNotify();
426  }  }
427    
# Line 411  public void removeNotify() Line 430  public void removeNotify()
430    if (menuBar != null)    if (menuBar != null)
431      menuBar.removeNotify();      menuBar.removeNotify();
432    super.removeNotify();    super.removeNotify();
433    
434      // By now we've been disconnected from the peer, and the peer set to
435      // null.  This is formally the same as saying "we just became
436      // un-displayable", so we wake up the event queue with a dummy event to
437      // see if it's time to shut down.
438      fireDummyEvent();
439  }  }
440    
441    /**    /**
# Line 449  public void removeNotify() Line 474  public void removeNotify()
474      return super.paramString () + ",title=" + title + resizable + state;      return super.paramString () + ",title=" + title + resizable + state;
475    }    }
476    
477  public static Frame[]  private static ArrayList weakFrames = new ArrayList();
478  getFrames()  
479    private static void noteFrame(Frame f)
480    {
481      weakFrames.add(new WeakReference(f));
482    }
483    
484    public static Frame[] getFrames()
485  {  {
486    //Frame[] array = new Frames[frames.size()];    int n = 0;
487    //return frames.toArray(array);    synchronized (weakFrames)
488    String msg = "FIXME: can't be implemented without weak references";      {
489    throw new UnsupportedOperationException(msg);        Iterator i = weakFrames.iterator();
490          while (i.hasNext())
491            {
492              WeakReference wr = (WeakReference) i.next();
493              if (wr.get() != null)
494                ++n;
495            }
496          if (n == 0)
497            return new Frame[0];
498          else
499            {
500              Frame[] frames = new Frame[n];
501              n = 0;
502              i = weakFrames.iterator();
503              while (i.hasNext())
504                {
505                  WeakReference wr = (WeakReference) i.next();
506                  if (wr.get() != null)
507                    frames[n++] = (Frame) wr.get();
508                }
509              return frames;
510            }
511        }
512  }  }
513    
514    public void setState (int state)    public void setState (int state)

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26