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 jButton1ActionP erformed(java.a wt.event.Action Event evt) {
//Parse all user input values for Table generation
rows = Integer.parseIn t(jTextFieldRow s.getText());
cols = Integer.parseIn t(jTextFieldCol s.getText());
width = Integer.parseIn t(jTextFieldWid th.getText());
border = Integer.parseIn t(jTextFieldBor der.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.setSiz e(colWidth, rowHeight);
textPane.setNam e(labelString);
}
}
jPanelTable.set Layout(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);
}
}
}
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 jButton1ActionP erformed(java.a wt.event.Action Event evt) {
//Parse all user input values for Table generation
rows = Integer.parseIn t(jTextFieldRow s.getText());
cols = Integer.parseIn t(jTextFieldCol s.getText());
width = Integer.parseIn t(jTextFieldWid th.getText());
border = Integer.parseIn t(jTextFieldBor der.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.setSiz e(colWidth, rowHeight);
textPane.setNam e(labelString);
}
}
jPanelTable.set Layout(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);
}
}
}
Comment