Results 1 to 3 of 3
  1. #1
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default running through jlabel fade only once

    how would i make this text fade out only once?

    Java Code:
    public void fadeJlabelText() {
    		new Timer(50, new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				alpha += increment;
    				if (alpha >= 200) {
    					alpha = 200;
    					increment = -increment;
    				}
    				if (alpha <= 0) {
    					alpha = 0;
    					increment = -increment;
    				}
    				label.setForeground(new Color(0, 0, 0, alpha));
    			}
    		}).start();
    	}
    Last edited by droidus; 01-29-2012 at 03:14 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,607
    Rep Power
    23

    Default Re: running through jlabel fade only once

    only once
    Use a boolean variable to control its execution. If the variable is not set, do the code and set the variable.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: running through jlabel fade only once

    Quote Originally Posted by droidus View Post
    how would i make this text fade out only once?
    Maybe by not writing code that contains logic to fade it in and out continuously?

    Additionally, by stop()ping the timer when the text has faded out only once?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 7
    Last Post: 12-18-2011, 04:13 AM
  2. Fade in/Fade out Class for any object
    By eLancaster in forum New To Java
    Replies: 3
    Last Post: 04-13-2011, 03:19 PM
  3. Adding a JLabel to a JPanel - jlabel not showing
    By Bongeh in forum New To Java
    Replies: 17
    Last Post: 04-06-2010, 11:02 PM
  4. Replies: 0
    Last Post: 08-26-2009, 01:03 PM
  5. Alpha Fade Flicker
    By jamesfrize in forum Java Applets
    Replies: 3
    Last Post: 04-02-2008, 02:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •