rt

解决方案 »

  1.   

    在 swing 和 awt里面
      

  2.   

    Button bu = new Button("按我");
    bu.addActionListener(
    new ActionListener(){
    public void actionPerformed(ActionEvent e){
    System.out.println(((Button)e.getSource()).getLabel());
    }

    });
      

  3.   

    Button bu = new Button("按我");
    TextField tf = new TextField();
    bu.addActionListener(
    new ActionListener(){
    public void actionPerformed(ActionEvent e){
    System.out.println(((Button)e.getSource()).getLabel());
    tf.setText("嘎嘎嘎嘎嘎嘎");
    }});
      

  4.   

    借用一下楼上的 少打几个字
    Button bu = new Button("按我");
    JTextField text = new JTextField();
    bu.addActionListener(
    new ActionListener(){
    public void actionPerformed(ActionEvent e){
      text.setText("你想要的文字");
    }
    });
      

  5.   

    在文本框后面追加文字,不删除原来的文字StringBuffer textInfo=new StringBuffer(text.getText());
    textInfo.append("想追加的文字");
    text.setText(textInfo.toString());