refreshing changes to GUI

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: refreshing changes to GUI

  1. #1
    Join Date
    Aug 2003

    refreshing changes to GUI

    Hello folks.

    I was wondering if someone could help me.

    I have written an application that displays one set of components within a frame. I remove those components and then rebuild the underlying panel with a new set of components. The problem is that the new components don't appear in the frame. It removes the old ones fine, but doesn't display the new ones. I have a blank frame.

    The funny thing is, when I maximize the frame, all the components appear and everything works fine.

    I was trying to find a description of what exactly happens during maximizing a window, but have struck out so far. I think it has something to do with Window_State_Changed, but I can't nail down what it is I'm looking for.

    Any help would be greatly appreciated.


  2. #2
    Join Date
    Mar 2003


    Please post your code.


  3. #3
    Join Date
    Aug 2003


    Hi there. Sorry about the lack of code. Here it is with as many comments as I could cram into it...

    // for the instructions screen
    class instructionClickEvent implements ActionListener

    public void actionPerformed (ActionEvent e4)
    // here I remove the two components that are originally
    // displayed to the user
    basePanel.remove(instructUpperPanel); basePanel.remove(instructLowerPanel);

    // then I begin recreating the panel by adding
    // the newer components to it

    basePanel.setLayout(new GridLayout(2,1));
    basePanel.add(nPanel1); // place the north panel in the applet
    // which holds the images

    cPanel.setLayout(new GridLayout(5,1)); // change manager of central panel

    textPanel.add(description); // add the text area to the text panel

    cPanel.add(textPanel); // add it to the central panel

    cPanel.add(selection1); // add the radio button to the central panel
    selection1.addItemListener(new CheckEvent()); // add the item listener event so if checked
    // will execute

    cPanel.add(selection2); // add the radio button to the central panel
    selection2.addItemListener(new CheckEvent()); // add the item listener event so if checked
    // will execute

    cPanel.add(selection3); // add the radio button to the central panel
    selection3.addItemListener(new CheckEvent()); // add the item listener event so if checked
    // will execute

    sPanel.add(sButton); // add the button to the south panel
    sButton.addActionListener (new clickEvent()); // add the action listener so the program
    // will execute

    sButton2.addActionListener(new repeatClickEvent()); // will allow the user to repeat
    // the voice file

    sButton.setEnabled(false); // set the button to disabled


    // this is where I would like it to refresh the GUI
    // at this point I've tried paint(), repaint(), update() and a host
    // of other commands to get it to refresh the GUI, but nothing works
    // except maximizing the window

    loadFile (); // load the module information from
    // the text file

    mv= new ModuleVoices(); // create new thread to play voices
    mv.start(); // start the thread

    I hope that's enough. The basePanel is already part of a frame. It seems it would just need to be refreshed, but I can't find the command to do it.

    Thanks for the help.

  4. #4
    Join Date
    Mar 2003


    Add repaint() after you remove / add components.


  5. #5
    Join Date
    Sep 2003


    Don't forget the revalidate() to reorganized your objects to its position.

    ritchie diputado

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center