Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package game1;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JButton;
- import javax.swing.ImageIcon;
- import java.awt.Image;
- import javax.swing.SwingConstants;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- public class Frame1
- {
- public JFrame frame;
- public JButton mainBttn;
- /**
- * Launch the application.
- */
- public static void main(String[] args)
- {
- EventQueue.invokeLater(new Runnable()
- {
- public void run()
- {
- try
- {
- Frame1 window = new Frame1();
- window.frame.setVisible(true);
- } catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public Frame1() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- public void initialize() {
- frame = new JFrame();
- frame.setBounds(100, 100, 1200, 800);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- Image chocChip =new ImageIcon(this.getClass().getResource("/cookie.png")).getImage();
- frame.getContentPane().setLayout(null);
- mainBttn = new JButton("");
- mainBttn.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent arg0)
- {
- }
- });
- mainBttn.addMouseListener(new MouseAdapter()
- {
- @Override
- public void mouseClicked(MouseEvent arg0)
- {
- }
- });
- mainBttn.setBounds(239, 97, 393, 309);
- frame.getContentPane().add(mainBttn);
- mainBttn.setHorizontalAlignment(SwingConstants.LEFT);
- mainBttn.setVerticalAlignment(SwingConstants.BOTTOM);
- mainBttn.setIcon(new ImageIcon(chocChip));
- JButton storeBttn = new JButton("Store");
- storeBttn.addMouseListener(new MouseAdapter()
- {
- @Override
- public void mouseClicked(MouseEvent arg0)
- {
- Store newWindow = new Store();
- newWindow.setVisible(true);
- }
- });
- storeBttn.setBounds(77, 226, 89, 23);
- frame.getContentPane().add(storeBttn);
- }
- }
- package game1;
- import java.awt.BorderLayout;
- import java.awt.FlowLayout;
- import javax.swing.JButton;
- import javax.swing.JDialog;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.BoxLayout;
- import javax.swing.ImageIcon;
- import java.awt.GridBagLayout;
- import java.awt.Image;
- import java.awt.GridBagConstraints;
- import java.awt.Insets;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import java.awt.Component;
- import javax.swing.Box;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- public class Store extends JDialog {
- private final JPanel contentPanel = new JPanel();
- /**
- * Launch the application.
- */
- public static void main(String[] args)
- {
- try
- {
- Store dialog = new Store();
- dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- dialog.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * Create the dialog.
- */
- public Store()
- {
- setBounds(100, 100, 821, 639);
- getContentPane().setLayout(new BorderLayout());
- contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
- getContentPane().add(contentPanel, BorderLayout.CENTER);
- contentPanel.setLayout(null);
- {
- JButton oatmealBttn = new JButton("");
- oatmealBttn.addMouseListener(new MouseAdapter()
- {
- @Override
- public void mouseClicked(MouseEvent arg0)
- {
- }
- });
- oatmealBttn.setBounds(10, 11, 100, 100);
- contentPanel.add(oatmealBttn);
- Image oat =new ImageIcon(this.getClass().getResource("/oatmeal raisin.jpg")).getImage();
- oatmealBttn.setIcon(new ImageIcon(oat));
- }
- {
- JButton chocoBttn = new JButton("");
- chocoBttn.setBounds(10, 122, 100, 100);
- contentPanel.add(chocoBttn);
- Image chocoChunk = new ImageIcon(this.getClass().getResource("/chocolate chunk.jpg")).getImage();
- chocoBttn.setIcon(new ImageIcon(chocoChunk));
- }
- {
- JButton mmBttn = new JButton("");
- mmBttn.setBounds(10, 233, 100, 100);
- contentPanel.add(mmBttn);
- Image mmCookie = new ImageIcon(this.getClass().getResource("/m&m.jpg")).getImage();
- mmBttn.setIcon(new ImageIcon(mmCookie));
- }
- {
- JButton macaroonBttn = new JButton("");
- macaroonBttn.setBounds(10, 344, 100, 100);
- contentPanel.add(macaroonBttn);
- Image macaroonC = new ImageIcon(this.getClass().getResource("/macaroon.png")).getImage();
- macaroonBttn.setIcon(new ImageIcon(macaroonC));
- }
- {
- JButton oreoBttn = new JButton("");
- oreoBttn.setBounds(10, 455, 100, 100);
- contentPanel.add(oreoBttn);
- Image oreoC = new ImageIcon(this.getClass().getResource("/oreo.jpg")).getImage();
- oreoBttn.setIcon(new ImageIcon(oreoC));
- }
- {
- JPanel buttonPane = new JPanel();
- buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
- getContentPane().add(buttonPane, BorderLayout.SOUTH);
- {
- JButton okButton = new JButton("OK");
- okButton.addMouseListener(new MouseAdapter()
- {
- @Override
- public void mouseClicked(MouseEvent e)
- {
- }
- });
- okButton.setActionCommand("OK");
- buttonPane.add(okButton);
- getRootPane().setDefaultButton(okButton);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement