【Swing/文本组件】定义自动换行的文本域

  • 文本域组件:Swing中任何一个文本域(JTextArea)都是JTestArea类型的对象。常用的构造方法如下
    • public JTextArea()
    • public JTextArea(String text)
    • public JTextArea( int rows,int columns)
    • public JTextArea(Document doc)
  • 定义自动换行的文本域
     1 /**
     2  * 
     3  */
     4 package 常用窗体;
     5 
     6 import java.awt.Container;
     7 
     8 import javax.swing.JFrame;
     9 import javax.swing.JTextArea;
    10 import javax.swing.WindowConstants;
    11 
    12 /**
    13  * @author 粤晨下午9:29:54
    14  *
    15  */
    16 public class JTextAreaTest  extends JFrame{
    17     public JTextAreaTest() {
    18         
    19     
    20     Container c=getContentPane();
    21     JTextArea jt=new JTextArea("文本域",6,6);
    22     jt.setLineWrap(true);
    23     c.add(jt);
    24     setVisible(true);
    25     setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    26     
    27     }
    28     /**
    29      * @param args
    30      */
    31     public static void main(String[] args) {
    32         // TODO Auto-generated method stub
    33 
    34         new JTextAreaTest();
    35     }
    36 
    37 }
    View Code

     

转载于:https://www.cnblogs.com/yitou13/p/8576700.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值