Results 1 to 7 of 7
  1. #1
    qwertyq is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Exclamation how to color a button

    hy

    I am new to this programm.:)

    how do I give a button a red color?

    and could somebody give me some tips for this:

    I have to make 2 buttons that go from left to right at the same time by clicking on one of them.

    Tnx already.:)

  2. #2
    hei1233212000 is offline Member
    Join Date
    Jul 2010
    Posts
    36
    Rep Power
    0

    Default

    try button.setBackground( Color.RED )

  3. #3
    Nadian is offline Member
    Join Date
    Jan 2011
    Posts
    9
    Rep Power
    0

    Default

    also dont forget to- import static java.awt.Color; --in your header first of the code above wont work

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,040
    Rep Power
    10

    Default

    Quote Originally Posted by Nadian View Post
    also dont forget to- import static java.awt.Color; --in your header first of the code above wont work
    This advice is superfluous at best, and downright incorrect at worst.

    You can't static import java.awt.Color. You could static import java.awt.Color.RED, for example, but that's not the same thing, and probably isn't what the OP should do anyway.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Nadian is offline Member
    Join Date
    Jan 2011
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by KevinWorkman View Post
    This advice is superfluous at best, and downright incorrect at worst.

    You can't static import java.awt.Color. You could static import java.awt.Color.RED, for example, but that's not the same thing, and probably isn't what the OP should do anyway.
    apologies - I am a newbie trying to help, i had a similar problem myself and i couldn't get setBackground(Color.Red) to work because i hadn't anything in the import section that goes at the top, so added "import java.awt.Color;" and it worked, but I may have done the wrong thing and got lucky, I do apologise. I mistakenly put static in the post as i got it mixed up with another import i regularly use import static java.lang.Sytem.out; I should be more careful.....

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by qwertyq View Post
    ...
    I have to make 2 buttons that go from left to right at the same time by clicking on one of them.
    ...
    Can you clarify this portion of your question?

  7. #7
    qwertyq is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default

    this for the answers guys,

    @Fubarable

    well first you pick 2 buttons. Then I have to make them move to the right side for a bit.
    they should do this by clicking on them.

Similar Threads

  1. Can't change the color of a button...
    By mrbeast87 in forum AWT / Swing
    Replies: 5
    Last Post: 11-16-2010, 10:22 PM
  2. Replies: 3
    Last Post: 06-27-2010, 03:57 AM
  3. [COLOR="Navy"]execute .bat file in mysql [/COLOR]
    By msankar.ravi in forum Networking
    Replies: 0
    Last Post: 02-24-2010, 05:27 AM
  4. Radio button dot color
    By Psyclone in forum AWT / Swing
    Replies: 3
    Last Post: 02-21-2010, 05:29 AM
  5. Color a button in Gnome
    By waka in forum New To Java
    Replies: 0
    Last Post: 02-13-2008, 01:52 AM

Tags for this Thread

Posting Permissions

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