• Post Reply Bookmark Topic Watch Topic
  • New Topic

Mouse Over?

 
Drake Silver
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi again.
I am having a difficult time trying to define my own color for background of a button.
void jBtnReports_mouseEntered(MouseEvent e)
{
jBtnReports.setBackground(Color.white);
}
I have done the above, one to change the color on mouse eneter, and once to change it on mouse out.
But for mouse out I would like to set the color by either HEX, or RGB.
I've tired the help files, but they were of little help to me...I just couldn't do anything other than cuase errors.
So, can anyone tell me how to set the Color to something like Color.Hex, or Color.RGB?
thank you, I would really appreciate it.
This isn't as important as other posts here, so don't feel rushed or anything.
thank you
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to swing...
 
Bill Liteplo
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the constructor for Color that takes three ints corresponding to R, G and B.
e.g. setBackground(new Color(250, 100, 43));
Bill
 
Drake Silver
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, sorry about not posting my question in the right forum.
I didn't know.
I'll remember for next time...
Although I'm not quite sure on why it's under swing...
Does Swing have to do with appearance.
not the actual programming, but the panels, buttons, textfields etc...?

anyway, apart from that.
Thankyou for the help.
I can't believe how quick that was.
I think I tried for about 20 min's without success.
Thank you.
Also, say I wanted to change the color on more than one button.
Coul I create a method(btnColor) and change the event colors that way?
ex:
public int btnColorEnter()
{
int r = 255;
int g = 144;
int b = 0;
return(r,g,b);
}
and on the event enetered I would do this:
void jBtnReports_mouseEntered(MouseEvent e)
{
jBtnReports.setBackground(Color.btnColorEnter(r,g,b));
}
Would that work?
[ November 07, 2002: Message edited by: Drake Silver ]
[ November 07, 2002: Message edited by: Drake Silver ]
 
Drake Silver
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually it won't work.
I tried, and the return value keeps giving me errors.
hmmm...
Java...dififcult..can't think..losing sanity...argg...raspberry
 
Drake Silver
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm...
maybe something like
public int btnColorEnter()
{
self..setBackground(new color(255,144,0));
}
hmm...I'll try that.
 
Bill Liteplo
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Slow down, partner.
A few things:

public int btnColorEnter() {
int r = 255;
int g = 144;
int b = 0;
return(r,g,b);
}

you can't return more than one object from a method.
Here are some suggestions:

You can split the setButtonColor into two methods if you want.
Try these out.
Bill
 
Drake Silver
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
Yeah...
I guess i'm not that great with java.
Thank you very much.
Seems I was a little off.
thanks again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!