home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 July / PCO_07_97.ISO / NET_COM / cc32e40.exe / nav40.z / java40.jar / java / awt / Component.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-06-07  |  8.1 KB  |  559 lines

  1. package java.awt;
  2.  
  3. import java.awt.image.ColorModel;
  4. import java.awt.image.ImageObserver;
  5. import java.awt.image.ImageProducer;
  6. import java.awt.peer.ComponentPeer;
  7. import java.io.PrintStream;
  8. import java.io.Serializable;
  9.  
  10. public abstract class Component implements ImageObserver, Serializable {
  11.    transient ComponentPeer peer;
  12.    transient Container parent;
  13.    // $FF: renamed from: x int
  14.    int field_0;
  15.    // $FF: renamed from: y int
  16.    int field_1;
  17.    int width;
  18.    int height;
  19.    Color foreground;
  20.    Color background;
  21.    Font font;
  22.    boolean visible = true;
  23.    boolean enabled = true;
  24.    boolean valid = false;
  25.    String name;
  26.    static final Object LOCK = new Object();
  27.  
  28.    Component() {
  29.    }
  30.  
  31.    public Container getParent() {
  32.       return this.parent;
  33.    }
  34.  
  35.    public ComponentPeer getPeer() {
  36.       return this.peer;
  37.    }
  38.  
  39.    public Toolkit getToolkit() {
  40.       ComponentPeer var1 = this.peer;
  41.       if (var1 != null) {
  42.          return var1.getToolkit();
  43.       } else {
  44.          Container var2 = this.parent;
  45.          return var2 != null ? ((Component)var2).getToolkit() : Toolkit.getDefaultToolkit();
  46.       }
  47.    }
  48.  
  49.    public boolean isValid() {
  50.       return this.peer != null && this.valid;
  51.    }
  52.  
  53.    public boolean isVisible() {
  54.       return this.visible;
  55.    }
  56.  
  57.    public boolean isShowing() {
  58.       if (this.visible && this.peer != null) {
  59.          Container var1 = this.parent;
  60.          return var1 == null || ((Component)var1).isShowing();
  61.       } else {
  62.          return false;
  63.       }
  64.    }
  65.  
  66.    public boolean isEnabled() {
  67.       return this.enabled;
  68.    }
  69.  
  70.    public Point location() {
  71.       return new Point(this.field_0, this.field_1);
  72.    }
  73.  
  74.    public Dimension size() {
  75.       return new Dimension(this.width, this.height);
  76.    }
  77.  
  78.    public Rectangle bounds() {
  79.       return new Rectangle(this.field_0, this.field_1, this.width, this.height);
  80.    }
  81.  
  82.    public synchronized void enable() {
  83.       if (!this.enabled) {
  84.          this.enabled = true;
  85.          if (this.peer != null) {
  86.             this.peer.enable();
  87.          }
  88.       }
  89.  
  90.    }
  91.  
  92.    public void enable(boolean var1) {
  93.       if (var1) {
  94.          this.enable();
  95.       } else {
  96.          this.disable();
  97.       }
  98.    }
  99.  
  100.    public synchronized void disable() {
  101.       if (this.enabled) {
  102.          this.enabled = false;
  103.          if (this.peer != null) {
  104.             this.peer.disable();
  105.          }
  106.       }
  107.  
  108.    }
  109.  
  110.    public void setVisible(boolean var1) {
  111.       this.show(var1);
  112.    }
  113.  
  114.    public synchronized void show() {
  115.       if (!this.visible) {
  116.          this.visible = true;
  117.          if (this.peer != null) {
  118.             this.peer.show();
  119.             if (this.parent != null) {
  120.                this.parent.invalidate();
  121.             }
  122.          }
  123.       }
  124.  
  125.    }
  126.  
  127.    public void show(boolean var1) {
  128.       if (var1) {
  129.          this.show();
  130.       } else {
  131.          this.hide();
  132.       }
  133.    }
  134.  
  135.    public synchronized void hide() {
  136.       if (this.visible) {
  137.          this.visible = false;
  138.          if (this.peer != null) {
  139.             this.peer.hide();
  140.             if (this.parent != null) {
  141.                this.parent.invalidate();
  142.             }
  143.          }
  144.       }
  145.  
  146.    }
  147.  
  148.    public Color getForeground() {
  149.       Color var1 = this.foreground;
  150.       if (var1 != null) {
  151.          return var1;
  152.       } else {
  153.          Container var2 = this.parent;
  154.          return var2 != null ? ((Component)var2).getForeground() : null;
  155.       }
  156.    }
  157.  
  158.    public synchronized void setForeground(Color var1) {
  159.       this.foreground = var1;
  160.       if (this.peer != null) {
  161.          var1 = this.getForeground();
  162.          if (var1 != null) {
  163.             this.peer.setForeground(var1);
  164.          }
  165.       }
  166.  
  167.    }
  168.  
  169.    public Color getBackground() {
  170.       Color var1 = this.background;
  171.       if (var1 != null) {
  172.          return var1;
  173.       } else {
  174.          Container var2 = this.parent;
  175.          return var2 != null ? ((Component)var2).getBackground() : null;
  176.       }
  177.    }
  178.  
  179.    public synchronized void setBackground(Color var1) {
  180.       this.background = var1;
  181.       if (this.peer != null) {
  182.          var1 = this.getBackground();
  183.          if (var1 != null) {
  184.             this.peer.setBackground(var1);
  185.          }
  186.       }
  187.  
  188.    }
  189.  
  190.    public Font getFont() {
  191.       Font var1 = this.font;
  192.       if (var1 != null) {
  193.          return var1;
  194.       } else {
  195.          Container var2 = this.parent;
  196.          return var2 != null ? ((Component)var2).getFont() : null;
  197.       }
  198.    }
  199.  
  200.    public synchronized void setFont(Font var1) {
  201.       this.font = var1;
  202.       if (this.peer != null) {
  203.          var1 = this.getFont();
  204.          if (var1 != null) {
  205.             this.peer.setFont(var1);
  206.          }
  207.       }
  208.  
  209.    }
  210.  
  211.    public synchronized ColorModel getColorModel() {
  212.       return this.peer == null ? this.getToolkit().getColorModel() : this.peer.getColorModel();
  213.    }
  214.  
  215.    public void move(int var1, int var2) {
  216.       this.reshape(var1, var2, this.width, this.height);
  217.    }
  218.  
  219.    public void resize(int var1, int var2) {
  220.       this.reshape(this.field_0, this.field_1, var1, var2);
  221.    }
  222.  
  223.    public void resize(Dimension var1) {
  224.       this.reshape(this.field_0, this.field_1, var1.width, var1.height);
  225.    }
  226.  
  227.    public synchronized void reshape(int var1, int var2, int var3, int var4) {
  228.       boolean var5 = this.width != var3 || this.height != var4;
  229.       if (var5 || this.field_0 != var1 || this.field_1 != var2) {
  230.          this.field_0 = var1;
  231.          this.field_1 = var2;
  232.          this.width = var3;
  233.          this.height = var4;
  234.          if (this.peer != null) {
  235.             this.peer.reshape(var1, var2, var3, var4);
  236.             if (var5) {
  237.                this.invalidate();
  238.             }
  239.  
  240.             if (this.parent != null) {
  241.                this.parent.invalidate();
  242.             }
  243.          }
  244.       }
  245.  
  246.    }
  247.  
  248.    public Dimension preferredSize() {
  249.       ComponentPeer var1 = this.peer;
  250.       return var1 != null ? var1.preferredSize() : this.minimumSize();
  251.    }
  252.  
  253.    public Dimension minimumSize() {
  254.       ComponentPeer var1 = this.peer;
  255.       return var1 != null ? var1.minimumSize() : this.size();
  256.    }
  257.  
  258.    public void layout() {
  259.    }
  260.  
  261.    public void validate() {
  262.       while(!this.valid && this.peer != null) {
  263.          this.valid = true;
  264.          this.layout();
  265.       }
  266.  
  267.    }
  268.  
  269.    public void invalidate() {
  270.       this.valid = false;
  271.    }
  272.  
  273.    public Graphics getGraphics() {
  274.       ComponentPeer var1 = this.peer;
  275.       return var1 != null ? var1.getGraphics() : null;
  276.    }
  277.  
  278.    public FontMetrics getFontMetrics(Font var1) {
  279.       ComponentPeer var2 = this.peer;
  280.       return var2 != null ? var2.getFontMetrics(var1) : this.getToolkit().getFontMetrics(var1);
  281.    }
  282.  
  283.    public void paint(Graphics var1) {
  284.    }
  285.  
  286.    public void update(Graphics var1) {
  287.       var1.setColor(this.getBackground());
  288.       var1.fillRect(0, 0, this.width, this.height);
  289.       var1.setColor(this.getForeground());
  290.       this.paint(var1);
  291.    }
  292.  
  293.    public void paintAll(Graphics var1) {
  294.       ComponentPeer var2 = this.peer;
  295.       if (this.visible && var2 != null) {
  296.          this.validate();
  297.          var2.paint(var1);
  298.       }
  299.  
  300.    }
  301.  
  302.    public void repaint() {
  303.       this.repaint(0L, 0, 0, this.width, this.height);
  304.    }
  305.  
  306.    public void repaint(long var1) {
  307.       this.repaint(var1, 0, 0, this.width, this.height);
  308.    }
  309.  
  310.    public void repaint(int var1, int var2, int var3, int var4) {
  311.       this.repaint(0L, var1, var2, var3, var4);
  312.    }
  313.  
  314.    public void repaint(long var1, int var3, int var4, int var5, int var6) {
  315.       ComponentPeer var7 = this.peer;
  316.       if (var7 != null && var5 > 0 && var6 > 0) {
  317.          var7.repaint(var1, var3, var4, var5, var6);
  318.       }
  319.  
  320.    }
  321.  
  322.    public void print(Graphics var1) {
  323.       this.paint(var1);
  324.    }
  325.  
  326.    public void printAll(Graphics var1) {
  327.       ComponentPeer var2 = this.peer;
  328.       if (this.visible && var2 != null) {
  329.          this.validate();
  330.          var2.print(var1);
  331.       }
  332.  
  333.    }
  334.  
  335.    public boolean imageUpdate(Image var1, int var2, int var3, int var4, int var5, int var6) {
  336.       int var7 = -1;
  337.       if ((var2 & 48) != 0) {
  338.          var7 = 0;
  339.       } else if ((var2 & 8) != 0) {
  340.          String var8 = System.getProperty("awt.image.incrementaldraw");
  341.          if (var8 == null || var8.equals("true")) {
  342.             String var9 = System.getProperty("awt.image.redrawrate");
  343.  
  344.             try {
  345.                var7 = var9 != null ? Integer.parseInt(var9) : 100;
  346.                if (var7 < 0) {
  347.                   var7 = 0;
  348.                }
  349.             } catch (Exception var10) {
  350.                var7 = 100;
  351.             }
  352.          }
  353.       }
  354.  
  355.       if (var7 >= 0) {
  356.          this.repaint((long)var7, 0, 0, this.width, this.height);
  357.       }
  358.  
  359.       return (var2 & 160) == 0;
  360.    }
  361.  
  362.    public Image createImage(ImageProducer var1) {
  363.       ComponentPeer var2 = this.peer;
  364.       return var2 != null ? var2.createImage(var1) : this.getToolkit().createImage(var1);
  365.    }
  366.  
  367.    public Image createImage(int var1, int var2) {
  368.       ComponentPeer var3 = this.peer;
  369.       return var3 != null ? var3.createImage(var1, var2) : null;
  370.    }
  371.  
  372.    public boolean prepareImage(Image var1, ImageObserver var2) {
  373.       return this.prepareImage(var1, -1, -1, var2);
  374.    }
  375.  
  376.    public boolean prepareImage(Image var1, int var2, int var3, ImageObserver var4) {
  377.       ComponentPeer var5 = this.peer;
  378.       return var5 != null ? var5.prepareImage(var1, var2, var3, var4) : this.getToolkit().prepareImage(var1, var2, var3, var4);
  379.    }
  380.  
  381.    public int checkImage(Image var1, ImageObserver var2) {
  382.       return this.checkImage(var1, -1, -1, var2);
  383.    }
  384.  
  385.    public int checkImage(Image var1, int var2, int var3, ImageObserver var4) {
  386.       ComponentPeer var5 = this.peer;
  387.       return var5 != null ? var5.checkImage(var1, var2, var3, var4) : this.getToolkit().checkImage(var1, var2, var3, var4);
  388.    }
  389.  
  390.    public synchronized boolean inside(int var1, int var2) {
  391.       return var1 >= 0 && var1 < this.width && var2 >= 0 && var2 < this.height;
  392.    }
  393.  
  394.    public Component locate(int var1, int var2) {
  395.       return this.inside(var1, var2) ? this : null;
  396.    }
  397.  
  398.    public void deliverEvent(Event var1) {
  399.       this.postEvent(var1);
  400.    }
  401.  
  402.    public boolean postEvent(Event var1) {
  403.       ComponentPeer var2 = this.peer;
  404.       if (this.handleEvent(var1)) {
  405.          return true;
  406.       } else {
  407.          Container var3 = this.parent;
  408.          if (var3 != null) {
  409.             var1.translate(this.field_0, this.field_1);
  410.             if (((Component)var3).postEvent(var1)) {
  411.                return true;
  412.             }
  413.          }
  414.  
  415.          return var2 != null ? var2.handleEvent(var1) : false;
  416.       }
  417.    }
  418.  
  419.    public boolean handleEvent(Event var1) {
  420.       switch (var1.id) {
  421.          case 401:
  422.          case 403:
  423.             return this.keyDown(var1, var1.key);
  424.          case 402:
  425.          case 404:
  426.             return this.keyUp(var1, var1.key);
  427.          case 501:
  428.             return this.mouseDown(var1, var1.x, var1.y);
  429.          case 502:
  430.             return this.mouseUp(var1, var1.x, var1.y);
  431.          case 503:
  432.             return this.mouseMove(var1, var1.x, var1.y);
  433.          case 504:
  434.             return this.mouseEnter(var1, var1.x, var1.y);
  435.          case 505:
  436.             return this.mouseExit(var1, var1.x, var1.y);
  437.          case 506:
  438.             return this.mouseDrag(var1, var1.x, var1.y);
  439.          case 1001:
  440.             return this.action(var1, var1.arg);
  441.          case 1004:
  442.             return this.gotFocus(var1, var1.arg);
  443.          case 1005:
  444.             return this.lostFocus(var1, var1.arg);
  445.          default:
  446.             return false;
  447.       }
  448.    }
  449.  
  450.    public boolean mouseDown(Event var1, int var2, int var3) {
  451.       return false;
  452.    }
  453.  
  454.    public boolean mouseDrag(Event var1, int var2, int var3) {
  455.       return false;
  456.    }
  457.  
  458.    public boolean mouseUp(Event var1, int var2, int var3) {
  459.       return false;
  460.    }
  461.  
  462.    public boolean mouseMove(Event var1, int var2, int var3) {
  463.       return false;
  464.    }
  465.  
  466.    public boolean mouseEnter(Event var1, int var2, int var3) {
  467.       return false;
  468.    }
  469.  
  470.    public boolean mouseExit(Event var1, int var2, int var3) {
  471.       return false;
  472.    }
  473.  
  474.    public boolean keyDown(Event var1, int var2) {
  475.       return false;
  476.    }
  477.  
  478.    public boolean keyUp(Event var1, int var2) {
  479.       return false;
  480.    }
  481.  
  482.    public boolean action(Event var1, Object var2) {
  483.       return false;
  484.    }
  485.  
  486.    public void addNotify() {
  487.       this.valid = false;
  488.    }
  489.  
  490.    public synchronized void removeNotify() {
  491.       if (this.peer != null) {
  492.          this.peer.dispose();
  493.          this.peer = null;
  494.       }
  495.  
  496.    }
  497.  
  498.    public boolean gotFocus(Event var1, Object var2) {
  499.       return false;
  500.    }
  501.  
  502.    public boolean lostFocus(Event var1, Object var2) {
  503.       return false;
  504.    }
  505.  
  506.    public void requestFocus() {
  507.       ComponentPeer var1 = this.peer;
  508.       if (var1 != null) {
  509.          var1.requestFocus();
  510.       }
  511.  
  512.    }
  513.  
  514.    public void nextFocus() {
  515.       ComponentPeer var1 = this.peer;
  516.       if (var1 != null) {
  517.          var1.nextFocus();
  518.       }
  519.  
  520.    }
  521.  
  522.    protected String paramString() {
  523.       String var1 = this.field_0 + "," + this.field_1 + "," + this.width + "x" + this.height;
  524.       if (!this.valid) {
  525.          var1 = var1 + ",invalid";
  526.       }
  527.  
  528.       if (!this.visible) {
  529.          var1 = var1 + ",hidden";
  530.       }
  531.  
  532.       if (!this.enabled) {
  533.          var1 = var1 + ",disabled";
  534.       }
  535.  
  536.       return var1;
  537.    }
  538.  
  539.    public String toString() {
  540.       return this.getClass().getName() + "[" + this.paramString() + "]";
  541.    }
  542.  
  543.    public void list() {
  544.       this.list(System.out, 0);
  545.    }
  546.  
  547.    public void list(PrintStream var1) {
  548.       this.list(var1, 0);
  549.    }
  550.  
  551.    public void list(PrintStream var1, int var2) {
  552.       for(int var3 = 0; var3 < var2; ++var3) {
  553.          var1.print("  ");
  554.       }
  555.  
  556.       var1.println(this);
  557.    }
  558. }
  559.