Re: Change status bar text back to default 5 seconds after every change?



cdj,

Create a custom control. Inside it, do what you're currently doing. I
assume you're doing something like using OnChange to start a timer and
using the timer's callback to reset the status bar's data. To prevent
the endless loop, add a boolean member variable. Try this:

public class myControl : StatusBar
{

private boolean bDefault = true;
private Timer timeReset = new Timer(...);

public void OnChange(...)
{
if (!this.bDefault)
this.timeReset.Reset();
}

public void OnTimerTick(...)
{
this.bDefault = true;
// set text back to default
Text = "Ready.";
}

public void SetText(string text)
{
this.bDefault = false;
Text = text;
}

}

I don't guarantee this code compiles, it's more to demonstrate a point.
You probably want to use a property override instead of SetText(), but
I wrote it that way for clarity. Also, I've not dealt with thread
safety.


Stephan



sherifffruitfly wrote:
Hi,

I'm using StatusBar text to inform the user what's going on in the
application. I pass a reference to from the main form's class to other
(instances of) classes that are doing the actual work, and they update
the Text property in various ways.

It would be slick (imo) if, after the user is informed about the antics
of some class-instance, if the StatusBar text would revert back to some
default text-variable in the main form class after some specified
interval of time (like 5 seconds).

Problem is, that I can't use the StatusBar's OnChange event (or
whatever's it's called) - if I did, then every time the "reversion" was
perform, the event would fire again.

So how would I go about implementing this? Even just a skeleton
code-example would be helpful.


Thanks for any ideas,

cdj

.



Relevant Pages

  • Re: subclass JPasswordField
    ... for (like how to add a document change listener to the PlainDocument ... inside the JPasswordField & how to set the timer and all). ... Google "java timer tutorial". ... public void insertUpdate{ ...
    (comp.lang.java.programmer)
  • Re: Pocket outlook - AppointmentsCollection class: ListChanged event
    ... void POOMHelper_OutlookItemChanged(PIMNotificationMessage notification, PIMItemType itemType, int itemOID, int databaseOID) ... static Timer timer= new Timer; ... Thread timerThread = timer.Start; ... public void SleepIntermittently ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Animating auto hide of JPanel inside a JFrame
    ... When the mouse is brought close to the top of the panel, a label 'slides' down ... public void actionPerformed ... private void positionLabel ... Timer class that is called back at intervals. ...
    (comp.lang.java.gui)
  • Panels on a BorderLayout
    ... I have just finished this application that draws a rectangle inside a panel & uses a thread or a timer to animate it. ... int size = 0; ... public void setSize{ ...
    (comp.lang.java.help)