我如何在JLabel中显示队列?(How can i show a Queue in a JLabel?)

编程入门 行业动态 更新时间:2024-10-28 14:35:56
我如何在JLabel中显示队列?(How can i show a Queue in a JLabel?)

我有个问题。 我有一个队列,我想用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);

更多推荐

本文发布于:2023-08-07 04:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1459731.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:队列   如何在   Queue   JLabel   show

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!