Textur GUI Kommentiert und Lavel Anzeige zuzugefügt
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
package de.jaujau.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
@@ -20,16 +19,23 @@ import javax.swing.JFileChooser;
|
||||
|
||||
/**
|
||||
* Klasse texturenauswaehlen_GUI
|
||||
* @author Sebastian Kacza
|
||||
* Diese Klasse erstelt ein Fenster für die Texturenpaket auswahl
|
||||
*/
|
||||
public class texturenauswaehlen_GUI extends JFrame{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JPanel contentPane;
|
||||
private Texturenpakete pakete;
|
||||
private JComboBox comboBox;
|
||||
private JComboBox<String> comboBox;
|
||||
private JLabel vorschaubild;
|
||||
private JButton speichern, hinzufuegen, schliessen;
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor fpr das Fenster
|
||||
* @param texturenpakete
|
||||
*/
|
||||
public texturenauswaehlen_GUI (Texturenpakete texturenpakete) {
|
||||
pakete = texturenpakete;
|
||||
erstelleFenster();
|
||||
@@ -37,6 +43,9 @@ public class texturenauswaehlen_GUI extends JFrame{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Erstelt alle komponenten des Fensters
|
||||
*/
|
||||
private void erstelleFenster() {
|
||||
//Fenster größen fetslegen
|
||||
setAlwaysOnTop(true);
|
||||
@@ -81,13 +90,19 @@ public class texturenauswaehlen_GUI extends JFrame{
|
||||
|
||||
|
||||
//Auswahl Box
|
||||
comboBox = new JComboBox();
|
||||
comboBox = new JComboBox<String>();
|
||||
comboBox.setBounds(117, 69, 351, 25);
|
||||
contentPane.add(comboBox);
|
||||
|
||||
aktualisiereInhalt();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Öffent einen auswahl dialog zu Öfnnen einer Datei
|
||||
* Beo klick auf OK wird das Paket hinzugefügt
|
||||
*/
|
||||
private void paketHinzufuegeb() {
|
||||
//Quelle: https://www.java-tutorial.org/jfilechooser.html
|
||||
|
||||
@@ -101,31 +116,43 @@ public class texturenauswaehlen_GUI extends JFrame{
|
||||
pakete.addPaket(chooser.getSelectedFile().toString());
|
||||
aktualisiereInhalt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Schießt das Auswahlfenster
|
||||
*/
|
||||
private void schliessen() {
|
||||
this.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Speichert die Auswahl des akutellen Paketes
|
||||
*/
|
||||
private void speichern() {
|
||||
pakete.setAktivesPaket(comboBox.getSelectedIndex());
|
||||
aktualisiereBild();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Aktualaiset die Inhalte der ComboBox
|
||||
*/
|
||||
private void aktualisiereInhalt() {
|
||||
comboBox.removeAllItems();
|
||||
for(int i = 0; i < pakete.getAnzahlPakete(); i++) {
|
||||
comboBox.addItem(pakete.getName(i));
|
||||
comboBox.addItem(pakete.getName(i) + " [Level " + pakete.getLevel(i) + "]");
|
||||
}
|
||||
comboBox.setSelectedIndex(pakete.getAktivesPaket());
|
||||
aktualisiereBild();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Aktualisiert das Vorschaubild
|
||||
*/
|
||||
private void aktualisiereBild() {
|
||||
vorschaubild.setIcon(new ImageIcon(pakete.getTextur(32).getScaledInstance(150, 210, Image.SCALE_SMOOTH)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user