you should add a label in a Panel,
which is added in a Frame.

解决方案 »

  1.   

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;public class talkbean implements WindowListener,MouseMotionListener
        ,AdjustmentListener
    {
    private Frame frame;
    private Label jj;
    void setframe(String frameTitle)
    {
    frame = new Frame( frameTitle);
    frame.setSize(10,400);
    frame.addWindowListener(this);
    frame.addMouseMotionListener(this);
    frame.setVisible(true);
    }
    public talkbean(String frameTitle)
    {
    setframe(frameTitle);
    }
    public static void main (String arg[])
    {
    talkbean talk = new talkbean(arg[0]);
    talk.adduser(talk,arg[1]);
    }
    void adduser(talkbean talk,String labelName)
    {
    talk.frame.add(new  Label (labelName)) ;
    }
    public void windowClosing(WindowEvent we)
    {
    System.exit(0);
    }
    public void windowOpened(WindowEvent we)
    {
    }
    public void windowIconified(WindowEvent we){}
    public void windowDeiconified(WindowEvent we){}
    public void windowActivated(WindowEvent we){}
    public void windowDeactivated(WindowEvent we){}
    public void windowClosed(WindowEvent we){}
    public void mouseDragged(MouseEvent me){}
    public void mouseMoved(MouseEvent me){} public void adjustmentValueChanged(AdjustmentEvent ev)
    {
    AdjustmentEvent bx;
    if (ev.getAdjustmentType()==1)
    {
    //this is downs event
    }
    if (ev.getAdjustmentType()==2)
    {
      //this is up event
    }
    }
    }
      

  2.   

    试了次,不行:(~~ 问一下,老大你自己测试了么,我做,出不来LABEL!
      

  3.   

    //需要刷新,刷新方案有二
    1、人为改变窗体大小
    2、加代码,如下: void adduser(talkbean talk){
        talk.frame.add(new  Label ("asdfasd")) ;    
        frame.setVisible(true);//刷新
     }