相对于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));// 设置宽度

效果如下:

注意以上图文无关。

最新文章

  1. 从零开始学 Java - Spring 集成 ActiveMQ 配置(二)
  2. this上下文,以及通过call 、apply 实现继承
  3. STL 阅读(浅析)
  4. poj 3463 最短路与次短路的方案数求解
  5. 2. xargs 命令
  6. isScroll代码
  7. 【POJ】【2699】The Maximum Number of Strong Kings
  8. Ajax乱码问题
  9. wojilu中的路由
  10. random.sample
  11. UML中的类间的关系
  12. shapeless官方指南翻译总结
  13. 分布式版本控制git常见问题之gitignore冲突(精简版)
  14. js禁止选中(网页复制)
  15. 利用jquery实现电商网站常用特效之:五星评分
  16. Python2.x爬虫入门之URLError异常处理
  17. servlet对象的生命周期
  18. HDU 1021(斐波那契数与因子3 **)
  19. 使用recyclerView item布局match_parent属性失效的问题
  20. .NET设计模式 第二部分 创建型模式(2)—抽象工厂模式(Abstract Factory)

热门文章

  1. Linux打包压缩
  2. Ubuntu 18.04安装 Sublime
  3. 缓存(LruCache)机制
  4. ZUFEOJ 2147 07染色带谜题
  5. 桌面笔记工具KeepNote
  6. Xamarin XAML语言教程模板页面TemplatedPage
  7. javascript中的对象创建与继承
  8. 使用phonegap开发安卓HLS播放软件解决方案
  9. A/B Problem(大数)
  10. 又见Python<3>:Pandas之Series对象的使用