"Cały kod"... czyli na stan aktualny 255 linijek? Powaga? Proszę was bardzo.
BTW, wstawiłem tylko ten kod, który jest odpowiedzialny za błąd.
Main.java
package mario;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
import mario.gui.MainMenuGUI;
import mario.gui.OptionMainMenuGUI;
import mario.options.ArgumentsInterpreter;
public class Main extends JFrame {
public static void main(String[] args) {
Main main = new Main();
main.runFrame(args);
}
private void runFrame(String[] args) {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Dimension dim = new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height);
int var1 = 0;
for(int i = 0; i < dimensions.length; i++) {
if (dimensions[i].equals(dim)) {
this.setSize(dim);
this.setUndecorated(true);
}
else {
var1++;
}
}
if (var1 == dimensions.length) {
this.setSize(dimensions[0]);
this.setUndecorated(false);
}
this.setResizable(false);
this.setTitle("Mario Social");
this.setVisible(true);
argint.Interpret(args, this);
}
public void Action(int p) {
if (actualPanel != null) {
this.remove(actualPanel);
}
switch (p) {
case 1:
this.add(MainMenu);
actualPanel = MainMenu;
case 2:
this.add(OptionMainMenu);
actualPanel = MainMenu;
default:
System.exit(1);
}
this.repaint();
}
public static final int MAIN_MENU = 1;
public static final int OPTION_MAIN_MENU = 2;
public void setFullScreen(boolean b) {
this.dispose();
if (b) {
this.setSize(Toolkit.getDefaultToolkit().getScreenSize());
}
else {
this.setSize(dimensions[0]);
}
this.setUndecorated(b);
this.setVisible(true);
}
private JPanel actualPanel;
public final Dimension[] dimensions = {
new Dimension(800, 600),
new Dimension(1280, 800),
new Dimension(1400, 1050),
new Dimension(1024, 600),
new Dimension(1600, 1200),
new Dimension(1600, 900),
new Dimension(2048, 1536)
};
private MainMenuGUI MainMenu = new MainMenuGUI();
private OptionMainMenuGUI OptionMainMenu = new OptionMainMenuGUI(this);
private ArgumentsInterpreter argint = new ArgumentsInterpreter();
}
MainMenuGUI.java:
package mario.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import mario.Main;
public class MainMenuGUI extends JPanel {
public MainMenuGUI() {}
public void setFrame(Main f) {
this.f = f;
this.run();
this.setAccess();
f.Action(Main.MAIN_MENU);
}
private void run() {
this.add(spButton);
this.add(mpButton);
this.add(editorButton);
this.add(optionButton);
this.add(exitButton);
Listener l = new Listener();
spButton.addActionListener(l);
mpButton.addActionListener(l);
editorButton.addActionListener(l);
optionButton.addActionListener(l);
exitButton.addActionListener(l);
}
private void setAccess() {
spButton.setEnabled(false);
mpButton.setEnabled(false);
editorButton.setEnabled(false);
optionButton.setEnabled(true);
exitButton.setEnabled(true);
}
private class Listener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == exitButton) {
System.exit(0);
}
if (e.getSource() == optionButton) {
f.Action(Main.OPTION_MAIN_MENU);
}
}
}
private Main f;
private JButton exitButton = new JButton("Wyjście z gry");
private JButton optionButton = new JButton("Opcje");
private JButton spButton = new JButton("Gra jednoosobowa");
private JButton mpButton = new JButton("Gra wieloosobowa");
private JButton editorButton = new JButton("Edytor");
}