Merge branch 'patch-1' of https://gitlab.imn.htwk-leipzig.de/weicker/inb1-a-jaujau.git into patch-1
BIN
StandartTexturenBeta3.zip
Executable file
BIN
StandartTexturenFehler.zip
Executable file
5
highscore.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Seb 245
|
||||
Elmo 240
|
||||
Moritz 220
|
||||
Alaa Aldin 217
|
||||
Fabian 215
|
@@ -22,7 +22,7 @@ class TEST_Kartensatz {
|
||||
@Test
|
||||
void ziehenSpieler() {
|
||||
for(int i = 0; i < 32; i++) {
|
||||
//Spieler hat zu angang keine Karten auf der Hand
|
||||
//Spieler hat zu anfang keine Karten auf der Hand
|
||||
assertTrue(satz.getHand(Spieler.SPIELER).size()==i);
|
||||
|
||||
//Karte Ziehen
|
||||
|
@@ -21,7 +21,7 @@ class TEST_Texturenpaket {
|
||||
|
||||
@Test
|
||||
void FehlerFreiesPaketLaden() {
|
||||
paket = new Texturenpaket("/home/sebastian/testpaket.zip");
|
||||
paket = new Texturenpaket("StandartTexturenBeta3.zip");
|
||||
assertTrue(paket.ladePacket());
|
||||
System.out.println("Name des Texturen Paketes: " + paket.getName());
|
||||
System.out.println("Level des Texturen Paketes: " + paket.getLevel());
|
||||
@@ -29,7 +29,7 @@ class TEST_Texturenpaket {
|
||||
|
||||
@Test
|
||||
void FehlerHaftesPaketLaden() {
|
||||
paket = new Texturenpaket("/home/sebastian/testpaket_fehler.zip");
|
||||
paket = new Texturenpaket("StandartTexturenFehler");
|
||||
assertFalse(paket.ladePacket());
|
||||
System.out.println("Name des Fehlerhaften Texturen Paketes: " + paket.getName());
|
||||
System.out.println("Level des Fehlerhaften Texturen Paketes: " + paket.getLevel());
|
||||
@@ -38,10 +38,10 @@ class TEST_Texturenpaket {
|
||||
|
||||
@Test
|
||||
void TexturenAusgeben() {
|
||||
paket = new Texturenpaket("/home/sebastian/testpaket.zip");
|
||||
paket = new Texturenpaket("StandartTexturenBeta3.zip");
|
||||
assertTrue(paket.ladePacket());
|
||||
Image Bilder[] = paket.getTexturen();
|
||||
for(int i = 0; i < 32; i++) {
|
||||
for(int i = 0; i < 33; i++) {
|
||||
assertTrue(Bilder[i] != null);
|
||||
}
|
||||
}
|
||||
|
33
src/de/jaujau/UnitTests/TEST_TexturenpaketIntern.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package de.jaujau.UnitTests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import de.jaujau.daten.TexturenpaketIntern;
|
||||
|
||||
class TEST_TexturenpaketIntern {
|
||||
|
||||
private TexturenpaketIntern paket;
|
||||
|
||||
@Test
|
||||
void FehlerFreiesPaketLaden() {
|
||||
paket = new TexturenpaketIntern("/img/texturen/standart", "TestPaket", 0);
|
||||
assertTrue(paket.ladePacket());
|
||||
System.out.println("Name des Texturen Paketes: " + paket.getName());
|
||||
System.out.println("Level des Texturen Paketes: " + paket.getLevel());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void TexturenAusgeben() {
|
||||
paket = new TexturenpaketIntern("/img/texturen/standart", "TestPaket", 0);
|
||||
assertTrue(paket.ladePacket());
|
||||
Image Bilder[] = paket.getTexturen();
|
||||
for(int i = 0; i < 33; i++) {
|
||||
assertTrue(Bilder[i] != null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -16,15 +16,33 @@ class TEST_Texturenpakete {
|
||||
pakete = new Texturenpakete();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
assertTrue(pakete.getAnzahlPakete()==0);
|
||||
assertTrue(pakete.addPaket("/home/sebastian/testpaket.zip"));
|
||||
void InternesPaket() {
|
||||
assertTrue(pakete.getAnzahlPakete()==1);
|
||||
//assertTrue(pakete.addPaket("StandartTexturenBeta3.zip"));
|
||||
//assertTrue(pakete.getAnzahlPakete()==2);
|
||||
assertTrue(pakete.setAktivesPaket(0));
|
||||
assertTrue(pakete.getAktivesPaket()==0);
|
||||
System.out.println(pakete.getName(0));
|
||||
System.out.println(pakete.getName(0));
|
||||
System.out.println("Test Intern");
|
||||
System.out.println("Paket Name: " + pakete.getName(0));
|
||||
System.out.println("Paket Level: " + pakete.getLevel(0));
|
||||
for(int i = 0; i < 32; i++) {
|
||||
assertTrue(pakete.getTextur(i)!=null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void ExternesPaket() {
|
||||
assertTrue(pakete.getAnzahlPakete()==1);
|
||||
assertTrue(pakete.addPaket("StandartTexturenBeta3.zip"));
|
||||
assertTrue(pakete.getAnzahlPakete()==2);
|
||||
assertTrue(pakete.setAktivesPaket(1));
|
||||
assertTrue(pakete.getAktivesPaket()==1);
|
||||
System.out.println("Test Extern");
|
||||
System.out.println("Paket Name: " + pakete.getName(1));
|
||||
System.out.println("Paket Level: " + pakete.getLevel(1));
|
||||
for(int i = 0; i < 32; i++) {
|
||||
assertTrue(pakete.getTextur(i)!=null);
|
||||
}
|
||||
|
@@ -1,3 +1,10 @@
|
||||
/**
|
||||
|
||||
* @author Alaa Aldin
|
||||
|
||||
* @version 1.0
|
||||
|
||||
*/
|
||||
package de.jaujau.daten;
|
||||
|
||||
public enum Spieler {
|
||||
|
@@ -1,5 +1,12 @@
|
||||
/**
|
||||
|
||||
* @author Alaa Aldin
|
||||
|
||||
* @version 1.0
|
||||
|
||||
*/
|
||||
package de.jaujau.daten;
|
||||
import de.jaujau.spiellogik.Spiel;
|
||||
//import de.jaujau.spiellogik.Spiel;
|
||||
|
||||
/**
|
||||
* Class Spieler
|
||||
@@ -15,10 +22,21 @@ public class Spielerdaten {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of punktestand
|
||||
*
|
||||
* @return the value of punktestand
|
||||
*/
|
||||
|
||||
public int getPunktestand() {
|
||||
return punktestand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of name
|
||||
*
|
||||
* @return the value of name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@@ -1,7 +1,15 @@
|
||||
/**
|
||||
|
||||
* @author Alaa Aldin
|
||||
|
||||
* @version 1.0
|
||||
|
||||
*/
|
||||
package de.jaujau.daten;
|
||||
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Spielerverwaltung {
|
||||
|
||||
@@ -10,37 +18,29 @@ public class Spielerverwaltung {
|
||||
private Spielerdaten spieler;
|
||||
|
||||
private String name = "Mark Zuckerberg"; // Testeintrag
|
||||
/**
|
||||
* arraylist von Spieler
|
||||
*/
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
// Accessor methods
|
||||
//
|
||||
/**
|
||||
* Set the value of level
|
||||
* @param newVar the new value of level
|
||||
*
|
||||
* @param newlevel the new value of level
|
||||
*/
|
||||
public void setLevel(int newlevel) {
|
||||
level = newlevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of level
|
||||
*
|
||||
* @return the value of level
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of level
|
||||
* @return the value of level
|
||||
* Get the value of name
|
||||
*
|
||||
* @return the value of name
|
||||
*/
|
||||
public String getName() {
|
||||
|
||||
@@ -48,17 +48,17 @@ public class Spielerverwaltung {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of spieler
|
||||
* arraylist von Spieler
|
||||
* @param newVar the new value of spieler
|
||||
* Set the value of spieler arraylist von Spieler
|
||||
*
|
||||
* @param newSpieler the new value of spieler
|
||||
*/
|
||||
public void setSpieler(Spielerdaten newSpieler) {
|
||||
spieler = newSpieler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of spieler
|
||||
* arraylist von Spieler
|
||||
* Get the value of spieler arraylist von Spieler
|
||||
*
|
||||
* @return the value of spieler
|
||||
*/
|
||||
public Spielerdaten getSpieler() {
|
||||
@@ -71,20 +71,63 @@ public class Spielerverwaltung {
|
||||
|
||||
/**
|
||||
*/
|
||||
public void leseDaten()
|
||||
{
|
||||
public void leseDaten() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public void speichernDaten()
|
||||
{
|
||||
public void speichernDaten() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Spielerverwaltung() {
|
||||
//Implementieren
|
||||
};
|
||||
// Die Highscore-datei wird geoeffnet und die Daten als zweidimensionales Array
|
||||
// zurueckgegeben
|
||||
public String[][] gethighscoreTabelle() {
|
||||
String[][] rowData = new String[15][2];
|
||||
BufferedReader reader;
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader("highscore.txt"));
|
||||
String line = reader.readLine();
|
||||
char[] lineArray;
|
||||
String name = "";
|
||||
String score = "";
|
||||
int zeilennummer = 0;
|
||||
boolean insArray = false;
|
||||
while (line != null) {
|
||||
System.out.println(line);
|
||||
lineArray = line.toCharArray();
|
||||
for (int i = 0; i < lineArray.length; i++) {
|
||||
|
||||
if (lineArray[i] != ' ' && score.length() == 0) {
|
||||
name += lineArray[i];
|
||||
} else if (lineArray[i] == ' ' && name.length() != 0) {
|
||||
i++;
|
||||
score += lineArray[i];
|
||||
|
||||
} else if (score.length() != 0) {
|
||||
score += lineArray[i];
|
||||
insArray = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (insArray) {
|
||||
rowData[zeilennummer][0] = name;
|
||||
rowData[zeilennummer][1] = score;
|
||||
insArray = false;
|
||||
}
|
||||
|
||||
zeilennummer++;
|
||||
name = score = "";
|
||||
line = reader.readLine();
|
||||
}
|
||||
reader.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return rowData;
|
||||
}
|
||||
}
|
||||
|
@@ -11,21 +11,41 @@ import java.util.zip.ZipFile;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
|
||||
/*ToDo:
|
||||
* lesen von Datein aus Zip in eigene Methoden auslagern
|
||||
* Fehlerprüfung nicht obtimal
|
||||
*/
|
||||
|
||||
/**
|
||||
* Verwaltet ein Texturenpackt
|
||||
* Verwaltung eines Texturenpaketes
|
||||
* zu jedem Paket werden folgende Informationen gespeichert:
|
||||
* Name
|
||||
* mindes Level
|
||||
* Pfad zu der Zip-Datei
|
||||
*
|
||||
* Aufbau eines Texturenpaketes:
|
||||
* name.zip
|
||||
* - paket.txt
|
||||
* - name:NAME
|
||||
* - level:LEVEL als Integer
|
||||
* - 0.png
|
||||
* - ...
|
||||
* - 31.png
|
||||
* - 32.png (Rückseite)
|
||||
*
|
||||
* @author Sebastian Kacza
|
||||
*
|
||||
*/
|
||||
public class Texturenpaket {
|
||||
|
||||
private String name;
|
||||
private int level;
|
||||
protected String name; //Protektet weil die abgeleitet Klasse TexturenpaketIntern auf die Werte zugreifen können muss
|
||||
protected int level;
|
||||
private final String pfad;
|
||||
|
||||
|
||||
/**
|
||||
* Erstellt ein neues Texturenpackt
|
||||
* @param Pfad zu der Zip-Datei des Texturenpacketes
|
||||
* @param Pfad zu der Zip-Datei des Texturenpaketes
|
||||
*/
|
||||
public Texturenpaket(String Pfad) {
|
||||
name = "Nicht geladen";
|
||||
@@ -35,8 +55,8 @@ public class Texturenpaket {
|
||||
|
||||
|
||||
/**
|
||||
* Läd die Packetinformationen und Testet das Packet auf Vollständigkeit
|
||||
* @return Paket vollständig laden, true/false
|
||||
* Läd die Packetinformationen in die lokalen Variablen und Testet das Packet auf Vollständigkeit
|
||||
* @return Paket vollständig geladen, true/false
|
||||
*/
|
||||
public boolean ladePacket() {
|
||||
System.out.println("TEXTURENPAKET: Lade Paket");
|
||||
@@ -52,7 +72,9 @@ public class Texturenpaket {
|
||||
InputStream eingabeStromTXT = paketDatei.getInputStream(zipInhaltPaketTXT);
|
||||
Scanner scanner = new Scanner(eingabeStromTXT);
|
||||
while(scanner.hasNext()) {
|
||||
String Zeile = scanner.next();
|
||||
String Zeile = scanner.nextLine();
|
||||
//scanner.nextLine()
|
||||
//scanner.next()
|
||||
String Spalte[] = Zeile.split(":");
|
||||
//System.out.println(Spalte.length);
|
||||
if(Spalte.length==2) {
|
||||
@@ -88,8 +110,8 @@ public class Texturenpaket {
|
||||
|
||||
|
||||
/**
|
||||
* Gibt alle Bilddatein für ein Texturen Paket zurück
|
||||
* @return Image der Texturen des Peketes als Image Array
|
||||
* Gibt alle Bilddatein von dem Texturenpaket als Image Array zurück
|
||||
* @return Image Array der Texturen des Paketes
|
||||
*/
|
||||
public Image[] getTexturen() {
|
||||
if(testePaket()) {
|
||||
@@ -97,15 +119,17 @@ public class Texturenpaket {
|
||||
try {
|
||||
File zipDatei = new File(pfad);
|
||||
ZipFile paketDatei = new ZipFile(zipDatei);
|
||||
Image Bilder[] = new Image[32];
|
||||
Image Bilder[] = new Image[33];
|
||||
|
||||
for(int i = 0; i < 32; i++) {
|
||||
for(int i = 0; i < 33; i++) {
|
||||
ZipEntry zipInhaltTextur = paketDatei.getEntry(i+".png");
|
||||
InputStream eingabeStromTextur = paketDatei.getInputStream(zipInhaltTextur);
|
||||
Bilder[i] = ImageIO.read(eingabeStromTextur);
|
||||
}
|
||||
paketDatei.close();
|
||||
return Bilder;
|
||||
|
||||
|
||||
} catch (ZipException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
@@ -140,7 +164,7 @@ public class Texturenpaket {
|
||||
* @return Paket vollständig, true/false
|
||||
*/
|
||||
private boolean testePaket() {
|
||||
System.out.println("TEXTURENPAKET: Teste Paket:");
|
||||
System.out.println("TEXTURENPAKET: Paket auf Fehler untersuchen:");
|
||||
//Testen ob Zip-Datei vorhanden und lesabar ist
|
||||
File zipDatei = new File(pfad);
|
||||
if(zipDatei.exists() || zipDatei.canRead()) {
|
||||
@@ -157,8 +181,8 @@ public class Texturenpaket {
|
||||
boolean PaketLevel = false;
|
||||
while(scanner.hasNext()) {
|
||||
//Prüfen ob Konfigurations Datei die Einträge "name" und "level" enthält
|
||||
String Zeile = scanner.next();
|
||||
System.out.println("TEXTURENPAKET: " + Zeile);
|
||||
String Zeile = scanner.nextLine();
|
||||
System.out.println("TEXTURENPAKET: Konfigzeile:" + Zeile);
|
||||
if(Zeile.contains("name:")) {
|
||||
PaketName = true;
|
||||
}
|
||||
@@ -169,11 +193,12 @@ public class Texturenpaket {
|
||||
scanner.close();
|
||||
if(!PaketName || !PaketLevel) {
|
||||
System.out.println("TEXTURENPAKET: Paket Konfiguration fehlerhaft");
|
||||
paketDatei.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
//Texturen Prüfen
|
||||
for(int i = 0; i < 32; i++) {
|
||||
for(int i = 0; i < 33; i++) {
|
||||
ZipEntry zipInhaltTextur = paketDatei.getEntry(i+".png");
|
||||
InputStream eingabeStromTextur = paketDatei.getInputStream(zipInhaltTextur);
|
||||
Image bild = ImageIO.read(eingabeStromTextur);
|
||||
@@ -181,6 +206,7 @@ public class Texturenpaket {
|
||||
System.out.println("TEXTURENPAKET: Datei: " + i + ".png nicht gefunden");
|
||||
return false;
|
||||
}
|
||||
System.out.println("TEXTURENPAKET: Datei: " + i + ".png OK!");
|
||||
}
|
||||
|
||||
paketDatei.close();
|
||||
|
61
src/de/jaujau/daten/TexturenpaketIntern.java
Executable file
@@ -0,0 +1,61 @@
|
||||
package de.jaujau.daten;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
|
||||
/**
|
||||
* Klasse für Interne Texturen Pakete deren Bilddaten sich die direkt im jar Archiv befinden
|
||||
* ein Internes Paket muss NICHT geladen werden befor es genutz werden kann!
|
||||
* Interne Pakete werden NICHT auf vollständigkeit geprüft!
|
||||
* @author Sebastian Kacza
|
||||
*
|
||||
*/
|
||||
public class TexturenpaketIntern extends Texturenpaket{
|
||||
|
||||
public String pfad;
|
||||
|
||||
|
||||
/**
|
||||
* Erstelt ein Neues Internes Texturenpaket
|
||||
* @param Pfad Interner Pfad du den Bilddateien z.b. /img/texturen/standart
|
||||
* @param Name Name des Paketes
|
||||
* @param Level Minideslevel des Paketes
|
||||
*/
|
||||
public TexturenpaketIntern(String Pfad ,String Name, int Level) {
|
||||
super(Pfad);
|
||||
name = Name;
|
||||
level = Level;
|
||||
pfad = Pfad;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Das laden der Daten eines Internet Paket ist nicht notwendig!
|
||||
*/
|
||||
@Override
|
||||
public boolean ladePacket() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gibt alle Bilddatein von dem Texturenpaket als Image Array zurück
|
||||
* @return Image Array der Texturen des Paketes
|
||||
*/
|
||||
@Override
|
||||
public Image[] getTexturen() {
|
||||
Image Bilder[] = new Image[33];
|
||||
for(int i = 0; i < 33; i++) {
|
||||
try {
|
||||
Bilder[i] = ImageIO.read(getClass().getResource(pfad +"/" + i + ".png"));
|
||||
} catch (IOException e) {
|
||||
Bilder[i] = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return Bilder;
|
||||
}
|
||||
|
||||
}
|
@@ -16,6 +16,11 @@ public class Texturenpakete {
|
||||
|
||||
public Texturenpakete(){
|
||||
TexturenpaketListe = new ArrayList<Texturenpaket>();
|
||||
|
||||
//Hinzufügen eines Internen Texturenpaketes
|
||||
TexturenpaketListe.add(new TexturenpaketIntern("/img/texturen/standart", "JauJau Standart Texturen Französisch", 0));
|
||||
|
||||
//Internes Texturenpaket als Aktiv festlegen
|
||||
AktivesPaket = 0;
|
||||
}
|
||||
|
||||
@@ -65,27 +70,29 @@ public class Texturenpakete {
|
||||
|
||||
|
||||
/**
|
||||
* Setzt das aktive Paket
|
||||
* Legt fest welches Texturenpaket das Aktive sein soll
|
||||
* Die Bilder des Aktiven Textuenpaketes werden nur Pufferung in eine Array geladen.
|
||||
* Dies soll Dateizugriffe beim Anzeigen der Bilder reduzieren
|
||||
* @param PaketNr des Paketes
|
||||
* @return Setzen erfolgreich true/false
|
||||
*/
|
||||
public boolean setAktivesPaket(int PaketNr) {
|
||||
if((PaketNr >= 0) && (PaketNr < TexturenpaketListe.size())) {
|
||||
AktivesPaket = PaketNr;
|
||||
|
||||
//Texturen Laden
|
||||
Texturen = TexturenpaketListe.get(PaketNr).getTexturen();
|
||||
return true;
|
||||
//ToDo: Wenn für ein Bild ein Null Objekt zurückgegebn soll das Bild ausgetauscht werden?
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fügt ein Neues Testuren Paket hinzu
|
||||
* Das Paket wird vor dem einfügen auf Vollständfigkeit geprüft
|
||||
* @param Pfad
|
||||
* @return
|
||||
* Es wird ein neues Texturenpaket zu der Liste hinzugefügt
|
||||
* Das Paket wird vor dem einfügen auf Vollständfigkeit geprüft.
|
||||
* Wenn es unfolständig ist wird es nicht hinzugefügt
|
||||
* @param Pfad zu der Texturenpaket Datei (.zip)
|
||||
* @return Ob das Paket erfolgreich hinzu gefügt wurde, true/false
|
||||
*/
|
||||
public boolean addPaket(String Pfad) {
|
||||
Texturenpaket NeuesPaket = new Texturenpaket(Pfad);
|
||||
@@ -104,7 +111,7 @@ public class Texturenpakete {
|
||||
* @return Textur als Image
|
||||
*/
|
||||
public Image getTextur(int KartenNr) {
|
||||
if((KartenNr >= 0) && (KartenNr < 32)) {
|
||||
if((KartenNr >= 0) && (KartenNr < 33)) {
|
||||
return Texturen[KartenNr];
|
||||
}
|
||||
return null;
|
||||
|
@@ -1,31 +1,125 @@
|
||||
package de.jaujau.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import de.jaujau.daten.Spielerverwaltung;
|
||||
import de.jaujau.daten.Texturenpakete;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.SwingConstants;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.FlowLayout;
|
||||
import javax.swing.BoxLayout;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Class GUI
|
||||
*/
|
||||
public class GUI extends JFrame implements ActionListener{
|
||||
public class GUI extends JFrame{
|
||||
|
||||
//
|
||||
// Fields
|
||||
//
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Spielerverwaltung spielerverwaltung;
|
||||
private boolean menuehidden = false;
|
||||
Hilfe_GUI frame = new Hilfe_GUI();
|
||||
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public GUI () { }
|
||||
public GUI (Spielerverwaltung speicherung) {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setTitle("JauJau");
|
||||
setPreferredSize(new Dimension(800, 500));
|
||||
setSize(982, 642);
|
||||
this.spielerverwaltung = speicherung;
|
||||
getContentPane().setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel Menue = new JPanel();
|
||||
Menue.setPreferredSize(new Dimension(270, 450));
|
||||
getContentPane().add(Menue, BorderLayout.WEST);
|
||||
Menue.setLayout(new BoxLayout(Menue, BoxLayout.X_AXIS));
|
||||
|
||||
JPanel MenueIcon = new JPanel();
|
||||
MenueIcon.setPreferredSize(new Dimension(50, 450));
|
||||
MenueIcon.setBackground(new Color(15, 19, 52));
|
||||
Menue.add(MenueIcon);
|
||||
MenueIcon.setLayout(null);
|
||||
|
||||
JPanel help = new JPanel();
|
||||
help.setBounds(0, 0, 50, 50);
|
||||
help.setBackground(new Color(15, 19, 52));
|
||||
MenueIcon.add(help);
|
||||
|
||||
JLabel helplable = new JLabel("");
|
||||
helplable.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||
helplable.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
helplable.setIcon(new ImageIcon(GUI.class.getResource("/img/help.png")));
|
||||
help.add(helplable);
|
||||
|
||||
JPanel menuebtn = new JPanel();
|
||||
menuebtn.setBounds(0, 50, 50, 50);
|
||||
MenueIcon.add(menuebtn);
|
||||
menuebtn.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JLabel menuelabel = new JLabel("");
|
||||
menuelabel.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||
menuelabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
menuelabel.setIcon(new ImageIcon(GUI.class.getResource("/img/menue.png")));
|
||||
menuebtn.add(menuelabel);
|
||||
menuebtn.setBackground(new Color(15, 19, 52));
|
||||
|
||||
JPanel menuhide = new JPanel();
|
||||
menuhide.setPreferredSize(new Dimension(220, 200));
|
||||
menuhide.setBackground(new Color(25, 29, 74));
|
||||
Menue.add(menuhide);
|
||||
menuhide.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel dashboard = new JPanel();
|
||||
dashboard.setBackground(new Color(73, 128, 242));
|
||||
getContentPane().add(dashboard, BorderLayout.CENTER);
|
||||
dashboard.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
Spiel_GUI Spiel_GUI = new Spiel_GUI();
|
||||
dashboard.add(Spiel_GUI);
|
||||
|
||||
|
||||
menuebtn.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(menuehidden == true) {
|
||||
menuhide.setVisible(false);
|
||||
Menue.setPreferredSize(new Dimension(50, Menue.getHeight()));
|
||||
menuehidden = false;
|
||||
}else{
|
||||
menuhide.setVisible(true);
|
||||
Menue.setPreferredSize(new Dimension(270, Menue.getHeight()));
|
||||
menuehidden = true;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
help.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(frame.isShowing() == true) {
|
||||
frame.setVisible(false);
|
||||
}else{
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -34,12 +128,4 @@ public void actionPerformed(ActionEvent e) {
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Accessor methods
|
||||
//
|
||||
|
||||
//
|
||||
// Other methods
|
||||
//
|
||||
|
||||
}
|
||||
|
@@ -1,34 +1,43 @@
|
||||
package de.jaujau.gui;
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingConstants;
|
||||
import java.awt.Font;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
public class Hilfe_GUI extends JFrame {
|
||||
|
||||
private JPanel contentPane;
|
||||
|
||||
/**
|
||||
* Class Hilfe_GUI
|
||||
* Create the frame.
|
||||
*/
|
||||
public class Hilfe_GUI {
|
||||
public Hilfe_GUI() {
|
||||
setBounds(100, 100, 588, 382);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
contentPane.setLayout(new BorderLayout(0, 0));
|
||||
setContentPane(contentPane);
|
||||
|
||||
//
|
||||
// Fields
|
||||
//
|
||||
JLabel lblNewLabel = new JLabel("Hilfe");
|
||||
lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 20));
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
contentPane.add(lblNewLabel, BorderLayout.NORTH);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
contentPane.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public Hilfe_GUI () { };
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Accessor methods
|
||||
//
|
||||
|
||||
//
|
||||
// Other methods
|
||||
//
|
||||
JTextArea txtrJaujauJaujauIst = new JTextArea();
|
||||
txtrJaujauJaujauIst.setEditable(false);
|
||||
txtrJaujauJaujauIst.setText("JauJau\r\nJauJau ist ein Java basiertes Spiel was nach auf dem Spielprinzip von MauMau aufbaut.\r\n\r\nProduktvision\r\nJauJau - \"Java-MauMau\" Interaktives Spieldesign, welches die traditionellen\r\nSpielmechaniken von MauMau digitalisiert und es m\u00F6glich macht auch alleine den\r\nbeliebten Klassiker zu spielen. Individuell - durch Spielerfolg Freischaltung\r\nneuer Kartendesigns.\r\n\r\nSpielidee\r\n\r\nKartenspiel auf Basis von MauMau.\r\nEin Spieler spielt gegen eine Computer Spieler\r\nDie Punktest\u00E4nde der Spieler werden Gespeichert\r\nMit h\u00F6heren Punktestand werden zus\u00E4tzliche Kartentexturenpakete freigeschaltete\r\n\r\n\r\nSpielregeln\r\nAkionskarten:\r\n\r\n7 - zwei ziehen\r\n8 - Aussetzen\r\nBube - W\u00FCnscher\r\n\r\nZusatzregeln:\r\n\r\n9 - Richtungswechsel\r\n8 - Stopper hebt Aktionskarte 7 \"zwei ziehen\" auf\r\n10 - Allesleger (darf auf jede Karte gelegt werden)\r\n\r\n\r\nFeatures\r\n\r\nAutomatischer \"Jau\" Ausruf bei letzter Karte und \"JauJau\" beim Ablegen der letzten\r\nverschiedene Texturenpackete f\u00FCr Kartens\u00E4tze\r\n\r\n\r\nAnforderungen\r\n\r\nKompatibel mit verschieden Betriebssystemen\r\nSkalierung der GUI\r\nJava 11 Support");
|
||||
scrollPane.setViewportView(txtrJaujauJaujauIst);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,240 +1,119 @@
|
||||
package de.jaujau.gui;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Image;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JButton;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.JPanel;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.Icon;
|
||||
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
|
||||
import de.jaujau.daten.Spielerverwaltung;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import java.awt.Font;
|
||||
|
||||
public class Menue_GUI extends GUI implements ActionListener {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Spielerverwaltung spielerverwaltung;
|
||||
private JPanel contentPane;
|
||||
private boolean shown = true;
|
||||
public class Menue_GUI
|
||||
extends JPanel {
|
||||
|
||||
private CardLayout cardLayout;
|
||||
|
||||
private JPanel panel1, panel2, panel3;
|
||||
private int sizemenu = 270;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create the application.
|
||||
* @param speicherung
|
||||
*/
|
||||
// Konstruktor
|
||||
public Menue_GUI(Spielerverwaltung speicherung) {
|
||||
this.spielerverwaltung = speicherung;
|
||||
speicherung.getSpieler();
|
||||
System.out.println("Men<EFBFBD>-GUI aufgerufen");
|
||||
initialize(this.spielerverwaltung);
|
||||
|
||||
setBorder(javax.swing.BorderFactory.createTitledBorder("Content"));
|
||||
|
||||
cardLayout = new CardLayout();
|
||||
|
||||
this.setLayout(cardLayout);
|
||||
|
||||
// Objekte der Panel erzeugen, die angezeigt werden sollen
|
||||
panel1 = new JPanel();
|
||||
panel1.setName("panel1");
|
||||
panel2 = new JPanel();
|
||||
panel2.setName("panel2");
|
||||
panel3 = new JPanel();
|
||||
panel3.setName("panel3");
|
||||
|
||||
panel1.setBackground(Color.YELLOW);
|
||||
panel2.setBackground(Color.WHITE);
|
||||
panel3.setBackground(Color.GREEN);
|
||||
|
||||
JLabel label1 = new JLabel("Startseite");
|
||||
label1.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
JLabel label2 = new JLabel("Highscore");
|
||||
label2.setFont(new Font("Tahoma", Font.PLAIN, 18));
|
||||
label2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label2.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
|
||||
|
||||
renderHighscore(); //Highscore Tabelle wird geladen
|
||||
panel2.setVisible( true );
|
||||
|
||||
|
||||
|
||||
JLabel label3 = new JLabel("Panel 3: Spiel");
|
||||
panel2.add(label2, BorderLayout.NORTH);
|
||||
panel3.add(label3);
|
||||
|
||||
this.add(panel1, "Start");
|
||||
panel1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
||||
panel1.add(label1);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("New label");
|
||||
panel1.add(lblNewLabel_1);
|
||||
this.add(panel2, "Highscore");
|
||||
this.add(panel3, "Spiel");
|
||||
|
||||
JPanel panel4 = new JPanel();
|
||||
panel4.setBackground(Color.LIGHT_GRAY);
|
||||
this.add(panel4, "Einstellungen");
|
||||
|
||||
JLabel lblNewLabel = new JLabel("Einstellungen");
|
||||
panel4.add(lblNewLabel);
|
||||
|
||||
}
|
||||
/**
|
||||
* Initialize the contents of the frame.
|
||||
*/
|
||||
|
||||
//Test GUI f<>r JauJau
|
||||
|
||||
private void initialize(Spielerverwaltung speicherung) {
|
||||
this.spielerverwaltung = speicherung;
|
||||
setBounds(100, 100, 963, 762);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
getContentPane().setLayout(new BorderLayout(0, 0));
|
||||
setVisible(true);
|
||||
|
||||
JPanel panel_top = new JPanel();
|
||||
panel_top.setPreferredSize(new Dimension(200, 100));
|
||||
panel_top.setBackground(new Color(0, 0, 128));
|
||||
this.getContentPane().add(panel_top, BorderLayout.NORTH);
|
||||
panel_top.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("JauJau");
|
||||
lblNewLabel_1.setForeground(Color.WHITE);
|
||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_1.setInheritsPopupMenu(false);
|
||||
lblNewLabel_1.setIgnoreRepaint(false);
|
||||
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 40));
|
||||
lblNewLabel_1.setVerticalAlignment(SwingConstants.CENTER);
|
||||
panel_top.add(lblNewLabel_1, BorderLayout.CENTER);
|
||||
|
||||
JPanel panel_side = new JPanel();
|
||||
panel_side.setBackground(new Color(0, 51, 153));
|
||||
panel_side.setPreferredSize(new Dimension(270, 400));
|
||||
this.getContentPane().add(panel_side, BorderLayout.WEST);
|
||||
panel_side.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel panel_buttons = new JPanel();
|
||||
panel_buttons.setBackground(new Color(0, 0, 128));
|
||||
panel_buttons.setPreferredSize(new Dimension(50, 200));
|
||||
panel_side.add(panel_buttons, BorderLayout.WEST);
|
||||
panel_buttons.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBounds(0, 0, 50, 50);
|
||||
panel.setBackground(new Color(0, 0, 153));
|
||||
panel.setPreferredSize(new Dimension(50, 50));
|
||||
panel_buttons.add(panel);
|
||||
panel.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
|
||||
JLabel minimize = new JLabel("");
|
||||
minimize.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(shown == true) {
|
||||
panel_side.setPreferredSize(new Dimension(50, panel_side.getHeight()));
|
||||
System.out.println("Update GUI 50");
|
||||
panel_side.revalidate();
|
||||
panel_side.repaint();
|
||||
shown = false;
|
||||
}else{
|
||||
panel_side.setPreferredSize(new Dimension(270, panel_side.getHeight()));
|
||||
System.out.println("Update GUI 270");
|
||||
panel_side.revalidate();
|
||||
panel_side.repaint();
|
||||
shown = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
minimize.setPreferredSize(new Dimension(50, 50));
|
||||
minimize.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
minimize.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||
minimize.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
ImageIcon imageIcon = new ImageIcon(new ImageIcon("C:\\Users\\Elmar\\Pictures\\exit.png").getImage().getScaledInstance(40, 40, Image.SCALE_DEFAULT));
|
||||
minimize.setIcon(imageIcon);
|
||||
panel.add(minimize, BorderLayout.CENTER);
|
||||
public void showPanel(String panel) {
|
||||
|
||||
JPanel buttons = new JPanel();
|
||||
buttons.setBackground(new Color(51, 51, 153));
|
||||
panel_side.add(buttons, BorderLayout.CENTER);
|
||||
buttons.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel panel_4 = new JPanel();
|
||||
panel_4.setBackground(new Color(0, 51, 153));
|
||||
buttons.add(panel_4, BorderLayout.CENTER);
|
||||
panel_4.setLayout(null);
|
||||
|
||||
JLabel start = new JLabel("Spiel starten");
|
||||
start.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
//Spiel starten Spiel_GUI und schlie<69>e Menue_GUI (wechsel) und Spiellogikaufrufen
|
||||
System.out.println("Start Game");
|
||||
}
|
||||
});
|
||||
start.setBackground(Color.WHITE);
|
||||
start.setForeground(Color.WHITE);
|
||||
start.setFont(new Font("Segoe UI", Font.PLAIN, 26));
|
||||
start.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
start.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
start.setBounds(0, 0, 220, 31);
|
||||
panel_4.add(start);
|
||||
|
||||
JLabel score = new JLabel("Highscore");
|
||||
score.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
//Rechtes Panel <20>ndern und Highscore aus jaujaudaten abrufen.
|
||||
System.out.println("Highscore");
|
||||
}
|
||||
});
|
||||
score.setBackground(Color.WHITE);
|
||||
score.setForeground(Color.WHITE);
|
||||
score.setFont(new Font("Segoe UI", Font.PLAIN, 26));
|
||||
score.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
score.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
score.setBounds(0, 42, 220, 31);
|
||||
panel_4.add(score);
|
||||
|
||||
JLabel settings = new JLabel("Einstellungen");
|
||||
settings.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
//Rechtes Panel <20>ndern und Einstellungen aufrufen
|
||||
System.out.println("Highscore");
|
||||
}
|
||||
});
|
||||
settings.setBackground(Color.WHITE);
|
||||
settings.setForeground(Color.WHITE);
|
||||
settings.setFont(new Font("Segoe UI", Font.PLAIN, 26));
|
||||
settings.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
settings.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
settings.setBounds(0, 84, 220, 31);
|
||||
panel_4.add(settings);
|
||||
|
||||
JLabel help = new JLabel("Hilfe");
|
||||
help.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
//Starte Hilfe GUI Menue_GUI bleibt ge<67>ffnet
|
||||
System.out.println("Hilfe");
|
||||
}
|
||||
});
|
||||
help.setBackground(Color.WHITE);
|
||||
help.setForeground(Color.WHITE);
|
||||
help.setFont(new Font("Segoe UI", Font.PLAIN, 26));
|
||||
help.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
help.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
help.setBounds(0, 126, 220, 31);
|
||||
panel_4.add(help);
|
||||
|
||||
JPanel panel_main = new JPanel();
|
||||
panel_main.setPreferredSize(new Dimension(600, 600));
|
||||
this.getContentPane().add(panel_main, BorderLayout.CENTER);
|
||||
panel_main.setLayout(new BoxLayout(panel_main, BoxLayout.X_AXIS));
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_1.setBackground(new Color(102, 153, 255));
|
||||
panel_main.add(panel_1);
|
||||
panel_1.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel panel_2 = new JPanel();
|
||||
panel_2.setBackground(new Color(51, 153, 204));
|
||||
panel_1.add(panel_2, BorderLayout.CENTER);
|
||||
panel_2.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("Name: ");
|
||||
lblNewLabel_2.setForeground(Color.WHITE);
|
||||
lblNewLabel_2.setFont(new Font("Segoe UI", Font.PLAIN, 26));
|
||||
lblNewLabel_2.setBackground(new Color(51, 153, 204));
|
||||
panel_2.add(lblNewLabel_2, BorderLayout.NORTH);
|
||||
lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblNewLabel_2.setVerticalAlignment(SwingConstants.TOP);
|
||||
lblNewLabel_2.setText("Name: " + speicherung.getName());
|
||||
|
||||
JPanel panel_3 = new JPanel();
|
||||
panel_3.setBackground(new Color(51, 153, 204));
|
||||
panel_2.add(panel_3, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
cardLayout.show(this, panel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void renderHighscore() {
|
||||
|
||||
String[][] rowData = {{ "Seb", "245" }, { "Elmo", "240" }, { "Moritz","220" }, { "Alaa Aldin", "217" }, {"Fabian", "215"}}; //Bsp. Datensatz muss noch entfernt werden.
|
||||
|
||||
String[] columnNames = {"Name", "Punkte"};
|
||||
panel2.setLayout(new BorderLayout(0, 0));
|
||||
JTable table = new JTable(); //Leere Tabelle
|
||||
DefaultTableModel tableModel = new DefaultTableModel(rowData, columnNames) { //Tabelle formatieren und Zellen nicht bearbeitbar machen
|
||||
private static final long serialVersionUID = 838285314713L;
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
//all cells false
|
||||
return false;
|
||||
}
|
||||
};
|
||||
table.setAutoCreateRowSorter(true); //Tabelle Sortierbar durch Tabellenkopf
|
||||
table.getTableHeader().setReorderingAllowed(false); //Tabelle nicht mehr drag and drop
|
||||
table.setModel(tableModel);
|
||||
|
||||
|
||||
panel2.add( new JScrollPane( table ) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
148
src/de/jaujau/gui/Navigation_GUI.java
Normal file
@@ -0,0 +1,148 @@
|
||||
package de.jaujau.gui;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Image;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import java.awt.Component;
|
||||
import javax.swing.GroupLayout;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.Insets;
|
||||
|
||||
|
||||
public class Navigation_GUI
|
||||
extends JPanel
|
||||
implements ActionListener {
|
||||
private JPanel panel;
|
||||
private Menue_GUI Menue_GUI;
|
||||
|
||||
// Konstruktor
|
||||
public Navigation_GUI(Menue_GUI menue_GUI) {
|
||||
this.Menue_GUI = menue_GUI;
|
||||
|
||||
// Hiermit bekommst du Zugriff auf das <20>bergebene Objekt mainPanel
|
||||
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
||||
|
||||
panel = new JPanel();
|
||||
panel.setBackground(new Color(102, 153, 204));
|
||||
add(panel);
|
||||
panel.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel panel_side = new JPanel();
|
||||
panel_side.setBackground(new Color(100, 149, 237));
|
||||
panel_side.setPreferredSize(new Dimension(200, 400));
|
||||
panel.add(panel_side, BorderLayout.CENTER);
|
||||
panel_side.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel panel_buttons = new JPanel();
|
||||
panel_buttons.setBackground(new Color(0, 0, 128));
|
||||
panel_buttons.setPreferredSize(new Dimension(50, 200));
|
||||
panel_side.add(panel_buttons, BorderLayout.WEST);
|
||||
panel_buttons.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
|
||||
panel.setBackground(new Color(0, 0, 153));
|
||||
panel.setPreferredSize(new Dimension(50, 50));
|
||||
panel_buttons.add(panel, BorderLayout.NORTH);
|
||||
panel.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
|
||||
JLabel lblNewLabel = new JLabel("");
|
||||
lblNewLabel.setPreferredSize(new Dimension(50, 50));
|
||||
lblNewLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
lblNewLabel.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
ImageIcon imageIcon = new ImageIcon(new ImageIcon("C:\\Users\\Elmar\\Pictures\\exit.png").getImage().getScaledInstance(40, 40, Image.SCALE_DEFAULT));
|
||||
lblNewLabel.setIcon(imageIcon);
|
||||
panel.add(lblNewLabel, BorderLayout.CENTER);
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_side.add(panel_1, BorderLayout.CENTER);
|
||||
|
||||
JPanel panel_2 = new JPanel();
|
||||
panel_2.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
Menue_GUI.showPanel("Start");
|
||||
}
|
||||
});
|
||||
panel_2.setBackground(new Color(0, 102, 204));
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("Start");
|
||||
lblNewLabel_1.setBackground(new Color(0, 102, 204));
|
||||
lblNewLabel_1.setForeground(Color.WHITE);
|
||||
lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 20));
|
||||
panel_2.add(lblNewLabel_1);
|
||||
|
||||
JLabel label = new JLabel("");
|
||||
|
||||
JPanel panel_3 = new JPanel();
|
||||
panel_3.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
Menue_GUI.showPanel("Highscore");
|
||||
}
|
||||
});
|
||||
panel_3.setBackground(new Color(0, 102, 204));
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("Highscore");
|
||||
lblNewLabel_2.setForeground(new Color(255, 255, 255));
|
||||
lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 20));
|
||||
panel_3.add(lblNewLabel_2);
|
||||
panel_1.setLayout(new GridLayout(0, 1, 0, 0));
|
||||
panel_1.add(panel_2);
|
||||
|
||||
JLabel label_1 = new JLabel("");
|
||||
panel_1.add(label_1);
|
||||
|
||||
JLabel label_2 = new JLabel("");
|
||||
panel_1.add(label_2);
|
||||
panel_1.add(label);
|
||||
panel_1.add(panel_3);
|
||||
|
||||
|
||||
//Schlie<69>e Button Panel
|
||||
panel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
panel_1.setVisible(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// In dieser Methode <20>nderst du das anzuzeigende Panel
|
||||
// <20>ber die showPanel-Methode in mainPanel
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
|
||||
if(e.getActionCommand().equals("Highscore"))
|
||||
Menue_GUI.showPanel("Highscore");
|
||||
|
||||
if(e.getActionCommand().equals("Spiel"))
|
||||
Menue_GUI.showPanel("Spiel");
|
||||
|
||||
if(e.getActionCommand().equals("Einstellungen"))
|
||||
Menue_GUI.showPanel("Einstellungen");
|
||||
}
|
||||
}
|
@@ -1,34 +1,65 @@
|
||||
package de.jaujau.gui;
|
||||
import java.awt.Image;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.BoxLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import java.util.*;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import de.jaujau.daten.Kartensatz;
|
||||
import de.jaujau.daten.Spielerverwaltung;
|
||||
import de.jaujau.daten.Texturenpakete;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class Spiel_GUI extends JPanel implements ActionListener {
|
||||
|
||||
/**
|
||||
* Class Spiel_GUI
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Spielerverwaltung spielerverwaltung;
|
||||
Texturenpakete texturen = new Texturenpakete();
|
||||
/**
|
||||
* Create the application.
|
||||
* @param speicherung
|
||||
*/
|
||||
public Spiel_GUI() {
|
||||
setLayout(null);
|
||||
System.out.println("Spiel_GUI: Spiel-GUI aufgerufen");
|
||||
initialize(spielerverwaltung);
|
||||
}
|
||||
/**
|
||||
* Initialize the contents of the frame.
|
||||
*/
|
||||
public class Spiel_GUI {
|
||||
|
||||
//
|
||||
// Fields
|
||||
//
|
||||
//Test GUI f<>r JauJau
|
||||
|
||||
private void initialize(Spielerverwaltung speicherung) {
|
||||
this.spielerverwaltung = speicherung;
|
||||
setBounds(100, 100, 963, 762);
|
||||
JPanel panel_main = new JPanel();
|
||||
panel_main.setPreferredSize(new Dimension(600, 600));;
|
||||
panel_main.setLayout(new BoxLayout(panel_main, BoxLayout.X_AXIS));
|
||||
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public Spiel_GUI () { };
|
||||
texturen.addPaket("StandartTexturenBeta3.zip");
|
||||
texturen.setAktivesPaket(0);
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Accessor methods
|
||||
//
|
||||
|
||||
//
|
||||
// Other methods
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
g.drawImage(texturen.getTextur(31), 50, 50, null);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,24 @@
|
||||
/**
|
||||
|
||||
* @author Alaa Aldin
|
||||
|
||||
* @version 1.0
|
||||
|
||||
*/
|
||||
package de.jaujau.spiellogik;
|
||||
|
||||
import de.jaujau.daten.Spielerverwaltung;
|
||||
import de.jaujau.daten.Texturenpakete;
|
||||
import de.jaujau.gui.GUI;
|
||||
import de.jaujau.gui.Menue_GUI;
|
||||
|
||||
//import de.jaujau.gui.Menue_GUI;
|
||||
//import de.jaujau.gui.Spiel_GUI;
|
||||
|
||||
public class Anwendung {
|
||||
|
||||
private Spiel aktuellesSpiel;
|
||||
private Texturenpakete texturenpakete;
|
||||
private Spielerverwaltung speicherung;
|
||||
private static Menue_GUI gui;
|
||||
private GUI gui;
|
||||
|
||||
//
|
||||
// Constructors
|
||||
@@ -19,7 +26,7 @@ public class Anwendung {
|
||||
public Anwendung() {
|
||||
|
||||
speicherung = new Spielerverwaltung();
|
||||
gui = new Menue_GUI(speicherung);
|
||||
gui = new GUI(speicherung);
|
||||
|
||||
};
|
||||
//
|
||||
@@ -82,51 +89,23 @@ public class Anwendung {
|
||||
return speicherung;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of gui
|
||||
*
|
||||
* @param newVar the new value of gui
|
||||
*/
|
||||
public static void setGui(Menue_GUI newVar) {
|
||||
gui = newVar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of gui
|
||||
* @return the value of gui
|
||||
*/
|
||||
public static GUI getGui () {
|
||||
return gui;
|
||||
}
|
||||
|
||||
//
|
||||
// Other methods
|
||||
//
|
||||
public static void openGui() { // GUI oeffnen!
|
||||
Anwendung jaujau = new Anwendung();
|
||||
public static void openMenue_GUI(Anwendung jaujau) { // Menue_GUI oeffnen!
|
||||
jaujau.gui.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
openGui();
|
||||
|
||||
//
|
||||
// Other methods
|
||||
//
|
||||
Anwendung jaujau = new Anwendung();
|
||||
openMenue_GUI(jaujau);
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
|
||||
/*public static void main(String[] args)
|
||||
{
|
||||
System.out.println("Programm gestartet");
|
||||
Anwendung jaujau = new Anwendung();
|
||||
jaujau.gui.setVisible(true);
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
BIN
src/img/exit.png
Normal file
After Width: | Height: | Size: 505 B |
BIN
src/img/help.png
Normal file
After Width: | Height: | Size: 357 B |
BIN
src/img/max.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
src/img/menue.png
Normal file
After Width: | Height: | Size: 696 B |
BIN
src/img/min.png
Normal file
After Width: | Height: | Size: 360 B |
BIN
src/img/texturen/standart/0.png
Executable file
After Width: | Height: | Size: 9.4 KiB |
BIN
src/img/texturen/standart/1.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
src/img/texturen/standart/10.png
Executable file
After Width: | Height: | Size: 20 KiB |
BIN
src/img/texturen/standart/11.png
Executable file
After Width: | Height: | Size: 21 KiB |
BIN
src/img/texturen/standart/12.png
Executable file
After Width: | Height: | Size: 18 KiB |
BIN
src/img/texturen/standart/13.png
Executable file
After Width: | Height: | Size: 23 KiB |
BIN
src/img/texturen/standart/14.png
Executable file
After Width: | Height: | Size: 43 KiB |
BIN
src/img/texturen/standart/15.png
Executable file
After Width: | Height: | Size: 7.4 KiB |
BIN
src/img/texturen/standart/16.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
src/img/texturen/standart/17.png
Executable file
After Width: | Height: | Size: 13 KiB |
BIN
src/img/texturen/standart/18.png
Executable file
After Width: | Height: | Size: 14 KiB |
BIN
src/img/texturen/standart/19.png
Executable file
After Width: | Height: | Size: 13 KiB |
BIN
src/img/texturen/standart/2.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
src/img/texturen/standart/20.png
Executable file
After Width: | Height: | Size: 35 KiB |
BIN
src/img/texturen/standart/21.png
Executable file
After Width: | Height: | Size: 50 KiB |
BIN
src/img/texturen/standart/22.png
Executable file
After Width: | Height: | Size: 45 KiB |
BIN
src/img/texturen/standart/23.png
Executable file
After Width: | Height: | Size: 14 KiB |
BIN
src/img/texturen/standart/24.png
Executable file
After Width: | Height: | Size: 23 KiB |
BIN
src/img/texturen/standart/25.png
Executable file
After Width: | Height: | Size: 26 KiB |
BIN
src/img/texturen/standart/26.png
Executable file
After Width: | Height: | Size: 30 KiB |
BIN
src/img/texturen/standart/27.png
Executable file
After Width: | Height: | Size: 30 KiB |
BIN
src/img/texturen/standart/28.png
Executable file
After Width: | Height: | Size: 35 KiB |
BIN
src/img/texturen/standart/29.png
Executable file
After Width: | Height: | Size: 50 KiB |
BIN
src/img/texturen/standart/3.png
Executable file
After Width: | Height: | Size: 12 KiB |
BIN
src/img/texturen/standart/30.png
Executable file
After Width: | Height: | Size: 45 KiB |
BIN
src/img/texturen/standart/31.png
Executable file
After Width: | Height: | Size: 14 KiB |
BIN
src/img/texturen/standart/32.png
Executable file
After Width: | Height: | Size: 64 KiB |
BIN
src/img/texturen/standart/4.png
Executable file
After Width: | Height: | Size: 33 KiB |
BIN
src/img/texturen/standart/5.png
Executable file
After Width: | Height: | Size: 47 KiB |
BIN
src/img/texturen/standart/6.png
Executable file
After Width: | Height: | Size: 42 KiB |
BIN
src/img/texturen/standart/7.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
src/img/texturen/standart/8.png
Executable file
After Width: | Height: | Size: 16 KiB |
BIN
src/img/texturen/standart/9.png
Executable file
After Width: | Height: | Size: 20 KiB |