如何显示我在JFrame上的JOptionPane中输入的内容? [英] How do I display something I enter in a JOptionPane on the JFrame?

查看:117
本文介绍了如何显示我在JFrame上的JOptionPane中输入的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是当我在JOptionPane中输入某些内容时,例如APPLES.我想在JFrame中将其显示为APPLES.现在,如果我想接下来输入CATS,它将与APPLES一起出现在JFrame中.

What I want to do is when I input something in JOptionPane, say, APPLES. I want to display it as APPLES in the JFrame. Now, if I want to input CATS next, it'll appear in the JFrame together with the APPLES.

它应该像这样:APPLES CATS

It should look like this: APPLES CATS

当我输入更多内容时,它会显示并显示.我知道怎么做的唯一方法是对JLabel使用setText,但是它只显示一个单词.如何显示我输入的所有单词?

And when I input more, it just displays and displays. The only way I know how to do it is to use setText for JLabel, but it's only displaying ONE word. How do I display ALL of the words I input?

推荐答案

但是只显示一个字

but it's only displaying ONE word

希望您正在JFrame中用JOptionPane编写单词,请尝试以下操作:

Hoping that you are getting word written in JOptionPane in JFrame, try this:

jLabel.setText(jLabel.getText() + " " + strGotFromJOptionPane);

strGotFromJOptionPane是您从JOptionPane获得的文本.

Here strGotFromJOptionPane is the text you got from JOptionPane.

这篇关于如何显示我在JFrame上的JOptionPane中输入的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆