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.model = model;
|
||||||
this.view.getLocalButton().addActionListener(this);
|
this.view.getLocalButton().addActionListener(this);
|
||||||
this.view.getMultiButton().addActionListener(this);
|
this.view.getMultiButton().addActionListener(this);
|
||||||
|
this.view.getSoundButton().addActionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +22,8 @@ public class MainMenuController implements ActionListener {
|
||||||
} else if (e.getSource() == view.getMultiButton()) {
|
} else if (e.getSource() == view.getMultiButton()) {
|
||||||
model.setGameMode("Multiplayer");
|
model.setGameMode("Multiplayer");
|
||||||
JOptionPane.showMessageDialog(view.getFrame(), "Multiplayer game selected.");
|
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.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class MainMenuView {
|
public class MainMenuView {
|
||||||
|
ImageIcon SoundIcon = new ImageIcon("Grafik/sound button.png");
|
||||||
private JFrame frame = new JFrame();
|
private JFrame frame = new JFrame();
|
||||||
private JLabel titelLabel = new JLabel("Studium versenken");
|
private JLabel titelLabel = new JLabel("Studium versenken");
|
||||||
private JButton lokalButton = new JButton("Lokal");
|
private JButton lokalButton = new JButton("Lokal");
|
||||||
private JButton multiButton= new JButton("Multiplayer");
|
private JButton multiButton= new JButton("Multiplayer");
|
||||||
private JButton soundButton = new JButton();
|
private JButton soundButton = new JButton(SoundIcon);
|
||||||
private ImageIcon background = new ImageIcon("images/background.jpg");
|
|
||||||
|
|
||||||
Font robotoFont = new Font("Roboto", Font.BOLD, 45);
|
Font robotoFont = new Font("Roboto", Font.BOLD, 45);
|
||||||
|
|
||||||
public MainMenuView() {
|
public MainMenuView() {
|
||||||
buildFrame();
|
buildFrame();
|
||||||
buildComponents();
|
buildComponents();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void buildComponents(){
|
public void buildComponents(){
|
||||||
lokalButton.setBounds(200,200,500,500);
|
lokalButton.setBounds(200,200,500,500);
|
||||||
multiButton.setBounds(800,200,500,500);
|
multiButton.setBounds(800,200,500,500);
|
||||||
titelLabel.setBounds(550,10,700,100);
|
titelLabel.setBounds(550,10,700,100);
|
||||||
|
soundButton.setBounds(20,20,128,128);
|
||||||
titelLabel.setFont(robotoFont);
|
titelLabel.setFont(robotoFont);
|
||||||
lokalButton.setFont(robotoFont.deriveFont(50f));
|
lokalButton.setFont(robotoFont.deriveFont(50f));
|
||||||
multiButton.setFont(robotoFont.deriveFont(50f));
|
multiButton.setFont(robotoFont.deriveFont(50f));
|
||||||
|
@ -32,12 +33,29 @@ public class MainMenuView {
|
||||||
frame.setSize(1500,1000);
|
frame.setSize(1500,1000);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
frame.getContentPane().setBackground( Color.decode("#98F5FF"));
|
frame.getContentPane().setBackground( Color.decode("#98F5FF"));
|
||||||
|
JLabel backgroundLabel = new JLabel(new ImageIcon("Grafik/mainmenubackground.png"));
|
||||||
|
frame.setContentPane(backgroundLabel);
|
||||||
frame.add(titelLabel);
|
frame.add(titelLabel);
|
||||||
frame.add(lokalButton);
|
frame.add(lokalButton);
|
||||||
frame.add(multiButton);
|
frame.add(multiButton);
|
||||||
|
frame.add(soundButton);
|
||||||
frame.setLocationRelativeTo(null);
|
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() {
|
public JButton getLocalButton() {
|
||||||
return lokalButton;
|
return lokalButton;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +64,8 @@ public class MainMenuView {
|
||||||
return multiButton;
|
return multiButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JFrame getFrame() {
|
public JButton getSoundButton() {
|
||||||
return frame;
|
return soundButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue