NetBeans Swing TextArea不是静态的,会引起麻烦 [英] NetBeans Swing TextArea is not static, causes trouble
问题描述
我已经创建了一个名为texttextArea的JFrame,名为'outputTextArea',我想在textArea中打印数据库查询的结果.但是,变量outputTextarea不是静态的,因此我无法在main方法中调用setText()方法来在textArea中打印数据库结果集.
I have created a JFrame with a textArea called 'outputTextArea' and I want to print the results from a database query in the textArea. However, the variable outputTextarea is not static and therefore I can't call the method setText() in the main method to print the db resultset in the textArea.
我想知道如何使此变量(私有javax.swing.JTextArea outputTextArea;)成为静态变量,因为NetBeans不允许我编辑此变量,因为它是由NetBeans拖放textArea时生成的.
I would like to know how I can make this variable (private javax.swing.JTextArea outputTextArea;) static, because NetBeans won't let me edit this variable because it was generated by NetBeans when I dragged and dropped the textArea.
推荐答案
我遇到了同样的问题. 在Netbeans IDE 8.0.2中: 1)在设计标签中 2)点击文本区域 3)转到属性->代码 4)变量修饰符->添加静态变量.
I had the same problem. In Netbeans IDE 8.0.2: 1) In the design tab 2) Click on the textarea 3) go to properties -> code 4) Variable Modifiers -> add static.
对我有用.
这篇关于NetBeans Swing TextArea不是静态的,会引起麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!