Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Fading in/out code?

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    21
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Fading in/out code?

    I have a code that isn't working.

    I have an integer called fade

    public int fade = 255;

    and I make fade smaller like so:

    if(fade >= 0) {
    try {

    fade = fade - 1;
    Thread.sleep(100)
    } catch(Exception e) { }
    }

    then I'm drawing a black box over the whole screen that uses fade as the alpha exception. The code will not work!

    Although if I make fade = 0 then do this

    if(fade >= 255) {
    try {

    fade++;
    Thread.sleep(100)
    } catch(Exception e) { }
    }

    and this makes the box fade in ...


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Fading in/out code?

    Please use the code tags, and please explain what you mean by 'it won't work'. Providing an SSCCE will more clearly demonstrate the problem

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    21
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Fading in/out code?

    It displays a blank screen.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Fading in/out code?

    Please read the last sentence in post #2 - if you don't know what an SSCCE is, there is a link in my signature. In other words, your post is limited of information to get help.

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    21
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Fading in/out code?

    Should I just copy paste a SSCCE or do you want a file uploaded?
    I'm new here...

Similar Threads

  1. Trouble Porting my Java File Reading Code to Android Code
    By Gravity Games in forum Android Development
    Replies: 0
    Last Post: December 6th, 2012, 04:38 PM
  2. Replies: 5
    Last Post: November 14th, 2012, 10:47 AM
  3. Help needed - Embedding javascript code in JSP code.
    By chinnu in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: October 29th, 2012, 01:09 PM
  4. Replies: 3
    Last Post: September 3rd, 2012, 11:36 AM
  5. Code is giving an error in console, but there are no errors apparent in the code!
    By JamEngulfer221 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 15th, 2011, 09:30 PM