简体   繁体   English

如何使用Java中的jButton从TextArea打印文本?

[英]How to print the text from a TextArea using a jButton in java?

How can I print the texts from a TextArea using a jButton? 如何使用jButton从TextArea打印文本? I'm using netbeans, btw. 我正在使用netbeans,顺便说一句。 Can anyone help me? 谁能帮我? It's for my midterm project in school. 这是我在学校的期中项目。

use getText() method of textarea to get the text. 使用textarea的getText()方法获取文本。 Use System.out.println() to print it in console, or if not console, follow your approach. 使用System.out.println()在控制台中打印它,如果没有,请按照您的方法进行打印。 Do these things inside the JButton's event handler. 在JButton的事件处理程序中执行这些操作。

public void actionPerformed(ActionEvent aew)
{
    JTextArea text = new JTextArea();

    String result = text.getText();
}

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

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