[英]How can I hide a jlist until a button has been clicked?
I am a beginner programmer and writing a simple jApplet for a presentation. 我是初学程序员,为演示文稿编写一个简单的jApplet。 The applet asks for the user's name and then says hello to them and asks how they are doing. 小应用程序询问用户的名字,然后向他们打招呼并询问他们是如何做的。 At that time I want a list of options to appear for the user to select. 那时我想要一个供用户选择的选项列表。
The problem is that I do not know how to hide the list. 问题是我不知道如何隐藏列表。 I have looked through the properties and couldn't find a display or visible option. 我查看了属性,找不到显示或可见选项。 I have also tried to set the visible row count to 0. Which doesn't get rid of it completely but it is good enough for my intentions. 我还试图将可见的行数设置为0.这并没有完全摆脱它,但它足以满足我的意图。 When I try to change that in the btnclick function to 当我尝试在btnclick函数中将其更改为
feelingLst.setVisibleRowCount(4);
Nothing shows up. 什么都没有出现。
How can I hide this box and then show it when I need it? 如何隐藏此框,然后在需要时显示它? It should be noted that it is inside a JScrollPane (feelingSPnl) which netbeans keeps adding even though I do not want it. 应该注意的是,它位于JScrollPane(feelingSPnl)中,即使我不想要它,netbeans也会继续添加。
Set visible(false) the JScrollPane of the Jlist, and then set it back to visible(true) in the actionPerformed for the corresponding button. 设置Jlist的JScrollPane可见(false),然后在actionPerformed中将其设置为可见(true)以显示相应的按钮。 Note that, if you only set to invisible the list, you'll get the empty scrollpane. 请注意,如果您只设置为隐藏列表,您将获得空滚动窗格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.