Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

transparent panel in applet  RSS feed

 
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have an applet with a JScrollPane (backgroundPanel) that has a background image painted on it. To this backgroundPanel I add a panel with a button and a transparent image painted over that button (helpPanel). Now, I set helpPanel.setOpaque(false) in order for the helpPanel to be painted with the background of backgroundPanel, but all I get is gray background of the container I guess. I do add backgroundPanel to the container.
Here are bits of code:
backgroundImage = getImage(getDocumentBase(),"../generic_images/" + gne.returnB
utton(313)); // get background image
backgroundPanel = new screenPanel(backgroundImage);
container = getContentPane();
JScrollPane jspanel = new JScrollPane(backgroundPanel);
container.add(jspanel);
backgroundPanel.setLayout(new GridBagLayout());
backgroundPanel.setBackground(Color.white);
((JPanel)container).setBorder(BorderFactory.createCompoundBorder(raisedbevel, l
oweredbevel));

JPanel helpPanel = new JPanel(new GridLayout(1,1));
helpPanel.add(help);
//helpPanel.setBackground(new Color(255,255,255));
helpPanel.setPreferredSize(new Dimension(35,35));
helpPanel.setOpaque(false);
parentButtonsBox.add(logoPanel);
parentButtonsBox.add(Box.createHorizontalStrut(2));
parentButtonsRightBox.add(kwiLogoPanel);
parentButtonsRightBox.add(Box.createHorizontalStrut(2));
parentButtonsRightBox.add(helpPanel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 9;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
backgroundPanel.add(parentButtonsRightBox, gridBagConstraints);
Does anybody know what am I doing wrong here?
thanks,
Alex
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!