Exceptions, die nicht anders verarbeitet werden können, werden jetzt mit
einem Message-Dialog abgefangen.
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
package de.katho.kBorrow;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
import de.katho.kBorrow.db.DbConnector;
|
||||
import de.katho.kBorrow.db.SqlConnector;
|
||||
import de.katho.kBorrow.db.SqliteConnector;
|
||||
import de.katho.kBorrow.gui.MainWindow;
|
||||
|
||||
public class Main {
|
||||
private DbConnector dbCon;
|
||||
private Settings set;
|
||||
|
||||
public static void main(String[] args){
|
||||
new Main();
|
||||
}
|
||||
|
||||
public Main(){
|
||||
/*
|
||||
* Create the apps main window.
|
||||
*/
|
||||
this.set = new Settings();
|
||||
|
||||
if(set.getProperty("dBType").equals("sqlite")){
|
||||
try {
|
||||
this.dbCon = new SqliteConnector(set.getProperty("sqlitePath"));
|
||||
} catch (ClassNotFoundException | SQLException | IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
else if(set.getProperty("dBType").equals("mysql")) {
|
||||
this.dbCon = new SqlConnector();
|
||||
}
|
||||
try {
|
||||
new MainWindow(this.dbCon);
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | UnsupportedLookAndFeelException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,19 @@
|
||||
package de.katho.kBorrow.gui;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import de.katho.kBorrow.Settings;
|
||||
import de.katho.kBorrow.db.DbConnector;
|
||||
import de.katho.kBorrow.db.SqlConnector;
|
||||
import de.katho.kBorrow.db.SqliteConnector;
|
||||
|
||||
|
||||
public class MainWindow {
|
||||
@@ -19,7 +24,8 @@ public class MainWindow {
|
||||
private JFrame frame;
|
||||
private JTabbedPane tabbedPane;
|
||||
|
||||
|
||||
|
||||
private Settings set;
|
||||
|
||||
/**
|
||||
* Create the application.
|
||||
@@ -29,33 +35,39 @@ public class MainWindow {
|
||||
* @throws ClassNotFoundException
|
||||
* @throws IOException
|
||||
*/
|
||||
public MainWindow(DbConnector pDbCon) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, IOException {
|
||||
this.dbCon = pDbCon;
|
||||
initialize();
|
||||
this.frame.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the contents of the frame.
|
||||
* @throws UnsupportedLookAndFeelException
|
||||
* @throws IllegalAccessException
|
||||
* @throws InstantiationException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws IOException
|
||||
*/
|
||||
private void initialize() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, IOException {
|
||||
public MainWindow() {
|
||||
this.set = new Settings();
|
||||
this.frame = new JFrame();
|
||||
this.frame.setResizable(false);
|
||||
this.frame.setBounds(100, 100, 600, 500);
|
||||
this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
|
||||
this.tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
this.frame.getContentPane().add(this.tabbedPane, BorderLayout.CENTER);
|
||||
try {
|
||||
if(set.getProperty("dBType").equals("sqlite")){
|
||||
this.dbCon = new SqliteConnector(set.getProperty("sqlitePath"));
|
||||
}
|
||||
else if(set.getProperty("dBType").equals("mysql")) {
|
||||
this.dbCon = new SqlConnector();
|
||||
}
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
|
||||
this.tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
this.frame.getContentPane().add(this.tabbedPane, BorderLayout.CENTER);
|
||||
this.tabbedPane.addTab("Neue Ausleihe", new NewLendingTab(this.dbCon));
|
||||
this.tabbedPane.addTab("Ausleihen verwalten", new ManageLendingTab(this.dbCon));
|
||||
this.tabbedPane.addTab("Artikel verwalten", new ArticleTab(this.dbCon));
|
||||
this.tabbedPane.addTab("Benutzer verwalten", new UserTab(this.dbCon));
|
||||
|
||||
}
|
||||
catch(ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | UnsupportedLookAndFeelException | SQLException e) {
|
||||
JOptionPane.showMessageDialog(this.frame, e.getStackTrace(), "Fatal error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
this.tabbedPane.addTab("Neue Ausleihe", new NewLendingTab(this.dbCon));
|
||||
this.tabbedPane.addTab("Ausleihen verwalten", new ManageLendingTab(this.dbCon));
|
||||
this.tabbedPane.addTab("Artikel verwalten", new ArticleTab(this.dbCon));
|
||||
this.tabbedPane.addTab("Benutzer verwalten", new UserTab(this.dbCon));
|
||||
this.frame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
new MainWindow();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user