• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I remove colour background of JFrame  RSS feed

 
Raymond Self
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added a background image to this JFrame (see image attached) as I want the buttons and field to just be on top of the image, does anybody know how to remove the colored part of the JFrame that is left? If you need to see any code just ask thanks
Capture.PNG
[Thumbnail for Capture.PNG]
JFrame
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What sort of layout are you using?
 
Raymond Self
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The frame is using a FlowLayout but the calculator that is added to the frame is using a GridBagLayout
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the calculator, a JPanel?
 
Raymond Self
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calculator extends JPanel yes
 
Mark King
Ranch Hand
Posts: 55
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried using the setOpaque method?
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raymond Self wrote:The frame is using a FlowLayout . . .
Why? I for one don't like flow layout. Since a frame defaults to border layout why don't you use that?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raymond Self wrote:Calculator extends JPanel yes


And the Calculator is in the FlowLayout? Or is it in the GridBagLayout? If so, is that in the FlowLayout somehow or is it somewhere else?

You know, it might be helpful if you just showed us the code which generates that GUI. Could speed things up here.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark King wrote:Have you tried using the setOpaque method?

This is indeed the correct approach.
Your background panel has other panels added on top of it. Invoke setOpaque(false); on all of them to make them transparent so that the image shows through.
 
Raymond Self
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark King wrote:Have you tried using the setOpaque method?


This worked perfectly thanks Mark and thanks everyone else for trying to help
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!