Kronjuwild #6
Binary file not shown.
After Width: | Height: | Size: 2.2 MiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 959 B |
|
@ -11,6 +11,7 @@ public class MainMenuController implements ActionListener {
|
|||
this.model = model;
|
||||
this.view.getLocalButton().addActionListener(this);
|
||||
this.view.getMultiButton().addActionListener(this);
|
||||
this.view.getSoundButton().addActionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,6 +22,8 @@ public class MainMenuController implements ActionListener {
|
|||
} else if (e.getSource() == view.getMultiButton()) {
|
||||
model.setGameMode("Multiplayer");
|
||||
JOptionPane.showMessageDialog(view.getFrame(), "Multiplayer game selected.");
|
||||
}else if (e.getSource() == view.getSoundButton()) {
|
||||
view.toggleMute();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,24 +3,25 @@ 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();
|
||||
private ImageIcon background = new ImageIcon("images/background.jpg");
|
||||
|
||||
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));
|
||||
|
@ -32,12 +33,29 @@ public class MainMenuView {
|
|||
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 JFrame getFrame() {
|
||||
return frame;
|
||||
}
|
||||
|
||||
public JButton getLocalButton() {
|
||||
return lokalButton;
|
||||
}
|
||||
|
@ -46,7 +64,8 @@ public class MainMenuView {
|
|||
return multiButton;
|
||||
}
|
||||
|
||||
public JFrame getFrame() {
|
||||
return frame;
|
||||
public JButton getSoundButton() {
|
||||
return soundButton;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue