开发者

Selectable panel in Swing

开发者 https://www.devze.com 2023-03-09 19:09 出处:网络
I´m trying to make something similar to the downloads panel of Transmission BT (here an image: http://www.transmissionbt.com/images/screenshots/Mac-Large.jpg) but I´m having some problems.

I´m trying to make something similar to the downloads panel of Transmission BT (here an image: http://www.transmissionbt.com/images/screenshots/Mac-Large.jpg) but I´m having some problems. I made a JPanel with the progress bar, labels, icon and buttons开发者_C百科 and then added this panel to a container (JPanel again) but I need to make this component selectable.

How can I do this?


You can simply use JList and ListCellRenderer to render your existing panel in a JList .


Dont you think A table would be easier with this? It has al the functions you need. JUst create a table on a FRAME and then remove the headers so you just have the table. In this was you can easily handle what was selected..

Another way is to use a grid layout that changes on each addition and then each section of the column grid should have a panel. Each panel should have a mouse listener for a click. When clicked you just change the background color.

They are stil more ways of handling this so these are just two.

Goodluck

0

精彩评论

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