• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Graduated Backgrounds

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum, where they love to get messy with this GUI stuff...
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic