简体   繁体   English

JTextArea的默认值?

[英]JTextArea default value?

I have been taught only to manage the GUI through the event dispatcher thread. 我只被教过通过事件分配器线程来管理GUI。 Currently I am using a textArea.append("something"); 目前,我正在使用textArea.append("something"); outside of the event dispatcher thread, but I want this to always happen at the start of running the program. 在事件调度程序线程之外,但是我希望这种情况始终在运行程序开始时发生。 How can I set a listener to act upon the start up for the program or is what I have done acceptable? 如何设置侦听器以在程序启动时采取行动,或者我所做的一切可以接受?

在创建它时使用构造函数JTextArea(String text)

One solution is to create a method in the Class containing the JTextArea called localInitialization() or something like it, which is called in the class's constructor directly after initComponents(). 一种解决方案是在Class中创建一个包含JTextArea的方法,该方法称为localInitialization()或类似的名称,该方法在该类的构造函数中直接在initComponents()之后调用。 This allows you to put your own custom start-up conditions especially if you are using a GUI Builder such as the one in NetBeans where you cannot edit initComponents(). 这样,您就可以设置自己的自定义启动条件,尤其是在使用GUI生成器时,例如NetBeans中无法编辑initComponents()的GUI生成器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM