DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2003
    Posts
    6

    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.

    Thanks.

  2. #2
    Join Date
    Mar 2003
    Posts
    86

    Code

    Please post your code.

    Sharbov.

  3. #3
    Join Date
    Aug 2003
    Posts
    6

    Code...

    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

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

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

    cPanel.add(sPanel);
    basePanel.add(cPanel);

    // 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
    Posts
    86

    repaint()

    Add repaint() after you remove / add components.

    Sharbov.

  5. #5
    Join Date
    Sep 2003
    Posts
    1

    revalidate()

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

    ritchie diputado

Bookmarks

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links