我的布局方式是null,
所有组件的位置都是setBounds

解决方案 »

  1.   

    add a viewPort
    eg:     JTextArea ta = new JTextArea()
            JScrollPane tempSP = new JScrollPane();
            JViewport tempVP = tempSP.getViewport();
            tempVP.add(ta);
      

  2.   

    JTextArea jTextArea1 = new JTextArea()
    JScrollPane JScrollPane1 = new JScrollPane();
    jScrollPane1.getViewport().add(jTextArea1);
      

  3.   

    另起一个简单测试,还是不行(只显示Area,没有Scroll)。
    import java.awt.*;
    import javax.swing.*;public class testFrame extends Frame{

    JTextArea jTextArea;
    JScrollPane jScrollPane;

        
    public testFrame()
    {

    jTextArea = new JTextArea(10,10);
    jTextArea.setBounds(0,0,200,200);
    jScrollPane = new JScrollPane();
    jScrollPane.getViewport().add(jTextArea);


    add(jScrollPane);
    add(jTextArea);

    pack();
    setBounds(0,0,200,200);
    show();
    } public static void main(String arg[])
    {
    testFrame frame = new testFrame();
    }
    }
      

  4.   

    import java.awt.*;
    import javax.swing.*;public class testFrame extends Frame{

    JTextArea jTextArea;
    JScrollPane jScrollPane;

        
    public testFrame()
    {

    jTextArea = new JTextArea(10,10);
    jTextArea.setBounds(0,0,200,200);
    jScrollPane = new JScrollPane();
    jScrollPane.getViewport().add(jTextArea);


    add(jScrollPane);
    //add(jTextArea); 删除不要

    pack();
    setBounds(0,0,200,200);
    show();
    } public static void main(String arg[])
    {
    testFrame frame = new testFrame();
    }
    }