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 2 of 2

Thread: JButton set background problem

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy JButton set background problem

    Hi All,
    When i apply the setBackground() Method to a JButton to set its Background, i face i Problem :
    Under Mac Os : The JButton DOSE NOT change its color,
    when i take my code to my other computer under Windows : OK, the JButton change...
    i am wondering ....
    1) Why under my Mac OS i face this problem...
    2) and Why i get two different results from a same code ??? Java is not Portable?? and independant of the OS?? or it is the swing that makes the problem???
    My code is so simple :
    MyJButton.setBackground(new Color(255,100,100));
    Thanks to any help...
    Last edited by helloworld922; February 25th, 2010 at 12:12 AM.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: JButton set background problem

    Check to see if your button is being set opaque or not. That will effect if the background color is set or not. And Mac's are funny, they have their own special JDK you download from apple. It should be cross-compatible with the official one released by sun (well, Oracle now), but I'm not completely sure about this.

Similar Threads

  1. JButton Help
    By ravjot28 in forum AWT / Java Swing
    Replies: 3
    Last Post: January 17th, 2010, 11:38 AM
  2. JButton...
    By chronoz13 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 27th, 2009, 11:39 AM
  3. JAVA Image Icon and JButton resizing problem
    By antitru5t in forum AWT / Java Swing
    Replies: 1
    Last Post: March 13th, 2009, 04:39 AM