麻烦添加文本到JTextArea(append或settext)(Trouble Adding text to JTextArea (append or settext))
所以我正在制作的程序使用2个线程:一个用于GUI,一个用于完成工作。
我希望工作线程/类的更新在GUI类中的JTextArea上打印出来。 我尝试的一切似乎都没有用。 我在行后面添加了一些行来打印文本,以便在JTextArea中添加文本以确保它已经到达行,但每次控制台都有文本但GUI中的JTextArea没有发生任何变化。
public static void consoleText(String consoleUpdate){ GUI.console.append(consoleUpdate); }
我在工人阶级试过这个,但什么也没发生。 有谁知道如何解决我的问题?
编辑:
MAIN.JAVA
public class main { public static void main(String[] args) { Thread t1 = new Thread(new GUI()); t1.start(); }
GUI.JAVA
public class GUI extends JFrame implements Runnable{ public static JTextArea console; private final static String newline = "\n"; public void run(){ GUI go = new GUI(); go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); go.setSize(350, 340); go.setVisible(true); } public GUI(){ setLayout(new FlowLayout()); console = new JTextArea(ConsoleContents, 15, 30); add(console); }
WORK.JAVA
...{ consoleText("\nI want this text on the JText Area"); } public static void consoleText(String consoleUpdate){ GUI.console.append(consoleUpdate); }
So the program I am making uses 2 threads: One for the GUI and one to do the work.
I want updates from the work thread/class to print out on JTextArea in GUI class. Everything I tried didn't seem to work. I added lines to print out text on the console right after lines to add text to the JTextArea to make sure it had got to the line but everytime console got text but no changes happened to JTextArea in the GUI.
public static void consoleText(String consoleUpdate){ GUI.console.append(consoleUpdate); }
I tried this in the work class but nothing happened. Anyone know how to fix my problem?
Edit:
MAIN.JAVA
public class main { public static void main(String[] args) { Thread t1 = new Thread(new GUI()); t1.start(); }
GUI.JAVA
public class GUI extends JFrame implements Runnable{ public static JTextArea console; private final static String newline = "\n"; public void run(){ GUI go = new GUI(); go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); go.setSize(350, 340); go.setVisible(true); } public GUI(){ setLayout(new FlowLayout()); console = new JTextArea(ConsoleContents, 15, 30); add(console); }
WORK.JAVA
...{ consoleText("\nI want this text on the JText Area"); } public static void consoleText(String consoleUpdate){ GUI.console.append(consoleUpdate); }
原文:https://stackoverflow.com/questions/13053107
最满意答案
我想你正在寻找一些旧的文档,autodesk决定保留这种方法,请查看http://help.autodesk.com/view/MAYAUL/2016/ENU/?guid=__cpp_ref_class_m_node_message_html
I think you are looking to some old documentation and autodesk decided to keep that method please check this http://help.autodesk.com/view/MAYAUL/2016/ENU/?guid=__cpp_ref_class_m_node_message_html
相关问答
更多-
maya培训学校哪个好?[2022-05-12]
国内MAYA比较权威的培训机构北边有火星时代,水晶石,南边有:CGWANG和环球数码。在选择的时候最好看看那个培训机构的学生作品,当然老师的作品也是很重要的衡量标准,推荐cgwang ,性价比最好的。重要的是实力也是最牛的。 -
MAYA怎么用。。。[2022-02-14]
MAYA的知识,实在太多了,MAYA主要分几大部分,如果你想学的话,可以在网上下栽一些教程,在到学校去进修下。 -
maya2009安装教程 maya2009安装说明[2019-10-26]
1. 首先在 C:\ 下创建一个名为 FLEXLM 的资料夹; 2. 拷贝 aw.dat 和 awkeygen.exe 到 FLEXLM 的资料夹下; 3. 安装 MAYA (最好在默认路径); 4. 点选开始-->所有程式-->Autodesk-->common utilities-->FlexLM license utilities; 5. 转到“system settings”选项卡,拷贝“Ethernet address”项后面的字串; 6. 使用记事本开启 FLEXLM 资料夹 ... -
Maya(脚本)中对象和节点之间有什么区别?(What is the difference between object and node in Maya (scripting)?)[2024-01-12]
cylinder_01是变换,用于处理平移,旋转,缩放等。 polyCylinder1是形状,它包含顶点,多边形,着色器连接等。 形状是变换的代表。 如果选择“ 显示”>“形状”,则可以在“大纲视图”中看到它 cylinder_01 is the transform, which handles translation, rotation, scale, etc. polyCylinder1 is the shape, which holds the vertices, polygons, shader c ... -
我想你正在寻找一些旧的文档,autodesk决定保留这种方法,请查看http://help.autodesk.com/view/MAYAUL/2016/ENU/?guid=__cpp_ref_class_m_node_message_html I think you are looking to some old documentation and autodesk decided to keep that method please check this http://help.autodesk.com/ ...
-
您可以在MAnimMessage 文档中继。这个回调可以帮助您找到关键帧操作并插入回调,例如: OpenMayaAnim.MAnimMessage.addAnimKeyframeEditedCallback( obj.addKeyframeDelta, None) You can relay on MAnimMessage Docs .This callback can help you to find the keyframe action and plug a callback eg : OpenMa ...
-
听起来你需要选择回调。 有了OpenMaya的api,就有了MEventMessage ,还有带有cmds scriptJob 。 这两个例子都可以在这里找到: 如何从Maya中获取突出显示场景中物体的事件? 出于性能原因,我建议使用MEventMessage而不是scriptJob 。 Sounds like you need a selection callback. With OpenMaya's api there's MEventMessage, and also scriptJob with c ...
-
伙计们, 终于找到了。 它完全不是它应该的位置。 Autodesk有一些奇怪的做事方式。 这里是: void removeMyNode(MObject &node, void *clientData) { MFnDependencyNode nodeFn(node); MGlobal::displayInfo(MString("Removal callback node: ") + nodeFn.name()); } MDGMessage::addNodeRemovedCallback(remov ...
-
权威名称是listAttr名称; 您在UI中看到的名称不可靠,因为AETemplate可以以任何方式覆盖它们。 AE经常呈现用于计算实际值的虚假属性 - 例如,摄像机在属性编辑器中具有angleOfView ,但设置它实际上会更改focalLength属性; 摄像机节点上没有angleOfView 。 因此,您可能需要做一些侦探工作来弄清楚可见UI的确在做什么。 玩滑块和观看历史是通常的第一步。 FWIW dict(zip(cmds.listAttr(), cmds.listAttr(sn=True))) ...