我有个问题。 我有一个队列,我想用JLabel文本显示它,但我不知道如何将队列中的完整数据放在一个JLabel中,我的意思是。 我知道方法JLabel.setText(),但是每当我从队列中显示一个新数据时,JLabel会刷新,然后显示我之前放置的那些数据,并且我希望在JLabel中显示完整的队列以将数据,像这样,但在JLabel中......
for(int i=0;i<Queue.length;i++);{ { System.out.print(Queue.push()+" ");}而我的问题是当我尝试显示推送队列的另一个数据时,JLabel刷新文本...
for(int i=0;i<Queue.length;i++);{ { JLabel.setText(Queue.push()+" ");}有一种方法可以正确显示它? 谢谢!。
I have a question. I have a queue and I want to show it in JLabel text, but I dont know how put the complete data from the queue in just one JLabel, I mean. I know the method JLabel.setText(), but each time I show a new data from the queue the JLabel refresh and then the data that I put before of that dissapear, and I want to show the complete Queue in a JLabel spacing the data, like this but in a JLabel...
for(int i=0;i<Queue.length;i++);{ { System.out.print(Queue.push()+" ");}and my problem is when I try to show the another data pushing the Queue, the JLabel refresh the text...
for(int i=0;i<Queue.length;i++);{ { JLabel.setText(Queue.push()+" ");}there is a method to show it correctly? thank you!.
最满意答案
您需要收集字符串变量中的所有值,然后进行设置。
String text = ""; for(int i=0;i<Queue.length;i++){ text += Queue.push()+" "; } JLabel.setText(text.trim());可能最好将它显示为HTML。 所以你可以进行换行
String text = "<html>"; for(int i=0;i<Queue.length;i++){ text += Queue.push()+"<br>"; } text += "</html>" JLabel.setText(text);You need to collect all values in a string variable and then set it.
String text = ""; for(int i=0;i<Queue.length;i++){ text += Queue.push()+" "; } JLabel.setText(text.trim());Probably it would be better to show it as HTML. So you can make the line-break
String text = "<html>"; for(int i=0;i<Queue.length;i++){ text += Queue.push()+"<br>"; } text += "</html>" JLabel.setText(text);更多推荐
发布评论