I'm trying to display a grid of TextPane's that are sized to fit a JPanel i've drawn into a Dialog class, the number of 'Cells' are entered into JTextFields and when the appropriate button is hit this method is executed. Each TextPane is stored as an object in the aray tableGrid. The code compiles fine, but when executed the JPanel remains blank.
I've created did using a book that explains it in AWT and i'm using SWING but so far as i can tell this should work for SWING too
Any help would be much appreciated.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//Parse all user input values for Table generation
rows = Integer.parseInt(jTextFieldRows.getText());
cols = Integer.parseInt(jTextFieldCols.getText());
width = Integer.parseInt(jTextFieldWidth.getText());
border = Integer.parseInt(jTextFieldBorder.getText());
//instantiate objects
int rowHeight = 500/rows;
int colWidth = 700/cols;
String labelString;
tableGrid = new Object[cols][rows];
for (int y=0; y<rows; y++);
{
for (int x=0; x<cols; x++);
{
labelString = "jTextPain"+x+y;
JTextPane textPane = new JTextPane();
tableGrid[x][y] = textPane;
textPane.setSize(colWidth, rowHeight);
textPane.setName(labelString);
}
}
jPanelTable.setLayout(new GridLayout(rows,cols));
//Pack the panel with the objects
for (int y=0; y<rows; y++);
{
for (int x=0; x<cols; x++);
{
JTextPane textPane = (JTextPane) tableGrid[x][y];
jPanelTable.add(textPane);
}
}
}