JTable with 10 columns is there. Need to arrange the dynamically created 10 JCheckboxes and arrange it in a row above the JTable. And align each JCheckboxes left position to the jtable first row each cell x coordinate.
Java Swing GUI appearance :
JInternalFrame-> with two JScrollpanes
(Top & Bottom)
Top Area : JScrollpane->JPanel->JCheckbox's
(10 check boxes)
Bottom Area : JScrollpane->JTable
(10 columns)
Here I want to arrange each check boxes x coordinate with the tables each cell x coordinate.
I tried the below code and it won't work. (worked like, the 10 check boxes covered with in the table's 5 column widths)
The column count of the table and the creation of check boxes are dynamic and it will change when ever needed.
panel.setPreferredSize(new Dimension(scrollpane.getPreferredSize().width, scrollpane.getPreferredSize().height));
int intColCount=table.getColumnCount();
int intX=0;
JCheckBox checkboxTop[] = new JCheckBox[intColCount];
JCheckBox checkboxBottom[] = new JCheckBox[intColCount];
for(int i=0;i<intColCount;i++){
intX = (int)table.getCellRect(0, i, true).getX();
checkboxTop[i]= new JCheckBox("Top "+(i+1));
panel.add(checkboxTop[i]);
checkboxTop[i].setBounds(intX, 10, 50, 10);
checkboxBottom[i]= new JCheckBox("Bottom "+(i+1));
panel.add(checkboxBottom[i]);
checkboxBottom[i].setBounds(intX, 30, 50, 10);
}
panel.setPreferredSize(new Dimension(intColCount*(int_each_cell_width), panel.getPreferredSize().height));
Can any one share some idea...