import java.awt.event.*;

import javax.swing.*;

import java.awt.*;



/* This will create a window that will have a background image of your choice. It is 
   currently set with three buttons that are images. The buttons will launch a couple
   of different programs as well as shutdown a WindowsXP machine. The images and programs
   are clearly marked so they can be easily changed to fit your needs. */

public class GameApp extends JFrame
{


     ImageIcon background;

     int imageHeight = 0;

     int imageWidth = 0;



     public GameApp()

     {

          background = new ImageIcon(getClass().getResource("/blueskulls.jpg")); //background image
          imageHeight= background.getIconHeight();

          imageWidth = background.getIconWidth();



          JPanel panel = new JPanel()

          {

               public void paintComponent(Graphics g) //Component

               {

                    // Approach 1: Dispaly image at at full size

                    // g.drawImage(background.getImage(), 0, 0, null);



                    // Approach 2: Display the image as a tiled background

                    for(int y=0; y < getHeight(); y+=imageHeight)

                         for(int x=0; x < getWidth(); x+=imageWidth)

                              g.drawImage(background.getImage(), x, y, this);



                    // Approach 3: Scale image to size of component

                    // Dimension d = getSize();

                    // g.drawImage(background.getImage(), 0, 0, d.width, d.height, null);



                    // Approach 4: Fix the image position in the scroll pane

                    // Point p = scrollPane.getViewport().getViewPosition();

                    // g.drawImage(background.getImage(), p.x, p.y, null);



                    setOpaque( false );

                    super.paintComponent(g);

               }

          };



          // images for buttons. change to suit your needs.
          JButton button = new JButton(new ImageIcon(getClass().getResource("/mame.png")));

          JButton button2= new JButton(new ImageIcon(getClass().getResource("/aj7.jpg")));

          JButton button3= new JButton(new ImageIcon(getClass().getResource("/shutdown.jpg")));



          button.setContentAreaFilled(false);

          button2.setContentAreaFilled(false);

          button3.setContentAreaFilled(false);



          button.setBorder(null);

          button2.setBorder(null);

          button3.setBorder(null);



          button.addActionListener(new ActionListener() {

               public void actionPerformed(ActionEvent e) {

                    try {

                          Runtime.getRuntime().exec("c:\\mame32\\Mame32.exe");
 //change to path and program you need
                    }

                    catch(java.io.IOException f) {

                          System.out.println(e);

                    }

               }

          });


          button2.addActionListener(new ActionListener() {

               public void actionPerformed(ActionEvent e) {

                    try {

                          Runtime.getRuntime().exec("c:\\ArcJuke7\\AJ7.exe"); //change to path and program you need
                    }

                    catch(java.io.IOException f) {

                          System.out.println(e);

                    }

               }

          });


          button3.addActionListener(new ActionListener() {

               public void actionPerformed(ActionEvent e) {

                    try {

                          Runtime.getRuntime().exec("shutdown -s -t 00"); //this is a WindowsXP command

                    }

                    catch(java.io.IOException f) {

                          System.out.println(e);

                    }
               }

          });



          panel.setBorder(BorderFactory.createEmptyBorder(

                                        30, //top

                                        50, //left

                                        50, //bottom

                                        50) //right

                                        );


          panel.setLayout(new GridLayout(2,2)); //change this when you add or subtract buttons


          panel.add( button );

          panel.add( button2 );

          panel.add( button3 );



          setContentPane( panel );

          }



     public static void main(String [] args)

     {

          GameApp frame = new GameApp();


          frame.setTitle("Game Application");

          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

          frame.setSize(650, 520); //this will need to be adjusted to what you want

          frame.setVisible(true);

     }

}