使用JTextArea示例
2024-08-27 10:54:24
相对于JLabel显示提示文字,JTextArea有一个先天优势:文字可以拷贝出来。经过下面设置它也能在外观上和JLabel一致。
代码如下:
JTextArea txtArea=new JTextArea(5,20);// 初始化 // 设置文字 txtArea.setText("We needto update personal business forecast data in staffing plan to get the budgetupdates. Due to the complexities of Staffing Plan sheet, it is necessary tohave one tool, which will help to inject the forecasted data into the staffingplan sheet automatically. The tool will thus, save time of a financial analystto get the budget on time."); txtArea.setFont(new Font("Arial",Font.PLAIN,14));// 设置字体 txtArea.setLineWrap(true);// 自动换行 txtArea.setWrapStyleWord(true);// 根据单词封装换行字符 txtArea.setBackground(this.getBackground());// 取所在面板的背景色 txtArea.setPreferredSize(new Dimension(800, 30));// 设置宽度
效果如下:
注意以上图文无关。
最新文章
- 从零开始学 Java - Spring 集成 ActiveMQ 配置(二)
- this上下文,以及通过call 、apply 实现继承
- STL 阅读(浅析)
- poj 3463 最短路与次短路的方案数求解
- 2. xargs 命令
- isScroll代码
- 【POJ】【2699】The Maximum Number of Strong Kings
- Ajax乱码问题
- wojilu中的路由
- random.sample
- UML中的类间的关系
- shapeless官方指南翻译总结
- 分布式版本控制git常见问题之gitignore冲突(精简版)
- js禁止选中(网页复制)
- 利用jquery实现电商网站常用特效之:五星评分
- Python2.x爬虫入门之URLError异常处理
- servlet对象的生命周期
- HDU 1021(斐波那契数与因子3 **)
- 使用recyclerView item布局match_parent属性失效的问题
- .NET设计模式 第二部分 创建型模式(2)—抽象工厂模式(Abstract Factory)