From af3fc37687f0331d7d32a59ac3546beade983620 Mon Sep 17 00:00:00 2001 From: Gavin Li Date: Sat, 18 Apr 2015 13:46:22 -0400 Subject: [PATCH] Changed some code structure to make it easier to read --- MerchantRPGCSE2102/src/view/StartScreen.java | 44 ++++++-------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/MerchantRPGCSE2102/src/view/StartScreen.java b/MerchantRPGCSE2102/src/view/StartScreen.java index 47e6bc9..1e0bf3c 100644 --- a/MerchantRPGCSE2102/src/view/StartScreen.java +++ b/MerchantRPGCSE2102/src/view/StartScreen.java @@ -17,82 +17,62 @@ import javax.swing.*; public class StartScreen extends JFrame { - + private static final long serialVersionUID = 1L; - + JPanel startMenu = new JPanel(); - - + + public static void main(String[] args) throws IOException { new StartScreen(); } - + public StartScreen() throws IOException { - - - - - + JLabel MainMenuBG = new JLabel(new ImageIcon("src/images/background.jpg")); MainMenuBG.setVisible(true); - - - - - - - Image icon, background; icon = loadIcon(); background = loadBackground(); BackgroundPanel panel = new BackgroundPanel(background, BackgroundPanel.ACTUAL, 1.0f, 0.5f); this.setIconImage(icon); - this.setTitle("The Merchant RPG"); this.setSize(1500, 844); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setResizable(false); this.setVisible(true); - - + JButton start = new JButton("Start"); start.setVisible(true); - start.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ System.out.println("Game started"); } - }); - + }); + JButton instructions = new JButton("Instructions"); instructions.setVisible(true); - - instructions.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ System.out.println("Instructions opened"); } + }); - }); - this.getContentPane().setLayout(null); start.setBounds(650, 382, 200, 80); instructions.setBounds(650, 482, 200, 40); panel.setBounds(0, 0, 1500, 844); start.setBackground(null); instructions.setBackground(null); - - this.getContentPane().add(instructions); this.getContentPane().add(start); - this.add(panel); } - + public BufferedImage loadIcon() throws IOException { BufferedImage img = null; try { @@ -103,7 +83,7 @@ public BufferedImage loadIcon() throws IOException { return null; } } - + public BufferedImage loadBackground() throws IOException { BufferedImage img = null; try {