summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlaeila <laeila@equijubus>2009-08-21 15:36:18 +0200
committerlaeila <laeila@equijubus>2009-08-21 15:36:18 +0200
commit8fbe5a7fc851885bced2140df92e0dcb43a5d681 (patch)
tree70ac83e3c0519dbfdf1960a99df73fedec8fd712 /src
parent1c5cbb8b51492c4d9e5528526f8a5664599a1a12 (diff)
downloadjeopardy-8fbe5a7fc851885bced2140df92e0dcb43a5d681.tar
jeopardy-8fbe5a7fc851885bced2140df92e0dcb43a5d681.zip
oberfläche für die spielerstellung angefangen
Diffstat (limited to 'src')
-rw-r--r--src/jeopardy/AQPair.java9
-rw-r--r--src/jeopardy/Controller.java20
-rw-r--r--src/jeopardy/Game.java16
-rw-r--r--src/jeopardy/GameDescription.java29
-rw-r--r--src/jeopardy/Jeopardy.java10
-rw-r--r--src/jeopardy/View.java200
6 files changed, 281 insertions, 3 deletions
diff --git a/src/jeopardy/AQPair.java b/src/jeopardy/AQPair.java
new file mode 100644
index 0000000..75ac226
--- /dev/null
+++ b/src/jeopardy/AQPair.java
@@ -0,0 +1,9 @@
+package jeopardy;
+
+public class AQPair {
+
+
+ AQPair() {
+
+ }
+}
diff --git a/src/jeopardy/Controller.java b/src/jeopardy/Controller.java
index 783c458..dc8687b 100644
--- a/src/jeopardy/Controller.java
+++ b/src/jeopardy/Controller.java
@@ -1,5 +1,23 @@
package jeopardy;
-public class Controller {
+import java.util.ArrayList;
+public class Controller {
+
+ void beginGame(GameDescription description) {
+
+ }
+
+ boolean isValidUser(String user) {
+ return false;
+ }
+
+ void createUser(String user) {
+
+ }
+
+ ArrayList<String> getCategories(ArrayList<String> players) {
+ ArrayList<String> blubb = new ArrayList<String>();
+ return blubb;
+ }
}
diff --git a/src/jeopardy/Game.java b/src/jeopardy/Game.java
new file mode 100644
index 0000000..f9f2872
--- /dev/null
+++ b/src/jeopardy/Game.java
@@ -0,0 +1,16 @@
+package jeopardy;
+
+import java.util.ArrayList;
+
+public class Game {
+
+ GameDescription description;
+ ArrayList<ArrayList<AQPair>> content;
+
+ Game(){}
+
+ Game(GameDescription d, ArrayList<ArrayList<AQPair>> c) {
+ description = d;
+ content = c;
+ }
+}
diff --git a/src/jeopardy/GameDescription.java b/src/jeopardy/GameDescription.java
new file mode 100644
index 0000000..6c22fa7
--- /dev/null
+++ b/src/jeopardy/GameDescription.java
@@ -0,0 +1,29 @@
+package jeopardy;
+
+import java.util.ArrayList;
+
+import javax.swing.JTextField;
+
+public class GameDescription {
+
+ private ArrayList<String> categories;
+ private ArrayList<String> users;
+
+ public void addUser(String user) {
+ users.add(user);
+ }
+
+ public void addCategory(String category) {
+ categories.add(category);
+ }
+
+ GameDescription() {
+ categories = new ArrayList<String>();
+ users = new ArrayList<String>();
+ }
+
+ GameDescription(ArrayList<String> c, ArrayList<String> u) {
+ categories = c;
+ users = u;
+ }
+}
diff --git a/src/jeopardy/Jeopardy.java b/src/jeopardy/Jeopardy.java
index 7b5f3db..e6c5e12 100644
--- a/src/jeopardy/Jeopardy.java
+++ b/src/jeopardy/Jeopardy.java
@@ -1,13 +1,19 @@
package jeopardy;
+import javax.swing.SwingUtilities;
+
public class Jeopardy {
/**
* @param args
*/
public static void main(String[] args) {
- // TODO Auto-generated method stub
-
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ View view = new View(new Controller());
+ view.createGameDialog(new GameDescription());
+ }
+ });
}
}
diff --git a/src/jeopardy/View.java b/src/jeopardy/View.java
index bed1eba..a2f50c2 100644
--- a/src/jeopardy/View.java
+++ b/src/jeopardy/View.java
@@ -1,5 +1,205 @@
package jeopardy;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import java.util.ArrayList;
+
public class View {
+ private Controller controller;
+
+ private JFrame show;
+ private JFrame host;
+
+ private JPanel labelPanel;
+ private JPanel questionPanel;
+
+
+ public void createGameDialog(final GameDescription description) {
+
+ final JPanel pmPanel = new JPanel();
+ final BoxLayout pmLayout = new BoxLayout(pmPanel, BoxLayout.LINE_AXIS);
+ pmPanel.setLayout(pmLayout);
+
+ final JPanel usersPanel = new JPanel();
+ final BoxLayout usersLayout = new BoxLayout(usersPanel, BoxLayout.PAGE_AXIS);
+ usersPanel.setLayout(usersLayout);
+
+ final JPanel nameAreaPanel = new JPanel();
+ final BoxLayout nameAreaLayout = new BoxLayout(nameAreaPanel, BoxLayout.PAGE_AXIS);
+ nameAreaPanel.setLayout(nameAreaLayout);
+
+ final ArrayList<JTextField> nameArea = new ArrayList<JTextField>();
+ JTextField firstName = new JTextField();
+ nameArea.add(new JTextField());
+ firstName.setMaximumSize(new Dimension(Short.MAX_VALUE, 1));
+ nameAreaPanel.add(Box.createGlue());
+ nameAreaPanel.add(firstName);
+
+ nameAreaPanel.setMaximumSize(new Dimension(150, 1));
+
+ JLabel descriptionLabel = new JLabel("Bitte Spielernamen angeben!");
+
+ JButton plus = new JButton("+");
+ plus.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ nameArea.add(new JTextField());
+ nameArea.get(nameArea.size()-1).setMaximumSize(new Dimension(Short.MAX_VALUE, 1));
+ nameAreaPanel.add(nameArea.get(nameArea.size()-1));
+ host.validate();
+ }
+ });
+
+ JButton minus = new JButton("-");
+ minus.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ nameAreaPanel.remove(nameArea.get(nameArea.size()-1));
+ nameArea.remove(nameArea.size()-1);
+ host.validate();
+ }
+ });
+
+ JButton finish = new JButton("Ok");
+
+ pmPanel.add(plus);
+ pmPanel.add(minus);
+
+ descriptionLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
+ nameAreaPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
+ pmPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
+ finish.setAlignmentX(Component.CENTER_ALIGNMENT);
+
+ usersPanel.add(descriptionLabel);
+ usersPanel.add(nameAreaPanel);
+ usersPanel.add(Box.createGlue());
+ usersPanel.add(pmPanel);
+ usersPanel.add(finish);
+
+ host.add(usersPanel);
+ host.validate();
+
+
+ //----------------------
+
+ final JPanel pmPanel2 = new JPanel();
+ final BoxLayout pmLayout2 = new BoxLayout(pmPanel2, BoxLayout.LINE_AXIS);
+ pmPanel2.setLayout(pmLayout2);
+
+ final JPanel categoriesPanel = new JPanel();
+ final BoxLayout categoriesLayout = new BoxLayout(categoriesPanel, BoxLayout.PAGE_AXIS);
+ categoriesPanel.setLayout(categoriesLayout);
+
+ categoriesPanel.setSize(new Dimension(5, Short.MAX_VALUE));
+
+ final JPanel categoriesAreaPanel = new JPanel();
+ final BoxLayout categoriesAreaLayout = new BoxLayout(categoriesAreaPanel, BoxLayout.PAGE_AXIS);
+ categoriesAreaPanel.setLayout(categoriesAreaLayout);
+
+ categoriesAreaPanel.setMaximumSize(new Dimension(150, 1));
+
+ final ArrayList<Choice> categoriesArea = new ArrayList<Choice>();
+ Choice firstCategory = new Choice();
+ categoriesArea.add(firstCategory);
+
+ firstCategory.setMaximumSize(new Dimension(Short.MAX_VALUE, 1));
+ categoriesAreaPanel.add(Box.createGlue());
+
+ categoriesAreaPanel.add(firstCategory);
+
+ JLabel descriptionLabel2 = new JLabel("Bitte Kategorien auswählen!");
+
+ JButton plus2 = new JButton("+");
+
+ plus2.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ categoriesArea.add(new Choice());
+ categoriesArea.get(categoriesArea.size()-1).setMaximumSize(new Dimension(Short.MAX_VALUE, 1));
+ categoriesAreaPanel.add(categoriesArea.get(categoriesArea.size()-1));
+ host.validate();
+ }
+ });
+
+ JButton minus2 = new JButton("-");
+
+ minus2.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ categoriesAreaPanel.remove(categoriesArea.get(nameArea.size()-1));
+ categoriesArea.remove(nameArea.size()-1);
+ host.validate();
+ }
+ });
+
+ JButton finish2 = new JButton("Ok");
+
+ descriptionLabel2.setAlignmentX(Component.CENTER_ALIGNMENT);
+ categoriesAreaPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
+ pmPanel2.setAlignmentX(Component.CENTER_ALIGNMENT);
+ finish2.setAlignmentX(Component.CENTER_ALIGNMENT);
+
+ pmPanel2.add(plus2);
+ pmPanel2.add(minus2);
+
+ categoriesPanel.add(descriptionLabel2);
+ categoriesPanel.add(categoriesAreaPanel);
+ categoriesPanel.add(Box.createGlue());
+ categoriesPanel.add(pmPanel2);
+ categoriesPanel.add(finish2);
+
+ finish.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ for(JTextField bla : nameArea) {
+ description.addUser(bla.getText());
+ }
+ host.remove(usersPanel);
+ host.add(categoriesPanel);
+ host.validate();
+ }
+ });
+
+ finish2.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ for(Choice bla : categoriesArea) {
+ description.addCategory(bla.getSelectedItem());
+ }
+ host.remove(categoriesPanel);
+ host.validate();
+ host.repaint();
+ }
+ });
+ }
+
+
+ //----------------------
+
+
+ public void showQuestion(String q) {
+ show.removeAll();
+
+ questionPanel = new JPanel();
+ JLabel question = new JLabel(q);
+
+ show.add(question);
+ show.validate();
+
+ }
+
+ public void showLabelPanel() {
+
+ }
+
+ public View(Controller c) {
+ controller = c;
+
+ show = new JFrame("Show");
+ show.setSize(800, 600);
+ show.setVisible(true);
+
+ host = new JFrame("Host");
+ host.setSize(800, 600);
+ host.setVisible(true);
+
+ labelPanel = new JPanel();
+ }
+
}