java - Update Grid in GridLayout -


i have array of objects laid out through gridlayout in jpanel. need able recreate object in index in array , have gridlayout update reflect this. of yet, cannot find anyway "refresh" or redraw gridlayout. possible refresh gridlayout without creating entire gridlayout or jpanel? assume not have access jframe.

import javax.swing.*; import java.awt.*;  public class test {     public static void main(string args[])     {         jframe frame = new jframe();         jpanel panel = new jpanel();          panel.setlayout(new gridlayout(5,5));          jlabel[][] labels = new jlabel[5][5];         (int = 0; < 5; i++)         {             (int j = 0; j < 5; j++)             {                 labels[j][i] = new jlabel("("+j+", "+i+")");                 panel.add(labels[j][i]);             }         }          labels[0][0] = new jlabel("hello world");          //without doing way (cause objects can't this)         //labels[0][0].settext("hello world!");          frame.add(panel);          frame.setdefaultcloseoperation(jframe.exit_on_close);          frame.pack();         frame.setresizable(false);         frame.setvisible(true);     } } 

i don't understand why can't update text on label.

why need "recreate object"? makes no sense. if need code like:

panel.remove(0); panel.add(thenewlabel, 0); panel.revalidate(); panel.repaint(); 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -