import java.awt.*; import javax.swing.JFrame; import javax.swing.*; public class MainMenuView { ImageIcon SoundIcon = new ImageIcon("Grafik/sound button.png"); private JFrame frame = new JFrame(); private JLabel titelLabel = new JLabel("Studium versenken"); private JButton lokalButton = new JButton("Lokal"); private JButton multiButton= new JButton("Multiplayer"); private JButton soundButton = new JButton(SoundIcon); Font robotoFont = new Font("Roboto", Font.BOLD, 45); public MainMenuView() { buildFrame(); buildComponents(); } public void buildComponents(){ lokalButton.setBounds(200,200,500,500); multiButton.setBounds(800,200,500,500); titelLabel.setBounds(550,10,700,100); soundButton.setBounds(20,20,128,128); titelLabel.setFont(robotoFont); lokalButton.setFont(robotoFont.deriveFont(50f)); multiButton.setFont(robotoFont.deriveFont(50f)); } public void buildFrame() { frame.setLayout(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(1500,1000); frame.setVisible(true); frame.getContentPane().setBackground( Color.decode("#98F5FF")); JLabel backgroundLabel = new JLabel(new ImageIcon("Grafik/mainmenubackground.png")); frame.setContentPane(backgroundLabel); frame.add(titelLabel); frame.add(lokalButton); frame.add(multiButton); frame.add(soundButton); frame.setLocationRelativeTo(null); } public void toggleMute(){ ImageIcon MuteIcon = new ImageIcon("Grafik/sound button muted.png"); if(soundButton.getIcon()==SoundIcon) { soundButton.setIcon(MuteIcon); }else{ soundButton.setIcon(SoundIcon); } } public void closeWindOw(){ frame.dispose(); } public JFrame getFrame() { return frame; } public JButton getLocalButton() { return lokalButton; } public JButton getMultiButton() { return multiButton; } public JButton getSoundButton() { return soundButton; } }