home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Frame;
- import java.awt.Insets;
- import java.awt.Label;
- import java.awt.Rectangle;
- import java.awt.Window;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowEvent;
- import java.awt.event.WindowListener;
- import java.util.EventObject;
- import powersoft.powerj.event.AWTEvent;
- import powersoft.powerj.event.EventData;
- import powersoft.powerj.ui.ResizePercentLayout;
-
- class MessageBox extends Dialog implements WindowListener, ActionListener {
- boolean __mainForm;
- private Button cb_1 = new Button();
- private Label label_message = new Label();
- private String _message;
-
- public Rectangle DURectangle(int var1, int var2, int var3, int var4) {
- String var5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- FontMetrics var6 = ((Component)this).getFontMetrics(((Component)this).getFont());
- double var7 = (double)(var6 != null ? var6.stringWidth(var5) / var5.length() : 0);
- double var9 = var6 != null ? (double)var6.getHeight() / (double)2.0F : (double)0.0F;
- 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));
- }
-
- public void DUPositionComponent(Component var1, int var2, int var3, int var4, int var5, Insets var6) {
- Rectangle var7 = this.DURectangle(var2, var3, var4, var5);
- if (var1 != this && var6 != null) {
- var7.x += var6.left;
- var7.y += var6.top;
- }
-
- if (var1 == this && var6 != null && var6.bottom > 0) {
- var7.height += var6.bottom;
- }
-
- var1.setBounds(var7);
- }
-
- public void setMainForm(boolean var1) {
- this.__mainForm = var1;
- }
-
- public boolean isMainForm() {
- return this.__mainForm;
- }
-
- public boolean create() throws Exception {
- ((Dialog)this).setResizable(true);
- Container var1 = this.getContentPane();
- Font var2 = new Font("Dialog", 0, 12);
- ((Component)this).setFont(var2);
- boolean var3 = true;
- ((Dialog)this).addNotify();
- Insets var4 = (Insets)var1.getInsets().clone();
- ((Component)var1).setBackground(Color.lightGray);
- ((Component)var1).setForeground(Color.black);
- ResizePercentLayout var5 = new ResizePercentLayout();
- var1.setLayout(var5);
- var1.add(this.cb_1);
- var1.add(this.label_message);
- this.DUPositionComponent(this, 107, 116, 226, 61, var4);
- ((Window)this).addWindowListener(this);
- this.cb_1.addActionListener(this);
- this.DUPositionComponent(this.cb_1, 85, 25, 45, 14, var4);
- this.cb_1.setFont(var2);
- this.cb_1.setBackground(Color.lightGray);
- this.cb_1.setForeground(Color.black);
- this.cb_1.setEnabled(true);
- this.cb_1.setVisible(true);
- this.cb_1.setLabel("OK");
- this.DUPositionComponent(this.label_message, 5, 5, 210, 10, var4);
- this.label_message.setText("Message");
- this.label_message.setAlignment(1);
- this.label_message.setFont(var2);
- this.label_message.setBackground(Color.lightGray);
- this.label_message.setForeground(Color.black);
- this.label_message.setEnabled(true);
- this.label_message.setVisible(true);
- var5.setResizePercent(this.cb_1, new Rectangle(0, 0, 0, 0));
- var5.setResizePercent(this.label_message, new Rectangle(0, 0, 0, 0));
- this.MessageBox_objectCreated(new EventData(this));
- ((Component)this).setVisible(true);
- return var3;
- }
-
- public synchronized boolean destroy() {
- if (this instanceof Window) {
- ((Window)this).dispose();
- } else {
- ((Container)this).removeNotify();
- }
-
- if (this.isMainForm()) {
- System.gc();
- System.runFinalization();
- System.exit(0);
- }
-
- return true;
- }
-
- public boolean defaultHandleEvent(Event var1) {
- this.defaultProcessEvent(new AWTEvent(var1));
- return false;
- }
-
- public void defaultProcessEvent(java.awt.AWTEvent var1) {
- super.processEvent(var1);
- }
-
- public void windowClosed(WindowEvent var1) {
- }
-
- public void windowOpened(WindowEvent var1) {
- }
-
- public void windowClosing(WindowEvent var1) {
- Object var2 = ((EventObject)var1).getSource();
- if (var2 == this) {
- this.MessageBox_windowClosing(var1);
- } else {
- this.unhandledEvent("java.awt.event.WindowListener", "windowClosing", var1);
- }
-
- }
-
- public void windowIconified(WindowEvent var1) {
- }
-
- public void windowActivated(WindowEvent var1) {
- }
-
- public void windowDeiconified(WindowEvent var1) {
- }
-
- public void windowDeactivated(WindowEvent var1) {
- }
-
- public void actionPerformed(ActionEvent var1) {
- Object var2 = ((EventObject)var1).getSource();
- if (var2 == this.cb_1) {
- this.cb_1_actionPerformed(var1);
- } else {
- this.unhandledEvent("java.awt.event.ActionListener", "actionPerformed", var1);
- }
-
- }
-
- public MessageBox(Frame var1, String var2) {
- super(var1, true);
- this._message = var2;
- }
-
- public MessageBox(String var1) {
- super((Frame)null, true);
- this._message = var1;
- }
-
- public boolean handleEvent(Event var1) {
- return this.defaultHandleEvent(var1);
- }
-
- public void unhandledEvent(String var1, String var2, Object var3) {
- }
-
- public void processEvent(java.awt.AWTEvent var1) {
- this.defaultProcessEvent(var1);
- }
-
- public Container getContentPane() {
- return this;
- }
-
- public boolean MessageBox_objectCreated(EventData var1) {
- this.label_message.setText(this._message);
- return false;
- }
-
- public boolean MessageBox_windowClosing(WindowEvent var1) {
- ((Component)this).setVisible(false);
- this.destroy();
- return false;
- }
-
- public boolean cb_1_actionPerformed(ActionEvent var1) {
- this.destroy();
- return false;
- }
- }
-