zoukankan      html  css  js  c++  java
  • Container类是Component的子类,它也是一个抽象类,它允许其他的组件(Component)加入其中

    在AWT中,所有能在屏幕上显示的组件(component )对应的类,均是 抽象类 Component 的子类或子孙类。

    这些类均可继承Component类的变量和方法。

    Container类是Component的子类,它也是一个抽象类,它允许其他的组件(Component)加入其中。

    加入的Component也允许是Container类型,即允许多层嵌套的层次结构,Container类在将组件以合适的形式安排在屏幕上时很有用,它有两个子类,Panel和Window,它们不是抽象类。

     1 package TomAwt;
     2 
     3 
     4 import java.applet.Applet;
     5 import java.awt.*;
     6 import java.awt.event.*;
     7 public class TomAwt_09 extends Applet implements TextListener{
     8     TextField from;
     9     TextField to;
    10     public void init(){
    11         from=new TextField(30);
    12         to=new TextField(30);
    13         to.setEditable(false);
    14         add(new Label("输入一些文本: "));
    15         add(from);
    16         add(new Label("你输入的文本是: "));
    17         add(to);
    18         //add TextListener
    19         from.addTextListener(this);
    20     }
    21     //implementation of textValueChanged method
    22     public void textValueChanged(TextEvent e){
    23         to.setText(from.getText());
    24     }
    25 }
  • 相关阅读:
    python基础学习之路No.2 数据类型
    练习题 --- 猜数字游戏
    python基础学习之路No.1
    python+selenium第一步
    Self-introduction
    oracle中的number类型
    简单选项卡切换(二)
    简单选项卡切换(一)
    简单焦点轮播(二)(图片可滚动)
    简单焦点轮播(一)
  • 原文地址:https://www.cnblogs.com/borter/p/9425393.html
Copyright © 2011-2022 走看看