undid dumb stuff
This commit is contained in:
parent
74ef472dd4
commit
6941497a23
27 changed files with 54 additions and 188 deletions
BIN
App.jar
BIN
App.jar
Binary file not shown.
Binary file not shown.
BIN
GameRunner.class
BIN
GameRunner.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
GridDialog.class
BIN
GridDialog.class
Binary file not shown.
206
GridDialog.java
206
GridDialog.java
|
|
@ -28,187 +28,55 @@ public class GridDialog {
|
||||||
public void createDialog() {
|
public void createDialog() {
|
||||||
dialog.setLayout(new GridBagLayout());
|
dialog.setLayout(new GridBagLayout());
|
||||||
|
|
||||||
SpinnerModel players = new SpinnerNumberModel(2, 1, 4, 1);
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
JSpinner numPlayers = new JSpinner(players);
|
c.fill = GridBagConstraints.BOTH;
|
||||||
|
c.gridy = 0;
|
||||||
|
c.gridwidth = 2;
|
||||||
|
c.weightx = 1;
|
||||||
|
c.weighty = 1;
|
||||||
|
c.insets = new Insets(2, 5, 10, 5);
|
||||||
|
JLabel title = new JLabel("Board Size Picker", JLabel.CENTER);
|
||||||
|
title.setFont(new Font(title.getFont().getName(), Font.BOLD, title.getFont().getSize() + 2));
|
||||||
|
dialog.add(title, c);
|
||||||
|
|
||||||
GridBagConstraints mainGBC = new GridBagConstraints();
|
c.gridy = 1;
|
||||||
|
c.gridwidth = 1;
|
||||||
|
c.insets = new Insets(2, 5, 2, 5);
|
||||||
|
dialog.add(new JLabel("Name 1:", JLabel.RIGHT), c);
|
||||||
|
dialog.add(name1, c);
|
||||||
|
|
||||||
mainGBC.gridy = 0;
|
c.gridy = 2;
|
||||||
mainGBC.gridwidth = 2;
|
dialog.add(new JLabel("Name 2:", JLabel.RIGHT), c);
|
||||||
mainGBC.fill = GridBagConstraints.BOTH;
|
dialog.add(name2, c);
|
||||||
mainGBC.insets = new Insets(2, 5, 2, 5);
|
|
||||||
JLabel numPlayerTitle = new JLabel("Player Picker", JLabel.CENTER);
|
|
||||||
numPlayerTitle.setFont(new Font(numPlayerTitle.getFont().getName(), Font.BOLD, numPlayerTitle.getFont().getSize() + 2));
|
|
||||||
dialog.add(numPlayerTitle, mainGBC);
|
|
||||||
|
|
||||||
mainGBC.gridy = 1;
|
c.gridy = 3;
|
||||||
mainGBC.gridwidth = 1;
|
dialog.add(new JLabel("# of Cards:", JLabel.RIGHT), c);
|
||||||
dialog.add(new JLabel("# of Players:"), mainGBC);
|
dialog.add(numCards, c);
|
||||||
dialog.add(numPlayers, mainGBC);
|
|
||||||
|
|
||||||
mainGBC.gridy = 2;
|
c.gridy = 4;
|
||||||
JButton playersOk = new JButton("Ok");
|
JButton okButton = new JButton("Ok");
|
||||||
playersOk.addActionListener(new ActionListener() {
|
okButton.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int players = (Integer)numPlayers.getValue();
|
new Main(name1.getText(), name2.getText(), factor((Integer)numCards.getValue())[0], factor((Integer)numCards.getValue())[1]);
|
||||||
dialog.getContentPane().removeAll();
|
dialog.dispose();
|
||||||
|
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
|
||||||
c.fill = GridBagConstraints.BOTH;
|
|
||||||
c.gridy = 0;
|
|
||||||
c.gridwidth = 2;
|
|
||||||
c.weightx = 1;
|
|
||||||
c.weighty = 1;
|
|
||||||
c.insets = new Insets(2, 5, 10, 5);
|
|
||||||
JLabel title = new JLabel("Board Size Picker", JLabel.CENTER);
|
|
||||||
title.setFont(new Font(title.getFont().getName(), Font.BOLD, title.getFont().getSize() + 2));
|
|
||||||
dialog.add(title, c);
|
|
||||||
|
|
||||||
c.gridy = 1;
|
|
||||||
c.gridwidth = 1;
|
|
||||||
c.insets = new Insets(2, 5, 2, 5);
|
|
||||||
dialog.add(new JLabel("Name 1:", JLabel.RIGHT), c);
|
|
||||||
dialog.add(name1, c);
|
|
||||||
|
|
||||||
if (players > 1) {
|
|
||||||
c.gridy = 2;
|
|
||||||
dialog.add(new JLabel("Name 2:", JLabel.RIGHT), c);
|
|
||||||
dialog.add(name2, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
c.gridy = players + 1;
|
|
||||||
dialog.add(new JLabel("# of Cards:", JLabel.RIGHT), c);
|
|
||||||
dialog.add(numCards, c);
|
|
||||||
|
|
||||||
c.gridy = players + 2;
|
|
||||||
JButton okButton = new JButton("Ok");
|
|
||||||
okButton.addActionListener(new ActionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
dialog.getContentPane().removeAll();
|
|
||||||
|
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
|
||||||
|
|
||||||
gbc.gridy = 0;
|
|
||||||
gbc.gridwidth = 2;
|
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc.insets = new Insets(2, 5, 2, 5);
|
|
||||||
JLabel playerTitle = new JLabel("Game Mode Picker", JLabel.CENTER);
|
|
||||||
playerTitle.setFont(new Font(playerTitle.getFont().getName(), Font.BOLD, playerTitle.getFont().getSize() + 2));
|
|
||||||
dialog.add(playerTitle, gbc);
|
|
||||||
|
|
||||||
if (players > 1) {
|
|
||||||
gbc.gridy = 1;
|
|
||||||
JButton localMultiplayerButton = new JButton("Local Multiplayer");
|
|
||||||
localMultiplayerButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
new Main(name1.getText(), name2.getText(), factor((Integer)numCards.getValue())[0], factor((Integer)numCards.getValue())[1], players);
|
|
||||||
dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.add(localMultiplayerButton, gbc);
|
|
||||||
|
|
||||||
gbc.gridy = 2;
|
|
||||||
JButton LANMultiplayerButton = new JButton("LAN Multiplayer");
|
|
||||||
LANMultiplayerButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
new Main(name1.getText(), name2.getText(), factor((Integer)numCards.getValue())[0], factor((Integer)numCards.getValue())[1], players);
|
|
||||||
dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.add(LANMultiplayerButton, gbc);
|
|
||||||
|
|
||||||
gbc.gridy = 3;
|
|
||||||
JButton onlineMultiplayerButton = new JButton("Online Multiplayer");
|
|
||||||
onlineMultiplayerButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
|
|
||||||
dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.add(onlineMultiplayerButton, gbc);
|
|
||||||
} else {
|
|
||||||
gbc.gridy = 1;
|
|
||||||
JButton singleplayerButton = new JButton("Singleplayer");
|
|
||||||
singleplayerButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
new Main(name1.getText(), name2.getText(), factor((Integer)numCards.getValue())[0], factor((Integer)numCards.getValue())[1], players);
|
|
||||||
dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.add(singleplayerButton, gbc);
|
|
||||||
|
|
||||||
gbc.gridy = 2;
|
|
||||||
JButton comButton = new JButton("Player v. COM");
|
|
||||||
comButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
|
|
||||||
dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.add(comButton, gbc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (players > 1) gbc.gridy = 4;
|
|
||||||
else gbc.gridy = 3;
|
|
||||||
gbc.gridwidth = 1;
|
|
||||||
gbc.insets = new Insets(5, 5, 2, 5);
|
|
||||||
JButton backPlayerButton = new JButton("Back");
|
|
||||||
backPlayerButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
|
|
||||||
new GridDialog(name1.getText(), name2.getText(), factor((Integer)numCards.getValue())[0] * factor((Integer)numCards.getValue())[1]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.add(backPlayerButton, gbc);
|
|
||||||
|
|
||||||
JButton cancelPlayerButton = new JButton("Cancel");
|
|
||||||
cancelPlayerButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
dialog.dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.add(cancelPlayerButton, gbc);
|
|
||||||
|
|
||||||
dialog.revalidate();
|
|
||||||
dialog.repaint();
|
|
||||||
dialog.pack();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.add(okButton, c);
|
|
||||||
|
|
||||||
c.gridx = 1;
|
|
||||||
JButton cancelButton = new JButton("Cancel");
|
|
||||||
cancelButton.addActionListener(new ActionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
dialog.dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.add(cancelButton, c);
|
|
||||||
|
|
||||||
dialog.revalidate();
|
|
||||||
dialog.repaint();
|
|
||||||
dialog.pack();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
dialog.add(okButton, c);
|
||||||
|
|
||||||
dialog.add(playersOk, mainGBC);
|
c.gridx = 1;
|
||||||
dialog.add(new JButton("Cancel"), mainGBC);
|
JButton cancelButton = new JButton("Cancel");
|
||||||
|
cancelButton.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
dialog.dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.add(cancelButton, c);
|
||||||
dialog.pack();
|
dialog.pack();
|
||||||
|
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
|
|
||||||
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
|
|
||||||
BIN
Main$1.class
BIN
Main$1.class
Binary file not shown.
BIN
Main$2.class
BIN
Main$2.class
Binary file not shown.
BIN
Main$3.class
BIN
Main$3.class
Binary file not shown.
BIN
Main$4.class
BIN
Main$4.class
Binary file not shown.
BIN
Main.class
BIN
Main.class
Binary file not shown.
18
Main.java
18
Main.java
|
|
@ -47,7 +47,7 @@ public class Main {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public Main(String name1, String name2, int rows, int cols, int players) {
|
public Main(String name1, String name2, int r, int c) {
|
||||||
/*try {
|
/*try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
|
||||||
|
|
@ -85,11 +85,11 @@ public class Main {
|
||||||
player2.setText(name2 + ": 0");
|
player2.setText(name2 + ": 0");
|
||||||
|
|
||||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
screenSize = new Dimension((int)((((screenSize.getHeight()*4)/5)/rows)*2)/3, (int)((screenSize.getHeight()*4)/5)/rows);
|
screenSize = new Dimension((int)((((screenSize.getHeight()*4)/5)/r)*2)/3, (int)((screenSize.getHeight()*4)/5)/r);
|
||||||
|
|
||||||
if (Toolkit.getDefaultToolkit().getScreenSize().getWidth() < ((cols * screenSize.getWidth()) + ((cols + 1) * 5))) {
|
if (Toolkit.getDefaultToolkit().getScreenSize().getWidth() < ((c * screenSize.getWidth()) + ((c + 1) * 5))) {
|
||||||
screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
screenSize = new Dimension((int)((screenSize.getWidth()*5)/6)/cols, (int)((((screenSize.getWidth()*5)/6)/cols)*3)/2);
|
screenSize = new Dimension((int)((screenSize.getWidth()*5)/6)/c, (int)((((screenSize.getWidth()*5)/6)/c)*3)/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fontSize;
|
int fontSize;
|
||||||
|
|
@ -105,8 +105,8 @@ public class Main {
|
||||||
|
|
||||||
Font useFont = new Font(testFont.getFont().getName(), Font.PLAIN, fontSize);
|
Font useFont = new Font(testFont.getFont().getName(), Font.PLAIN, fontSize);
|
||||||
|
|
||||||
this.rows = rows;
|
rows = r;
|
||||||
this.cols = cols;
|
cols = c;
|
||||||
|
|
||||||
panels = new JPanel[rows][cols];
|
panels = new JPanel[rows][cols];
|
||||||
btns = new JButton[rows][cols];
|
btns = new JButton[rows][cols];
|
||||||
|
|
@ -270,11 +270,11 @@ public class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.setLayout(new GridBagLayout());
|
frame.setLayout(new GridBagLayout());
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
c.gridy = 0;
|
gbc.gridy = 0;
|
||||||
|
|
||||||
frame.add(infoPanel, c);
|
frame.add(infoPanel, c);
|
||||||
c.gridy = 1;
|
gbc.gridy = 1;
|
||||||
|
|
||||||
frame.add(panel, c);
|
frame.add(panel, c);
|
||||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
javac *.java
|
javac -source 1.7 -target 1.7 *.java
|
||||||
IF EXIST App.jar DEL /F App.jar
|
IF EXIST Calc.jar DEL /F Calc.jar
|
||||||
jar cfm App.jar manifest.txt *.class
|
jar cfm Calc.jar manifest.txt *.class
|
||||||
java -jar App.jar
|
echo off
|
||||||
|
DEL /F *.class
|
||||||
|
DEL /F *.ctxt
|
||||||
|
cls
|
||||||
|
java -jar Calc.jar
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
"C:\Program Files\Java\jdk1.8.0_172\bin\javac" *.java
|
|
||||||
IF EXIST App.jar DEL /F App.jar
|
|
||||||
"C:\Program Files\Java\jdk1.8.0_172\bin\jar" cfm App.jar manifest.txt *.class
|
|
||||||
echo off
|
|
||||||
cls
|
|
||||||
"C:\Program Files\Java\jdk1.8.0_172\bin\java" -jar App.jar
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue