java - Have to move screen to get JTextArea to appear -


i have desktop pane program user inputs data , jtextarea appears results. instead of having text area, wanted add scroll pane, did. created new scroll pane, , added text area it. now, when put in data text area in scroll pane not appear until move page. in other words, works, have move page little in order results , scroll pane show on screen.

any ideas on why happening?

 private jtextarea matchlistresults = new jtextarea();  private jpanel matchpanelbase = new jpanel(new borderlayout());  private jscrollpane mresults = new jscrollpane();      private void matchresframe(string[] matchresultarray) throws ioexception,          sqlexception {          dimension size = new dimension();         size.setsize(400, 300);         matchlistresults.setpreferredsize(size);         matchlistresults.setfont(font); 

. . .

        mresults.getviewport().add(matchlistresults);         matchlistresults.setvisible(true);         matchpanelbase.add(mresults, borderlayout.center);     } 

when add components visible gui basic code is:

panel.add(...); panel.revalidate(); panel.repaint(); 

by default components have size of (0, 0) there nothing paint. revalidate() invoke layout manager determine components size , location.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -