चयन करने के लिए, मैं चाहता हूँ जब कोई उपयोगकर्ता एक सेल पर क्लिक करता है, इस वाक्य स्क्रीन पर मुद्रित करने के लिए:जावा: कैसे एक JTable में केवल एक ही सेल और एक JTable में नहीं पूरी पंक्ति
I am cell in row X and column Y
जहां एक्स और वाई क्लिक किए गए सेल की पंक्ति और कॉलम हैं। लेकिन क्या मैं हो रही है:
I am cell in row 1 and column 0
I am cell in row 1 and column 1
I am cell in row 1 and column 2
....
I am cell in row 1 and column N (N = number of columns)
अर्थात समूची पंक्ति का चयन किया जाता है: जब मैं उदाहरण के लिए पंक्ति 1 और स्तंभ 4 में सेल क्लिक करें मैं निम्नलिखित मिलता है।
public class CustomTableCellRenderer extends DefaultTableCellRenderer{
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(isSelected) System.out.println("I am cell in row "+row+" and column "+column);
return cell;
}
}
किसी भी मदद के लिए धन्यवाद:
इसकोड है।
क्या आप चयनित जेटीबल पंक्ति – mKorbel