title: background image help, JPanel, JFrame, anything?
body: <p>I want to make a background image for a game I'm designing but I cant figure out the right way to get the effect I want, I want a background that can be seen behind text etc. basically having the background cover the whole JFrame / JPanel not just one section of the layout (e.g. BorderLayout.Center) I think it does this anyway but if it does do that how do I make the background for those transparent to see the background which is behind... </p>
  
  <p>Confusing i know but I hope someone here understands what I am trying to do and can help... this is my current code. I have been playing around with the background so dont read to much in how i have written it.</p>
  
  <pre><code>import javax.swing.*;
  import javax.swing.border.*;
  
  import java.awt.*;
  
  public class GamePanel extends JPanel {
  
  private JTextPane playertext;
  private JTextField wealthstring, currentwealth;
  
  public GamePanel() {
  
      super();
      setLayout(new BorderLayout());
      setBackground(Game.getBackgroundColor());
      Border raised = BorderFactory.createRaisedBevelBorder();
      Border lowered = BorderFactory.createLoweredBevelBorder();
      setBorder(BorderFactory.createCompoundBorder(new EmptyBorder(4, 4, 4, 4), (BorderFactory.createCompoundBorder(raised, lowered))));
      add(northpanel(), BorderLayout.NORTH);
      add(eastpanel(), BorderLayout.EAST);
  
  
  }
  
  
  private JLabel northpanel() {
  
      Font northfont = new Font("Engravers MT", Font.BOLD, 12);
      ImageIcon banner = new ImageIcon("images/banner.png", "North Background");
  
      playertext = new JTextPane();
      playertext.setFont(northfont);
      playertext.setEditable(false);
      playertext.setText("Player: \n" + Game.getName());
      playertext.setBackground(Game.getBackgroundColor());
      playertext.setBorder(new EmptyBorder(10,10,10,10));
  
      wealthstring = new JTextField("Money: ");
      wealthstring.setFont(northfont);
      wealthstring.setEditable(false);
      wealthstring.setHorizontalAlignment(wealthstring.RIGHT);
      wealthstring.setBorder(null);
      wealthstring.setBackground(Game.getBackgroundColor());
  
      currentwealth = new JTextField();
      currentwealth.setFont(northfont);
      currentwealth.setEditable(false);
      currentwealth.setHorizontalAlignment(wealthstring.RIGHT);
      currentwealth.setBackground(Game.getBackgroundColor());
      currentwealth.setBorder(null);
      String wealthrounded = String.format("%.2f", Game.getMoney());
      currentwealth.setText(wealthrounded);
  
      JPanel wealthtext = new JPanel();
      wealthtext.setLayout(new GridLayout(2, 1));
      wealthtext.setBackground(Game.getBackgroundColor());
      wealthtext.setBorder(new EmptyBorder(10,10,10,10));
      wealthtext.add(wealthstring);
      wealthtext.add(currentwealth);
  
      JLabel northpanel = new JLabel();
      northpanel.setLayout(new BorderLayout());
      northpanel.setIcon(banner);
      northpanel.add(new JSeparator(), BorderLayout.PAGE_END);
      northpanel.add(playertext, BorderLayout.WEST);
      northpanel.add(wealthtext, BorderLayout.EAST);
      return northpanel;
  }
  
  private JPanel eastpanel() {
  
  
      JButton tab1 = new JButton("Tab 1");
      JButton tab2 = new JButton("Tab 2");
      JButton tab3 = new JButton("Tab 3");
  
      JPanel easttabs = new JPanel();
      easttabs.setLayout(new GridLayout(1, 3));
      easttabs.add(tab1);
      easttabs.add(tab2);
      easttabs.add(tab3);
  
      JPanel eastpanels = new JPanel();
      eastpanels.setLayout(new BorderLayout());
      eastpanels.setBackground(Game.getBackgroundColor());
      eastpanels.add(easttabs, BorderLayout.NORTH);
  
      return eastpanels;
  }
  
  }
  </code></pre>