🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16938

Animation revisited (i.e. when does a screen refresh)

#16938
From: Tom Heagy
Date: Tue, 05 Jan 1999 00:00
64 lines
2601 bytes
The following is a simple class that exemplifies my problem with
refreshing an updated control during a time consuming or delayed
process.  This frame has a text control with the word "BEFORE" initially
set.  When the command button is clicked, the text for the control is
immediately set to "AFTER".  The code then proceeds to loop for a while
in order to reflect about a 1-2 second delay.  After the delay, the text
is changed to the word "MORE".  The problem is: You will never see the
word "AFTER".  The screen won't refresh until after the looping is
finished.  If anyone can get this to work, I would greatly appreciate
it.  I'm starting to pull out what little hair I have left in my thick
skull!

Thanks,

-Tom

====== LISTING FOLLOWS =======
import java.awt.*;
import java.awt.event.*;
import borland.jbcl.control.*;
import borland.jbcl.layout.*;

public class TestFrame extends DecoratedFrame {

  BorderLayout borderLayout1 = new BorderLayout();
  XYLayout xYLayout2 = new XYLayout();
  BevelPanel bevelPanel1 = new BevelPanel();
  TextControl tc1 = new TextControl();
  ButtonControl cbOK = new ButtonControl();

  public TestFrame() {
    try  {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void jbInit() throws Exception  {
    this.setLayout(borderLayout1);
    this.setSize(new Dimension(443, 365));
    this.setTitle("TESTING");
    tc1.setFont(new Font("Dialog", 1, 20));
    tc1.setText("BEFORE");
    cbOK.setLabel("Change");
    cbOK.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        cbOK_actionPerformed(e);
      }
    });
    bevelPanel1.setLayout(xYLayout2);
    this.add(bevelPanel1, BorderLayout.CENTER);
    bevelPanel1.add(tc1, new XYConstraints(82, 69, 93, 35));
    bevelPanel1.add(cbOK, new XYConstraints(264, 50, 85, 51));
  }

  void cbOK_actionPerformed(ActionEvent e) {
    tc1.setText("AFTER");
    for (int j=1; j < 5000000; j++)
    {}
    tc1.setText("MORE");
  }
}
Technical Details
Message-ID: <3692836D.C7FE0802@sciatl.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,7fea73d52964a1ef,start
X-Google-Attributes: gidf74b3,public
From: Tom Heagy <tom.heagy@sciatl.com>
Subject: Animation revisited (i.e. when does a screen refresh)
Date: 1999/01/05
Message-ID: <3692836D.C7FE0802@sciatl.com>
X-Deja-AN: 429155513
Content-Transfer-Encoding: 7bit
Organization: Another Netscape Collabra Server User
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language