java - How to add components to a JPanel that was generated by netbeans gui builder in my source code. -


i writing program draws different shapes onto jpanel given different dimensions used netbeans gui builder make gui part, generated jpanel(jpanel1) want draw graphics component have class(mygraphics) jpanel1.add(new mygraphics()); not anything. how add stuff autogenerated jpanel? tried doing jpanel1.setbackground(color.red); , worked fine why doesn't jpanel1.add(new mygraphics()); work?

try call jpanel method repaint or paintimmediately (inherited jcomponent).

usually repaint dispatched runnable this:

swingutilities.invokelater(new runnable() { public void run() {         repaint();     } });  

edit: if have gui user interacts (e.g button fire event's), important make use of concurrency application doesn't freeze.

some useful reading on concurrency

good luck :)


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -