मैं कॉलम के हेडर को सेट करने में सक्षम हूं लेकिन JTable के पहले कॉलम की सभी पंक्तियों में आइकन सेट करने में सक्षम नहीं हूं।जेटीबल के कॉलम में आइकन कैसे सेट करें?
public class iconRenderer extends DefaultTableCellRenderer{
public Component getTableCellRendererComponent(JTable table,Object obj,boolean isSelected,boolean hasFocus,int row,int column){
imageicon i=(imageicon)obj;
if(obj==i)
setIcon(i.imageIcon);
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(JLabel.CENTER);
return this;
}
}
public class imageicon{
ImageIcon imageIcon;
imageicon(ImageIcon icon){
imageIcon=icon;
}
}
और मेरे BuildTable() विधि में लाइनों के नीचे।
public void SetIcon(JTable table, int col_index, ImageIcon icon){
table.getTableHeader().getColumnModel().getColumn(col_index).setHeaderRenderer(new iconRenderer());
table.getColumnModel().getColumn(col_index).setHeaderValue(new imageicon(icon));
}
हम कैसे यह पहली स्तंभों की सभी पंक्तियों के लिए सेट कर सकते हैं? मैंने लूप के साथ प्रयास किया है लेकिन आइकन सेट करने के लिए फिर से चलाने के लिए पंक्तियों के लिए अभी तक नहीं मिला है। या कोई और तरीका है?
यह कोड अब क्या करता है? इसके साथ क्या विशेष रूप से गलत है। – jzd
इमेजिकॉन क्लास का बिंदु भी क्या है। बस उस कॉलम में छवि को स्टोर करें और इस अन्य वर्ग से निपटने के बजाय इसे सीधे इस्तेमाल करें। – jzd
इसके सेटिंग कॉलम का हेडर केवल। लेकिन पहले कॉलम की सभी पंक्तियों में आइकन डालना चाहते हैं। – bsm