Computer Science Canada

Hi I need some help with this background and buttons

Author:  DaBox [ Tue Jan 03, 2012 5:26 pm ]
Post subject:  Hi I need some help with this background and buttons

Basically I have this background and I want to put these transparent buttons in place so it could work as a proper menu screen

here is a picture of what happens: http://i.imgur.com/kiFOW.png

as you can see the transparent buttons are on the right side of the background, I want those buttons to be placed where the start and info buttons are located

I kept trying to see how I can fix this and I am literally stumped, when I setlayout to null the background picture goes away, but I can't use setbounds without using setlayout

basically I know the problem but I do not know how to fix it so I hope you guys can help

here is the code

code:
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Menu extends JFrame implements ActionListener
{
        Container pane = getContentPane();
        Container button = getContentPane();
        JPanel background = new JPanel();
        ImageIcon bg = new ImageIcon("LeagueTD Menu.png");
        JLabel bgpic = new JLabel(bg);
        JButton start = new JButton("");
        JButton info = new JButton("");

        public Menu()
        {
                super("Menu");
                setSize(800,600);
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               
                //Set buttons coordinates
                start.setBounds(32,367,182,72);
                info.setBounds(32,457,182,72);

                //set buttons transparent
                start.setBackground(new Color(0,0,0,0));
                info.setBackground(new Color(0,0,0,0));

                start.addActionListener(this);
                info.addActionListener(this);

                background.add(bgpic);
                background.add(start);
                background.add(info);
                pane.add("Center",background);
                setVisible(true);
        }

        public void actionPerformed(ActionEvent event)
        {
                if(event.getSource()==start)
                {
                        dispose();
                        Mode frame = new Mode();

                }
        }
}

Author:  DaBox [ Tue Jan 03, 2012 5:38 pm ]
Post subject:  Re: Hi I need some help with this background and buttons

nvm I fixed it T_T

I just used setbounds for the background as well and used setlayout(null)

anyways while I have your attention if your reading this

anyone know of a good tutorial to build a tower defense game in java Razz? I'm still a complete noob


: