home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1998 September / dppcpro0998.iso / Rwc / Sybase / Install.exe / samples.z / Form_Application.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-03-25  |  5.1 KB  |  196 lines

  1. import java.awt.Button;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Event;
  6. import java.awt.Font;
  7. import java.awt.FontMetrics;
  8. import java.awt.Frame;
  9. import java.awt.Insets;
  10. import java.awt.List;
  11. import java.awt.Rectangle;
  12. import java.awt.Window;
  13. import java.awt.event.ActionEvent;
  14. import java.awt.event.ActionListener;
  15. import java.awt.event.WindowEvent;
  16. import java.awt.event.WindowListener;
  17. import java.util.Enumeration;
  18. import java.util.EventObject;
  19. import java.util.Properties;
  20. import powersoft.powerj.event.AWTEvent;
  21. import powersoft.powerj.ui.ResizePercentLayout;
  22.  
  23. class Form_Application extends Frame implements WindowListener, ActionListener {
  24.    boolean __mainForm;
  25.    private List lb_systemProperties = new List();
  26.    private Button cb_showSystemProperties = new Button();
  27.    private Properties _systemProperties;
  28.  
  29.    public Rectangle DURectangle(int var1, int var2, int var3, int var4) {
  30.       String var5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  31.       FontMetrics var6 = ((Component)this).getFontMetrics(((Component)this).getFont());
  32.       double var7 = (double)(var6 != null ? var6.stringWidth(var5) / var5.length() : 0);
  33.       double var9 = var6 != null ? (double)var6.getHeight() / (double)2.0F : (double)0.0F;
  34.       return new Rectangle((int)Math.round(var7 * (double)var1 / (double)4.0F), (int)Math.round(var9 * (double)var2 / (double)4.0F), (int)Math.round(var7 * (double)var3 / (double)4.0F), (int)Math.round(var9 * (double)var4 / (double)4.0F));
  35.    }
  36.  
  37.    public void DUPositionComponent(Component var1, int var2, int var3, int var4, int var5, Insets var6) {
  38.       Rectangle var7 = this.DURectangle(var2, var3, var4, var5);
  39.       if (var1 != this && var6 != null) {
  40.          var7.x += var6.left;
  41.          var7.y += var6.top;
  42.       }
  43.  
  44.       if (var1 == this && var6 != null && var6.bottom > 0) {
  45.          var7.height += var6.bottom;
  46.       }
  47.  
  48.       var1.setBounds(var7);
  49.    }
  50.  
  51.    public void setMainForm(boolean var1) {
  52.       this.__mainForm = var1;
  53.    }
  54.  
  55.    public boolean isMainForm() {
  56.       return this.__mainForm;
  57.    }
  58.  
  59.    public boolean create() throws Exception {
  60.       ((Frame)this).setTitle("Application");
  61.       ((Frame)this).setResizable(true);
  62.       Container var1 = this.getContentPane();
  63.       Font var2 = new Font("Dialog", 0, 12);
  64.       ((Component)this).setFont(var2);
  65.       boolean var3 = true;
  66.       ((Frame)this).addNotify();
  67.       Insets var4 = (Insets)var1.getInsets().clone();
  68.       ((Component)var1).setBackground(Color.lightGray);
  69.       ((Component)var1).setForeground(Color.black);
  70.       ResizePercentLayout var5 = new ResizePercentLayout();
  71.       var1.setLayout(var5);
  72.       var1.add(this.lb_systemProperties);
  73.       var1.add(this.cb_showSystemProperties);
  74.       this.DUPositionComponent(this, 74, 13, 262, 240, var4);
  75.       ((Window)this).addWindowListener(this);
  76.       this.DUPositionComponent(this.lb_systemProperties, 5, 25, 246, 195, var4);
  77.       this.lb_systemProperties.setFont(var2);
  78.       this.lb_systemProperties.setBackground(Color.white);
  79.       this.lb_systemProperties.setForeground(Color.black);
  80.       this.lb_systemProperties.setEnabled(true);
  81.       this.lb_systemProperties.setVisible(true);
  82.       this.cb_showSystemProperties.addActionListener(this);
  83.       this.DUPositionComponent(this.cb_showSystemProperties, 5, 5, 110, 15, var4);
  84.       this.cb_showSystemProperties.setFont(var2);
  85.       this.cb_showSystemProperties.setBackground(Color.lightGray);
  86.       this.cb_showSystemProperties.setForeground(Color.black);
  87.       this.cb_showSystemProperties.setEnabled(true);
  88.       this.cb_showSystemProperties.setVisible(true);
  89.       this.cb_showSystemProperties.setLabel("Show System Properties");
  90.       var5.setResizePercent(this.lb_systemProperties, new Rectangle(0, 0, 100, 100));
  91.       var5.setResizePercent(this.cb_showSystemProperties, new Rectangle(0, 0, 0, 0));
  92.       ((Component)this).setVisible(true);
  93.       return var3;
  94.    }
  95.  
  96.    public synchronized boolean destroy() {
  97.       if (this instanceof Window) {
  98.          ((Window)this).dispose();
  99.       } else {
  100.          ((Container)this).removeNotify();
  101.       }
  102.  
  103.       if (this.isMainForm()) {
  104.          System.gc();
  105.          System.runFinalization();
  106.          System.exit(0);
  107.       }
  108.  
  109.       return true;
  110.    }
  111.  
  112.    public boolean defaultHandleEvent(Event var1) {
  113.       this.defaultProcessEvent(new AWTEvent(var1));
  114.       return false;
  115.    }
  116.  
  117.    public void defaultProcessEvent(java.awt.AWTEvent var1) {
  118.       super.processEvent(var1);
  119.    }
  120.  
  121.    public void windowClosed(WindowEvent var1) {
  122.    }
  123.  
  124.    public void windowOpened(WindowEvent var1) {
  125.    }
  126.  
  127.    public void windowClosing(WindowEvent var1) {
  128.       Object var2 = ((EventObject)var1).getSource();
  129.       if (var2 == this) {
  130.          this.Form_Application_windowClosing(var1);
  131.       } else {
  132.          this.unhandledEvent("java.awt.event.WindowListener", "windowClosing", var1);
  133.       }
  134.  
  135.    }
  136.  
  137.    public void windowIconified(WindowEvent var1) {
  138.    }
  139.  
  140.    public void windowActivated(WindowEvent var1) {
  141.    }
  142.  
  143.    public void windowDeiconified(WindowEvent var1) {
  144.    }
  145.  
  146.    public void windowDeactivated(WindowEvent var1) {
  147.    }
  148.  
  149.    public void actionPerformed(ActionEvent var1) {
  150.       Object var2 = ((EventObject)var1).getSource();
  151.       if (var2 == this.cb_showSystemProperties) {
  152.          this.cb_showSystemProperties_actionPerformed(var1);
  153.       } else {
  154.          this.unhandledEvent("java.awt.event.ActionListener", "actionPerformed", var1);
  155.       }
  156.  
  157.    }
  158.  
  159.    public Form_Application() {
  160.    }
  161.  
  162.    public boolean handleEvent(Event var1) {
  163.       return this.defaultHandleEvent(var1);
  164.    }
  165.  
  166.    public void unhandledEvent(String var1, String var2, Object var3) {
  167.    }
  168.  
  169.    public void processEvent(java.awt.AWTEvent var1) {
  170.       this.defaultProcessEvent(var1);
  171.    }
  172.  
  173.    public Container getContentPane() {
  174.       return this;
  175.    }
  176.  
  177.    public boolean Form_Application_windowClosing(WindowEvent var1) {
  178.       ((Component)this).hide();
  179.       this.destroy();
  180.       return false;
  181.    }
  182.  
  183.    public boolean cb_showSystemProperties_actionPerformed(ActionEvent var1) {
  184.       this._systemProperties = System.getProperties();
  185.       Enumeration var2 = this._systemProperties.propertyNames();
  186.  
  187.       while(var2.hasMoreElements()) {
  188.          String var3 = new String((String)var2.nextElement());
  189.          String var4 = new String(this._systemProperties.getProperty(var3));
  190.          this.lb_systemProperties.addItem("[ " + var3 + " ]    " + var4);
  191.       }
  192.  
  193.       return false;
  194.    }
  195. }
  196.