This commit is contained in:
Sebastian Kacza
2021-01-08 15:28:37 +01:00
parent a316f1fd09
commit 1682e72045
2 changed files with 65 additions and 3 deletions

View File

@@ -0,0 +1,27 @@
package de.jaujau.UnitTests;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import de.jaujau.daten.Texturenpakete;
import de.jaujau.gui.texturenauswaehlen_GUI;
class TEST_TexturenGUI {
private Texturenpakete pakete;
private texturenauswaehlen_GUI gui;
@BeforeEach
void setUp() throws Exception {
texturenauswaehlen_GUI gui = new texturenauswaehlen_GUI(pakete);
}
@Test
void test() {
//fail("Not yet implemented");
gui.setVisible(true);
}
}

View File

@@ -13,6 +13,7 @@ import javax.swing.border.EmptyBorder;
import de.jaujau.daten.Texturenpakete;
import javax.swing.JList;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
/**
* Klasse texturenauswaehlen_GUI
@@ -22,6 +23,7 @@ public class texturenauswaehlen_GUI extends JFrame{
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private Texturenpakete pakete;
private JComboBox comboBox;
private JButton ok, hinzufuegen, entfernen;
@@ -56,21 +58,54 @@ public class texturenauswaehlen_GUI extends JFrame{
//Teste Entfernen
entfernen = new JButton("Entfernen");
entfernen.setBounds(291, 129, 140, 25);
entfernen.addActionListener(e-> paketHinzufuegeb());
entfernen.addActionListener(e-> paketEntfernen());
contentPane.add(entfernen);
//Teste OK
ok = new JButton("Speicher");
ok.setBounds(358, 239, 73, 23);
ok.addActionListener(e-> paketHinzufuegeb());
ok.addActionListener(e-> speichern());
contentPane.add(ok);
JComboBox comboBox = new JComboBox();
comboBox = new JComboBox();
comboBox.setBounds(144, 73, 287, 25);
contentPane.add(comboBox);
aktualisiereBox();
}
private void paketHinzufuegeb() {
//Quelle: https://www.java-tutorial.org/jfilechooser.html
// JFileChooser-Objekt erstellen
JFileChooser chooser = new JFileChooser();
// Dialog zum Oeffnen von Dateien anzeigen
int chooseroption = chooser.showOpenDialog(null);
// Abfrage, ob auf "Öffnen" geklickt wurde
if(chooseroption == JFileChooser.APPROVE_OPTION)
{
//data.loadInputtext(chooser.getSelectedFile());
//refresh_textbox();
pakete.addPaket(chooser.getSelectedFile().toString());
aktualisiereBox();
}
}
private void paketEntfernen() {
}
private void speichern() {
pakete.setAktivesPaket(comboBox.getSelectedIndex());
this.setVisible(false);
}
private void aktualisiereBox() {
comboBox.removeAllItems();
for(int i = 0; i < pakete.getAnzahlPakete(); i++) {
comboBox.addItem(pakete.getName(i));
}
comboBox.setSelectedIndex(pakete.getAktivesPaket());
}
}