开发者

Method is java swing that clear a Jlist?

开发者 https://www.devze.com 2023-02-24 21:19 出处:网络
Is there a method in Java swing that clear a JList and a JTextField? for example I have开发者_JAVA百科 a string in a Jlist and a string in a JtextField and I want to press a \"cancel\" button, what m

Is there a method in Java swing that clear a JList and a JTextField?

for example I have开发者_JAVA百科 a string in a Jlist and a string in a JtextField and I want to press a "cancel" button, what method do i need to have in the mouse Listener in order for the Jlist and JtextField to clear?


For JTextField you can use the setText(""); method. See more here

For JList you can use the setListData(new Object[0]); method. If you want the list to stay but only remove the selection you can use the clearSelection() method. See more here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号