Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

background for button

Posted on 1997-05-03
6
Medium Priority
?
265 Views
Last Modified: 2010-04-16
I have an applet that has buttons that change color depending on the situation.  This applet works fine
on a unix machine. However, on a pc this doesnt work.
So much for paltform independent.  Is there a way
to make this work on a pc?

Here are parts of the code:

 if (dates[0]  != null) {
              for(int k=0;k<dates.length;k++)
                {
                  month=dates[k][1];
                  if(!(month==null) && changeMonth(month)==thismonth && Integer.parseInt(dates[k][3])==tmp && Integer.parseInt(dates[k][4])==thisyear+1900)
                    {
                      myButton[i].setBackground(new Color(0, 128, 128));
                      break;            
                    }              
                }
            }
           
          }
          else myButton[i].setBackground(new Color(16512));    
        }
      }
0
Comment
Question by:arth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:jpk041897
ID: 1220085
Could you post the relevant parts of the code?
0
 

Author Comment

by:arth
ID: 1220086
Edited text of question
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1220087
Hum,

Have you tried:

myButton[i].setBackground(new Color(0, 128, 128));
myButton[i].repaint();
break;

To force an update of the component?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:rickl032797
ID: 1220088
Maybe this is an answer, but one you won't want! I think in the windows implementation, background has no effect (ie if you could change background it would be for all gui buttons). Not 100% on this though.If this is the case, your only alternative is to code up your own button class, or perhaps just use a bitmap type button from somewhere.
0
 

Expert Comment

by:rickl032797
ID: 1220089
Sorry you rejected my answer, but I have discovered it's true. Maybe in 1.1.? they will introduce some trick to accomplish it. I had someone else run into this (with a code sample from a book) and it does run on unix but not in win95 (didn't try any others).So unless you use an alternative button you make yourself, I think you're stuck for now....
0
 

Accepted Solution

by:
jpzwarte earned 300 total points
ID: 1220090
I don't know if it works with setBackground, but i've used it succesfully with setForeground in jdk1.1.1. ... i just tried using setBackground on a button in jdk1.1.1 and it WORKS!

here's some code:

public void mouseEntered(MouseEvent e)
    {
        Object obj = e.getSource();
        Color active = Color.red;

        if (obj == Quit) // Quit = Button
            Quit.setBackground(active); // this WORKS!
        else if (obj == Send)
            Send.setForeground(active);
        else if (obj == SendToAll)
            SendToAll.setForeground(active);
        else if (obj == ClearText)
            ClearText.setForeground(active);
    }
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question