मेरे वर्तमान स्विंग प्रोजेक्ट में मेरे पास JList
सभी सक्रिय सॉकेट प्रदर्शित कर रहा है, और प्रत्येक सेल में उस सॉकेट को बंद करने के लिए JButton
है। लेकिन सेल में JButton
क्लिक करने योग्य नहीं है: श्रोता को निकाल दिया नहीं जाता है।जेएलटीटी सेल में जेबटन क्लिक करने योग्य नहीं है
मैंने निम्नानुसार कोड को न्यूनतम में संशोधित किया है।
private class ConnectionListRenderer extends JButton implements ListCellRenderer {
public Component getListCellRendererComponent(JList jlist, Object o, int i, boolean bln, boolean bln1) {
addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
//do something (close the socket in my project)
}
});
return this;
}
}
jList.setCellRenderer(new ConnectionListRenderer());
सूची ठीक दिखती है, लेकिन बटन पर क्लिक करने योग्य नहीं है। क्या मैं गलत हूं या JList
बस निकालकर JButton
का समर्थन नहीं करता है?
(जैसा कि आप जानते :-) – kleopatra