Icons werden in Buttons verwendet.

This commit is contained in:
socrates
2014-10-28 23:37:19 +01:00
parent 6c2ec72fcf
commit 1f4b81ac81
12 changed files with 68 additions and 31 deletions

View File

@@ -8,4 +8,8 @@ kBorrow is going to be a simple application to manage items that have been borro
This software uses the Xerial SQLite JDBC (https://bitbucket.org/xerial/sqlite-jdbc). The SQLite JDBC follows the Apache License Version 2.0 (http://www.apache.org/licenses/) This software uses the Xerial SQLite JDBC (https://bitbucket.org/xerial/sqlite-jdbc). The SQLite JDBC follows the Apache License Version 2.0 (http://www.apache.org/licenses/)
### MySQL Connector ### MySQL Connector
This software uses the Oracle MySQL Java Connector (http://dev.mysql.com/downloads/connector/j/). The MySQL Java Connector is provided under the GPL License Version 2.0 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html). This software uses the Oracle MySQL Java Connector (http://dev.mysql.com/downloads/connector/j/). The MySQL Java Connector is provided under the GPL License Version 2.0 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
### Tango Desktop Project
This software also uses icons provided by the Tango Desktop Project (http://tango.freedesktop.org/).
License will follow!

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -39,7 +39,7 @@ public class Main {
} }
try { try {
new MainWindow(this.dbCon); new MainWindow(this.dbCon);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
System.exit(1); System.exit(1);

View File

@@ -5,6 +5,7 @@ import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JButton; import javax.swing.JButton;
@@ -35,8 +36,9 @@ public class ArticleTab extends JPanel implements ActionListener {
/** /**
* Create the panel. * Create the panel.
* @throws IOException
*/ */
public ArticleTab(final DbConnector dbCon) { public ArticleTab(final DbConnector dbCon) throws IOException {
super(); super();
this.setLayout(null); this.setLayout(null);
@@ -45,14 +47,18 @@ public class ArticleTab extends JPanel implements ActionListener {
*/ */
this.articleTableModel = new ArticleTableModel(dbCon); this.articleTableModel = new ArticleTableModel(dbCon);
JTable articleTable = new JTable(articleTableModel); JTable articleTable = new JTable(articleTableModel);
articleTable.setRowHeight(30);
ArticleDeleteTableButton articleDeleteTableButton = new ArticleDeleteTableButton("L<EFBFBD>schen", articleTable); ArticleDeleteTableButton articleDeleteTableButton = new ArticleDeleteTableButton("L<EFBFBD>schen", articleTable);
ArticleEditTableButton articleEditTableButton = new ArticleEditTableButton("Bearbeiten", articleTable, this); ArticleEditTableButton articleEditTableButton = new ArticleEditTableButton("Bearbeiten", articleTable, this);
articleTable.getColumnModel().getColumn(4).setCellEditor(articleDeleteTableButton); for (int i = 3; i <= 4; i++){
articleTable.getColumnModel().getColumn(4).setCellRenderer(articleDeleteTableButton); articleTable.getColumnModel().getColumn(i).setCellEditor(i == 3 ? articleEditTableButton : articleDeleteTableButton);
articleTable.getColumnModel().getColumn(i).setCellRenderer(i == 3 ? articleEditTableButton : articleDeleteTableButton);
articleTable.getColumnModel().getColumn(3).setCellEditor(articleEditTableButton);
articleTable.getColumnModel().getColumn(3).setCellRenderer(articleEditTableButton); articleTable.getColumnModel().getColumn(i).setMinWidth(30);
articleTable.getColumnModel().getColumn(i).setMaxWidth(30);
articleTable.getColumnModel().getColumn(i).setPreferredWidth(30);
}
articleTable.setFillsViewportHeight(true); articleTable.setFillsViewportHeight(true);

View File

@@ -6,6 +6,7 @@ import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException; import javax.swing.UnsupportedLookAndFeelException;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.io.IOException;
import de.katho.kBorrow.db.DbConnector; import de.katho.kBorrow.db.DbConnector;
@@ -26,8 +27,9 @@ public class MainWindow {
* @throws IllegalAccessException * @throws IllegalAccessException
* @throws InstantiationException * @throws InstantiationException
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws IOException
*/ */
public MainWindow(DbConnector pDbCon) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { public MainWindow(DbConnector pDbCon) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, IOException {
this.dbCon = pDbCon; this.dbCon = pDbCon;
initialize(); initialize();
this.frame.setVisible(true); this.frame.setVisible(true);
@@ -39,8 +41,9 @@ public class MainWindow {
* @throws IllegalAccessException * @throws IllegalAccessException
* @throws InstantiationException * @throws InstantiationException
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws IOException
*/ */
private void initialize() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { private void initialize() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, IOException {
this.frame = new JFrame(); this.frame = new JFrame();
this.frame.setResizable(false); this.frame.setResizable(false);
this.frame.setBounds(100, 100, 600, 500); this.frame.setBounds(100, 100, 600, 500);

View File

@@ -3,6 +3,7 @@ package de.katho.kBorrow.gui;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
@@ -29,20 +30,25 @@ public class UserTab extends JPanel implements ActionListener {
private int userEditId; private int userEditId;
private UserTableModel userTableModel; private UserTableModel userTableModel;
public UserTab(final DbConnector dbCon){ public UserTab(final DbConnector dbCon) throws IOException{
super(); super();
this.setLayout(null); this.setLayout(null);
//Tabelle und drumherum //Tabelle und drumherum
this.userTableModel = new UserTableModel(dbCon); this.userTableModel = new UserTableModel(dbCon);
JTable userTable = new JTable(userTableModel); JTable userTable = new JTable(userTableModel);
userTable.setRowHeight(30);
UserDeleteTableButton userDeleteTableButton = new UserDeleteTableButton("L<EFBFBD>schen", userTable); UserDeleteTableButton userDeleteTableButton = new UserDeleteTableButton("L<EFBFBD>schen", userTable);
userTable.getColumnModel().getColumn(4).setCellEditor(userDeleteTableButton);
userTable.getColumnModel().getColumn(4).setCellRenderer(userDeleteTableButton);
UserEditTableButton userEditTableButton = new UserEditTableButton("Bearbeiten", userTable, this); UserEditTableButton userEditTableButton = new UserEditTableButton("Bearbeiten", userTable, this);
userTable.getColumnModel().getColumn(3).setCellEditor(userEditTableButton);
userTable.getColumnModel().getColumn(3).setCellRenderer(userEditTableButton); for (int i = 3; i <= 4; i++){
userTable.getColumnModel().getColumn(i).setCellEditor(i == 3 ? userEditTableButton : userDeleteTableButton);
userTable.getColumnModel().getColumn(i).setCellRenderer(i == 3 ? userEditTableButton : userDeleteTableButton);
userTable.getColumnModel().getColumn(i).setMinWidth(30);
userTable.getColumnModel().getColumn(i).setMaxWidth(30);
userTable.getColumnModel().getColumn(i).setPreferredWidth(30);
}
userTable.setFillsViewportHeight(true); userTable.setFillsViewportHeight(true);
@@ -115,7 +121,7 @@ public class UserTab extends JPanel implements ActionListener {
break; break;
case 2: case 2:
this.lblUserStatus.setText("Entweder Vor- oder Nachname m<>ssen ausgef<65>llt sein."); this.lblUserStatus.setText("Entweder Vor- oder Nachname m<>ssen ausgef<65>llt sein.");
break; break;
} }
@@ -128,7 +134,7 @@ public class UserTab extends JPanel implements ActionListener {
switch (re){ switch (re){
case 0: case 0:
this.lblUserStatus.setText("Benutzer \""+this.textFieldUserName.getText()+" "+this.textFieldUserSurname.getText()+"\" erfolgreich hinzugef<65>gt."); this.lblUserStatus.setText("Benutzer \""+this.textFieldUserName.getText()+" "+this.textFieldUserSurname.getText()+"\" erfolgreich hinzugef<65>gt.");
this.textFieldUserName.setText(""); this.textFieldUserName.setText("");
this.textFieldUserSurname.setText(""); this.textFieldUserSurname.setText("");
break; break;
@@ -140,7 +146,7 @@ public class UserTab extends JPanel implements ActionListener {
break; break;
case 2: case 2:
this.lblUserStatus.setText("Entweder Vor- oder Nachname m<>ssen ausgef<65>llt sein."); this.lblUserStatus.setText("Entweder Vor- oder Nachname m<>ssen ausgef<65>llt sein.");
break; break;
} }
} }

View File

@@ -2,7 +2,12 @@ package de.katho.kBorrow.listener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JTable; import javax.swing.JTable;
import de.katho.kBorrow.gui.ArticleTableModel; import de.katho.kBorrow.gui.ArticleTableModel;
@@ -14,8 +19,8 @@ public class ArticleDeleteTableButton extends TableButton {
*/ */
private static final long serialVersionUID = 7701712368979056068L; private static final long serialVersionUID = 7701712368979056068L;
public ArticleDeleteTableButton(String pLabel, JTable pTable) { public ArticleDeleteTableButton(String pLabel, JTable pTable) throws IOException {
super(pLabel, pTable); super(new ImageIcon(ImageIO.read(new File("assets/icons/edit-delete.png"))), pTable);
this.buttonE.addActionListener(new ActionListener(){ this.buttonE.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e){

View File

@@ -2,7 +2,11 @@ package de.katho.kBorrow.listener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JTable; import javax.swing.JTable;
import de.katho.kBorrow.gui.ArticleTab; import de.katho.kBorrow.gui.ArticleTab;
@@ -15,8 +19,8 @@ public class ArticleEditTableButton extends TableButton {
*/ */
private static final long serialVersionUID = -5902626427691636902L; private static final long serialVersionUID = -5902626427691636902L;
public ArticleEditTableButton(String pLabel, JTable pTable, final ArticleTab articleTab) { public ArticleEditTableButton(String pLabel, JTable pTable, final ArticleTab articleTab) throws IOException {
super(pLabel, pTable); super(new ImageIcon(ImageIO.read(new File("assets/icons/accessories-text-editor.png"))), pTable);
this.buttonE.addActionListener(new ActionListener(){ this.buttonE.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e){

View File

@@ -3,6 +3,7 @@ package de.katho.kBorrow.listener;
import java.awt.Component; import java.awt.Component;
import javax.swing.AbstractCellEditor; import javax.swing.AbstractCellEditor;
import javax.swing.ImageIcon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
@@ -15,11 +16,11 @@ public abstract class TableButton extends AbstractCellEditor implements TableCel
protected JButton buttonR; protected JButton buttonR;
protected JButton buttonE; protected JButton buttonE;
public TableButton (String pLabel, JTable pTable) { public TableButton (ImageIcon pIcon, JTable pTable) {
this.label = pLabel; //this.label = pLabel;
this.table = pTable; this.table = pTable;
this.buttonR = new JButton(pLabel); this.buttonR = new JButton(pIcon);
this.buttonE = new JButton(pLabel); this.buttonE = new JButton(pIcon);
} }
public Object getCellEditorValue() { public Object getCellEditorValue() {

View File

@@ -2,7 +2,11 @@ package de.katho.kBorrow.listener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JTable; import javax.swing.JTable;
import de.katho.kBorrow.gui.UserTableModel; import de.katho.kBorrow.gui.UserTableModel;
@@ -11,8 +15,8 @@ public class UserDeleteTableButton extends TableButton {
private static final long serialVersionUID = -886584066497429394L; private static final long serialVersionUID = -886584066497429394L;
public UserDeleteTableButton(String pLabel, JTable pTable){ public UserDeleteTableButton(String pLabel, JTable pTable) throws IOException{
super(pLabel, pTable); super(new ImageIcon(ImageIO.read(new File("assets/icons/edit-delete.png"))), pTable);
this.buttonE.addActionListener(new ActionListener(){ this.buttonE.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e){

View File

@@ -2,7 +2,11 @@ package de.katho.kBorrow.listener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JTable; import javax.swing.JTable;
import de.katho.kBorrow.gui.UserTab; import de.katho.kBorrow.gui.UserTab;
@@ -15,8 +19,8 @@ public class UserEditTableButton extends TableButton {
*/ */
private static final long serialVersionUID = -886584066497429394L; private static final long serialVersionUID = -886584066497429394L;
public UserEditTableButton(String pLabel, JTable pTable, final UserTab pPanel){ public UserEditTableButton(String pLabel, JTable pTable, final UserTab pPanel) throws IOException{
super(pLabel, pTable); super(new ImageIcon(ImageIO.read(new File("assets/icons/accessories-text-editor.png"))), pTable);
this.buttonE.addActionListener(new ActionListener(){ this.buttonE.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e){