jeudi 26 mars 2015

JTextArea getColumns, getRows returning 0



I have a JTextArea I want to display a specific array of lines of text based on the number of columns and rows; but getColumns and getRows are returning zero. The following should give an idea of what I am trying to accomplish:



public class Frame extends JFrame implements ComponentListener {
...
this.textArea = new JTextArea();
this.textArea.setFocusable(false);
this.textArea.setFont(new Font(Font.MONOSPACED, Font.BOLD, 20));
this.add(textArea, BorderLayout.CENTER);
this.editor = new Editor(new File("test"));
this.textArea.addComponentListener(this);
...
@Override
public void componentResized(ComponentEvent ce) {
this.editor.setHeight(this.textArea.getRows());
this.editor.setWidth(this.textArea.getColumns());
drawText();
}


Why are getRows and getColumns returning zero?




Aucun commentaire:

Enregistrer un commentaire