Kronjuwild #6
|
@ -1,7 +1,9 @@
|
||||||
public class HalloSchiffeVersenken {
|
public class HalloSchiffeVersenken {
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
MainMenu mainMenu = new MainMenu();
|
MainMenuModel model = new MainMenuModel();
|
||||||
|
MainMenuView view = new MainMenuView();
|
||||||
|
MainMenuController controller = new MainMenuController(model, view);
|
||||||
|
|
||||||
System.out.println("HelloSchiffeVersenekn");
|
System.out.println("HelloSchiffeVersenekn");
|
||||||
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.*;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
public class MainMenu implements ActionListener {
|
|
||||||
JFrame frame = new JFrame();
|
|
||||||
JLabel titelLabel = new JLabel("Studium versenken");
|
|
||||||
JButton lokalButton = new JButton("Lokal");
|
|
||||||
JButton multiButton= new JButton("Multiplayer");
|
|
||||||
JButton soundButton = new JButton();
|
|
||||||
Font comicSansFont = new Font("Comic Sans MS", Font.BOLD, 45);
|
|
||||||
|
|
||||||
MainMenu(){
|
|
||||||
frame.setLayout(null);
|
|
||||||
lokalButton.setBounds(100,200,500,500);
|
|
||||||
multiButton.setBounds(800,200,500,500);
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.setSize(1500,1000);
|
|
||||||
frame.setVisible(true);
|
|
||||||
frame.getContentPane().setBackground( Color.decode("#98F5FF"));
|
|
||||||
|
|
||||||
frame.add(titelLabel);
|
|
||||||
frame.add(lokalButton);
|
|
||||||
frame.add(multiButton);
|
|
||||||
frame.setLocationRelativeTo(null);
|
|
||||||
titelLabel.setBounds(500,10,700,100);
|
|
||||||
titelLabel.setFont(comicSansFont);
|
|
||||||
lokalButton.setFont(comicSansFont.deriveFont(50f));
|
|
||||||
multiButton.setFont(comicSansFont.deriveFont(50f));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if(e.getSource() == lokalButton){
|
|
||||||
MainMenu nextMenu= new MainMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class MainMenuController implements ActionListener {
|
||||||
|
private MainMenuView view;
|
||||||
|
private MainMenuModel model;
|
||||||
|
|
||||||
|
public MainMenuController(MainMenuModel model, MainMenuView view) {
|
||||||
|
this.view = view;
|
||||||
|
this.model = model;
|
||||||
|
this.view.getLocalButton().addActionListener(this);
|
||||||
|
this.view.getMultiButton().addActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (e.getSource() == view.getLocalButton()) {
|
||||||
|
model.setGameMode("Local");
|
||||||
|
JOptionPane.showMessageDialog(view.getFrame(), "Local game selected.");
|
||||||
|
} else if (e.getSource() == view.getMultiButton()) {
|
||||||
|
model.setGameMode("Multiplayer");
|
||||||
|
JOptionPane.showMessageDialog(view.getFrame(), "Multiplayer game selected.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
public class MainMenuModel {
|
||||||
|
private String gameMode;
|
||||||
|
|
||||||
|
public void setGameMode(String mode) {
|
||||||
|
this.gameMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGameMode() {
|
||||||
|
return gameMode;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class MainMenuView {
|
||||||
|
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");
|
||||||
|
|
||||||
|
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);
|
||||||
|
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"));
|
||||||
|
frame.add(titelLabel);
|
||||||
|
frame.add(lokalButton);
|
||||||
|
frame.add(multiButton);
|
||||||
|
frame.setLocationRelativeTo(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JButton getLocalButton() {
|
||||||
|
return lokalButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JButton getMultiButton() {
|
||||||
|
return multiButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JFrame getFrame() {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue