home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 1.0 KB | 57 lines |
- // FixedFrame.java
- // A Frame that is guaranteed to be at least some minimum size, and
- // will disappear when closed.
- import java.awt.Frame;
- import java.awt.Dimension;
- import java.awt.Insets;
- import java.awt.Event;
-
- public class FixedFrame extends Frame
- {
- int width, height;
-
- FixedFrame(Dimension s)
- {
- this(s.width, s.height);
- }
-
- FixedFrame(int w, int h)
- {
- width = w; height = h;
- move(200+(int)(Math.random()*50), 200+(int)(Math.random()*50));
- }
-
- FixedFrame()
- {
- this(-1, -1);
- }
-
- void setsize(Dimension s)
- {
- width = s.width; height = s.height;
- }
-
- public Dimension preferredSize()
- {
- Dimension sp = super.preferredSize();
- Insets is = insets();
- return new Dimension(width == -1 ? sp.width : width,
- (height == -1 ? sp.height : height)+20);
- }
-
- public Dimension minimumSize()
- {
- return preferredSize();
- }
-
- // handleEvent
- // Remove this window if closed. Can be overridden in subclasses
- public boolean handleEvent(Event evt)
- {
- if (evt.id == Event.WINDOW_DESTROY)
- dispose();
- return super.handleEvent(evt);
- }
- }
-
-