我是用过JScrollPane,不过没有效果,也不报错.谁知道的话最好能给出一个小小的例程.

解决方案 »

  1.   

    JTextArea emptyTextArea = new JTextArea();
      JScrollPane sp = new JScrollPane(queryTextArea);
      sp.setBorder(new BevelBorder(BevelBorder.LOWERED));再把sp加到frame里!
    试试吧!
      

  2.   

    public class xxx{
        xxx(){
            JTextArea emptyTextArea = new JTextArea();
            JScrollPane sp = new JScrollPane(queryTextArea);
            sp.setBorder(new BevelBorder(BevelBorder.LOWERED));
            JFrame frame = new JFrame("xxx");
            frame.getContentPane().add(sp);
            frame.setVisible(true);  
       }
       public static void main(String [] s){
           xxx();
       }
    }考过去,编译一下试试吧!我随手写的,不知道过不过得去。我也是这两天现学的^_^
      

  3.   

    程序我调好了~~~~~不过~~~好莫明奇妙~~~~~import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;public class test extends JFrame{
        test(){
            JTextArea emptyTextArea = new JTextArea();
            JScrollPane sp = new JScrollPane(emptyTextArea);
            sp.setBorder(new BevelBorder(BevelBorder.LOWERED));
            JFrame frame = new JFrame("test");
            frame.setSize(100,100);
            frame.getContentPane().add(sp);
            frame.setVisible(true);
          }
         public static void main(String[] args) {
           test test1 = new test();
         }}老大,你给我的是~~~~~~!!@#$@%我不是要JTextArea这样单个的组件如何滚动内容.我的意思是指把好多个组件比如一堆JButton一堆JTextArea放到一个JPanel容器中,然后对这整个容器进行滚动.
      

  4.   

    刚做了一个java swing的assignment。 也被这个问题折磨得死去活来的。
    好在最后有结果了, 希望能帮到你。
    关键是最后那个scrollhttp://qeeze.blogspot.com/
      

  5.   

    http://qeeze.blogspot.com/这个网址打不开,不过blogspot.com倒是能打开,是不是你打错字母了.你能把大概的方法说一下吗.或是把你的assignment发给我. [email protected]
      

  6.   

    贴给你啦
    我assignment超大一个 琢磨scrollpane只不过是其中一项痛苦
    个人觉得是swing JSrollPane有问题啦 sun德tutorial里的例子都是不太work的 我只不过是找出一个折衷的办法,让scollbar一定要show出来我贴的是我总结出来的最简单的保证scroll得出来的例子
    JPanel d就是你要加其他组件的panelimport javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;public class TestScroll extends JFrame
    {
    private JPanel d;
    private JScrollPane sp;public TestScroll()
    {
    this.setTitle("test!!");
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);JPanel cp = new JPanel();
    cp.setBackground(Color.BLACK);
    cp.setLayout(new BorderLayout());this.d = new JPanel();
    d.setBackground(Color.WHITE);this.sp = new JScrollPane(d);
    cp.add(sp);
    cp.setPreferredSize(new Dimension(200, 200));
    this.setContentPane(cp);this.pack();
    this.setVisible(true);
    this.scroll();
    }public void scroll()
    {
    d.setPreferredSize(new Dimension(500, 500));
    d.revalidate();
    this.pack();
    this.setVisible(true);
    }public static void main(String[] argv)
    {
    TestScroll t = new TestScroll();
    }}
      

  7.   

    太感谢了,我要的就是d.setPreferredSize(new Dimension(500, 500));这句.
    非常感谢给你80分,另外20分给adLouis(adLouis)