• Post Reply Bookmark Topic Watch Topic
  • New Topic

Graduated Backgrounds  RSS feed

 
Steve Gebert
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI - Well, I'm into my second week of programming with java and I'm starting to like it :-) I have figured out how to override the paintComponent of a panel by extending JPanel and displaying a gif on screen. But I'd like to have a graduated background on my main panel, or maybe even display a graphic that is a graduated image. So my question is - how do you change the background of a frame or panel to a graduated dark bluie on the left side and light purplish bluie on the right side? Thanks in advance.
 
Ben Buchli
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, as far as i know you can do that only by setting a background picture...
but i may be wrong, since I'm pretty new to java as well...

ben
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum, where they love to get messy with this GUI stuff...
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either way works okay. Here's a way using the GradientPaint class.
 
Steve Gebert
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for the code sample. It is exactly what I was looking for and it is very clear and consise. I appreciate the response.
 
Gary Down
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Craig,
I see from your reply you know quite a bit more about this than I do.
SO..
I ran your Shades program.
The frame displayed without the coloured effect.
On closing the frame the frame closed down but left the coloured area overlaying my screen. By minimising and them retsoring my screen it cleared it away.

I suspect I have an environmental problem.
Any suggestions as to what I should look at.

Thanks,
and keep the replies coming, for us new to java they are most helpful.

Gary Down.

a bit more info.....
just added
JFrame.setDefaultLookAndFeelDecorated(true);
immediately before the line of code
"JFrame f = new JFrame();"
It now works buts sometimes leaves the "close frame" "x" on screen.
[ May 15, 2004: Message edited by: Gary Down ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!