Search:

Type: Posts; User: Norm

Search: Search took 0.13 seconds.

  1. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    Which part don't you understand?
    create instances of the ActionListener classes:
    For example: AClass ac = new AClass();
    Use those instances in the calls to the Timer constructor
    ... new...
  2. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    The code needs to create instances of the classes and use them in the Timer constructors.
  3. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    Where is the separate listener for the second timer? You can't makeup names for listener methods. This method is not used for anything:

    public void actionPerformed2(ActionEvent e)

    You should...
  4. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    The second timer MUST have its own action listener method. It should not share a listener.
    In its listener showMsg can be set false.
  5. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    If showMsg is true the message should be drawn
    If showMsg is false the message should not be drawn
    showMsg will stay true until the one sec timer's listener method sets it false

    You'll have to...
  6. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    What is the second part?
  7. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    Drawing an empty String seems a waste of time.
    You don't need the == true with a boolean variable. The variable itself has a value of true or false.
    if(showMsg)
  8. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    A boolean is simpler.

    NOTE: The code does not need to test if true and then test if false
    if(condition) {
    // here when true
    }else{
    // here when false
    }
  9. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    Use the if statement to skip doing the draw to "clear" the message.
    The way to tell a method what to do could be by setting a boolean:
    boolean showMsg = true; // used to tell paint when to draw a...
  10. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    Would NOT drawing the String be the same as clearing the string? Control the drawing of the String with a if statement.

    There should NOT be code to start a thread every time the paint() method is...
  11. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    Where are any of the techniques that were talked about? I don't see anything in this code that attempts to clear the message after some time.
  12. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    If you want more help: Make a small simple program that compiles, executes and shows the problem.
    Talking about techniques isn't working. We need code for testing.
  13. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    Make a small simple program that compiles, executes and shows the problem.
  14. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    Not at all. I was only talking about code in the paint() method.
  15. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    If you draw the same message two times, the first with a different color than the background and the second with the same color as the background, I'd think you'd see the results of the first drawing...
  16. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    If you don't call the drawString() method the String won't be drawn.
    If you do call drawString() the String will be drawn (It will be visible if the color is different from the background color)
  17. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    To clear the message, don't draw it when the paint() method is called.
  18. Replies
    35
    Views
    3,434

    Re: display text for 1 sec than remove txt java

    Use a Timer.
    Show message
    Start timer for desired time
    when timer calls its listener, clear message
Results 1 to 18 of 18