This commit is contained in:
PaulK 2023-01-31 18:22:18 +01:00
parent 4fca90af4b
commit 6f5579f2cc
4 changed files with 19 additions and 13 deletions

View File

@ -32,7 +32,10 @@ public class Einzelansicht extends JFrame implements TableModelListener {
this.setSize(500, 400); this.setSize(500, 400);
this.setResizable(false); this.setResizable(false);
this.setLayout(null); this.setLayout(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
tab = ta; tab = ta;
this.setTitle(tab);
try (Connection conn = DriverManager.getConnection(url, "root", "")) { try (Connection conn = DriverManager.getConnection(url, "root", "")) {
Statement s = conn.createStatement(); Statement s = conn.createStatement();
@ -45,7 +48,7 @@ public class Einzelansicht extends JFrame implements TableModelListener {
} }
vor = new JButton("Weiter"); vor = new JButton("Weiter");
vor.setBounds(300, 150, 90, 50); vor.setBounds(350, 150, 90, 50);
vor.setFont(font); vor.setFont(font);
vor.setBackground(Color.white); vor.setBackground(Color.white);
vor.setForeground(Color.black); vor.setForeground(Color.black);
@ -61,13 +64,13 @@ public class Einzelansicht extends JFrame implements TableModelListener {
this.add(vor); this.add(vor);
zur = new JButton("Letzte"); zur = new JButton("Letzte");
zur.setBounds(150, 150, 90, 50); zur.setBounds(80, 150, 90, 50);
zur.setFont(font); zur.setFont(font);
zur.setBackground(Color.white); zur.setBackground(Color.white);
zur.setForeground(Color.black); zur.setForeground(Color.black);
zur.addActionListener(e -> { zur.addActionListener(e -> {
if(i>1){ if (i > 1) {
i--; i--;
} }
try { try {
sql = "Select * From " + tab + " Where " + rm.getColumnName(1) + " =" + i; sql = "Select * From " + tab + " Where " + rm.getColumnName(1) + " =" + i;
@ -85,7 +88,7 @@ public class Einzelansicht extends JFrame implements TableModelListener {
this.add(sc); this.add(sc);
a = new JButton("Zurück"); a = new JButton("Zurück");
a.setBounds(50, 30, 70, 50); a.setBounds(50, 30, 80, 50);
a.setForeground(Color.BLACK); a.setForeground(Color.BLACK);
a.setBackground(Color.white); a.setBackground(Color.white);
a.setFont(font); a.setFont(font);
@ -116,7 +119,7 @@ public class Einzelansicht extends JFrame implements TableModelListener {
del.setBackground(Color.white); del.setBackground(Color.white);
del.setFont(font); del.setFont(font);
del.addActionListener(e -> { del.addActionListener(e -> {
System.out.println(t.getValueAt(0,0)); System.out.println(t.getValueAt(0, 0));
String wh = t.getValueAt(0, 0).toString(); String wh = t.getValueAt(0, 0).toString();
int response = JOptionPane.showConfirmDialog(null, "Wollen Sie den Eintrag löschen?", "Bestätigen", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); int response = JOptionPane.showConfirmDialog(null, "Wollen Sie den Eintrag löschen?", "Bestätigen", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response == 0) { if (response == 0) {
@ -210,16 +213,17 @@ public class Einzelansicht extends JFrame implements TableModelListener {
} else { } else {
try { try {
for (int j = 1; j <= rm.getColumnCount(); j++) { for (int j = 1; j <= rm.getColumnCount(); j++) {
System.out.println(sq);
if (j == rm.getColumnCount()) { if (j == rm.getColumnCount()) {
sq = sq + rm.getColumnName(j) + " LIKE '%" + st + "%'"; sq = sq + rm.getColumnName(j) + " LIKE '%" + st + "%'";
} else { } else {
sq = sq + rm.getColumnName(j) + " LIKE '%" + st + "%' or "; sq = sq + rm.getColumnName(j) + " LIKE '%" + st + "%' or ";
} }
} }
sql="Select * FROm "+tab+ " Where "+sq; sql = "SELECT * FROM " + tab + " WHERE " + sq;
System.out.println(sql); System.out.println(sql);
einfügen(tab,sql); einfügen(tab, sql);
sq = "";
sql = "";
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -233,7 +237,7 @@ public class Einzelansicht extends JFrame implements TableModelListener {
public void tableChanged(TableModelEvent e) { public void tableChanged(TableModelEvent e) {
int zeile = table.getSelectedRow(); int zeile = table.getSelectedRow();
int spalte = table.getSelectedColumn(); int spalte = table.getSelectedColumn();
if (spalte > 0 && zeile > 0) { if (spalte > 0) {
int response = 0; int response = 0;
try { try {
response = JOptionPane.showConfirmDialog(null, "Wollen Sie dein Eintrag in Zeile " + (zeile + 1) + ", Spalte :" + (rm.getColumnName(spalte + 1)) + " ändern?", "Bestätigen", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); response = JOptionPane.showConfirmDialog(null, "Wollen Sie dein Eintrag in Zeile " + (zeile + 1) + ", Spalte :" + (rm.getColumnName(spalte + 1)) + " ändern?", "Bestätigen", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

View File

@ -20,6 +20,7 @@ public class Menu extends JFrame implements ActionListener {
this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLayout(null); this.setLayout(null);
this.setBackground(Color.WHITE); this.setBackground(Color.WHITE);
this.setTitle("Bundesliga");
JLabel lbl = new JLabel(""); JLabel lbl = new JLabel("");
ImageIcon img = new ImageIcon(new ImageIcon(Menu.class.getResource("/image/Bundesiga.jfif")).getImage()); ImageIcon img = new ImageIcon(new ImageIcon(Menu.class.getResource("/image/Bundesiga.jfif")).getImage());
@ -68,7 +69,7 @@ public class Menu extends JFrame implements ActionListener {
DefaultListModel liste = new DefaultListModel(); DefaultListModel liste = new DefaultListModel();
list = new JList(liste); list = new JList(liste);
list.addListSelectionListener(e -> { list.addListSelectionListener(e -> {
if (list.getSelectedValue().toString().equalsIgnoreCase("Verein") || list.getSelectedValue().toString().equalsIgnoreCase("test")) { if (list.getSelectedValue().toString().equalsIgnoreCase("Verein") || list.getSelectedValue().toString().equalsIgnoreCase("spieler")) {
this.add(v); this.add(v);
} else } else

View File

@ -40,7 +40,7 @@ public class Tabellen extends JFrame implements TableModelListener {
this.add(sc); this.add(sc);
a = new JButton("Zurück"); a = new JButton("Zurück");
a.setBounds(50, 30, 70, 50); a.setBounds(50, 30, 80, 50);
a.setForeground(Color.BLACK); a.setForeground(Color.BLACK);
a.setBackground(Color.white); a.setBackground(Color.white);
a.setFont(font); a.setFont(font);
@ -158,7 +158,8 @@ public class Tabellen extends JFrame implements TableModelListener {
public void tableChanged(TableModelEvent e) { public void tableChanged(TableModelEvent e) {
int zeile = table.getSelectedRow(); int zeile = table.getSelectedRow();
int spalte = table.getSelectedColumn(); int spalte = table.getSelectedColumn();
if (spalte > 0 && zeile > 0) { System.out.println(zeile+" "+ spalte);
if (spalte > 0 || zeile > 0) {
int response = 0; int response = 0;
try { try {
response = JOptionPane.showConfirmDialog(null, "Wollen Sie dein Eintrag in Zeile " + (zeile + 1) + ", Spalte :" + (rm.getColumnName(spalte + 1)) + " ändern?", "Bestätigen", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); response = JOptionPane.showConfirmDialog(null, "Wollen Sie dein Eintrag in Zeile " + (zeile + 1) + ", Spalte :" + (rm.getColumnName(spalte + 1)) + " ändern?", "Bestätigen", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);