0

so I was wondering if there is anyway to add a picture as a background for the jmenu and by that I don't mean the JMenu bar but the actual screen below it. I have looked online for a long time and can't seem to find any solution to my problem. Any help/solution would be greatly appreciated. Once again, I am trying to find a way to print a picture not on the JMenu bar, but the space that is below it.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
user2229592
  • 71
  • 1
  • 1
  • 9
  • agreed with post by @Mr. Polywhirl +1 but issue will be little bit complicated, for real and nice output and with readable text in JMenuItem could be required to play with UIManager – mKorbel Apr 02 '13 at 20:27

2 Answers2

2

Once again, I am trying to find a way to print a picture not on the JMenu bar, but the space that is below it.

I think you mean the content pane. See Using Top Level Containers to learn some of the terminology.

If this is what you mean then check out Background Panel.

camickr
  • 321,443
  • 19
  • 166
  • 288
1

I am assuming you mean the JMenuItem? There is a post on DreamInCode.net which discusses adding an image to a JMenuItem. All you have to do is extend the JMenuItem and override its paintComponent() method.

Solution by Dogstopper:

public CustomMenuItem(){
        this.setOpaque(true);
        i = new ImageIcon(getClass().getResource("/Img/BackGround.png")).getImage();
        System.out.println(i);
}

@Override
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.drawImage(i, 0, 0, this);

}
Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132