Java中JTextArea添加滚动条

  JTextArea  Shortestway,TXT,OUTPUT_RESULT;
  JScrollPane   scroll;
  JMenuBar jb;
  JTextArea ja;


class WindowText0 extends JFrame 
 { 
     WindowText0(String s) 
     { 
         this.setLayout(new GridLayout());                            
    p=new JPanel();
    p_login=new JPanel();
    p7=new JPanel();
    p_login.setLayout(new GridLayout(4,2));
    TXT = new JTextArea(10,30);
    jb = new JMenuBar();
    this.setJMenuBar(jb);
    //ja = new JTextArea();
    scroll = new JScrollPane(TXT);
    //p7.add(TXT);
    p_login.add(p7);
    p.add(p_login);
    p.add(scroll);
    //p.add(p5);
    this.add(p,"Center");
        //setBounds(500, 500, 200, 150);
        this.setBounds(400, 400, 1200, 600);
        for(int i=0;i<edges.size();i++)
  {
   TXT.append("From:"+edges.get(i).start_node+"  To:"+edges.get(i).end_node+"  Weight:"+edges.get(i).weight+"\n");
   //System.out.println();
  }
        this.addWindowListener (new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                setVisible (false);
                //System.exit(0);
            }
    });
  this.setVisible(true);
  
        //setVisible(true); 
        validate();//
     }    
     
 }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值