简体   繁体   中英

using JList of Swing

I have a 3 Jlist, the first contain the name of application. the second is used to put the name of application to install, the third the name of application to uninstall. but it is not beautiful. I would like to have one list with two list of radio button for each List we can choose install or uninstall but i don't know how to do that in swing.

You might look at a two-column JTable , with the name in the first column and a JComboBox in the second. The JComboBox would specify install , uninstall or unchanged , defaulting to unchanged . This example shows how to specify a DefaultCellEditor having a JComboBox . See How to Use Tables for more. Some related alternatives are mentioned here .

I haven't got the scenario quite clearly.
Try this out.
Take 2 JRadioButton , one JButtonGroup and 3 JList . Set buttonGroup property of those 2 radio buttons to that JButtonGroup . Then write codes on onClick event of each radio button to enable the corresponding JList and disable the other JList .
I hope this will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM