Erste Ansätze, ein Artikel-Inspect-Frame zu implementieren.
This commit is contained in:
53
src/de/katho/kBorrow/gui/ArticleInspectFrame.java
Normal file
53
src/de/katho/kBorrow/gui/ArticleInspectFrame.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package de.katho.kBorrow.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTable;
|
||||
import java.awt.GridLayout;
|
||||
|
||||
public class ArticleInspectFrame extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8993341404926674307L;
|
||||
private JPanel contentPane;
|
||||
private JTable table;
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public ArticleInspectFrame(int pArtId, HashMap<String, Object> pModels) {
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 660, 541);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
contentPane.setLayout(new BorderLayout(0, 0));
|
||||
setContentPane(contentPane);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
contentPane.add(panel, BorderLayout.CENTER);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("Artikelname");
|
||||
lblNewLabel_1.setBounds(0, 0, 100, 30);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("New label");
|
||||
lblNewLabel.setBounds(0, 45, 634, 45);
|
||||
panel.add(lblNewLabel);
|
||||
table = new JTable();
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(table);
|
||||
contentPane.add(scrollPane, BorderLayout.SOUTH);
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import de.katho.kBorrow.data.KArticle;
|
||||
import de.katho.kBorrow.db.DbConnector;
|
||||
import de.katho.kBorrow.listener.ArticleDeleteTableButton;
|
||||
import de.katho.kBorrow.listener.ArticleEditTableButton;
|
||||
import de.katho.kBorrow.listener.ArticleInspectTableButton;
|
||||
import de.katho.kBorrow.models.ArticleTableModel;
|
||||
|
||||
public class ArticlePanel extends JPanel implements ActionListener, KeyListener {
|
||||
@@ -61,10 +62,11 @@ public class ArticlePanel extends JPanel implements ActionListener, KeyListener
|
||||
articleTable.setRowHeight(30);
|
||||
ArticleDeleteTableButton articleDeleteTableButton = new ArticleDeleteTableButton("L<EFBFBD>schen", articleTable, this, articleController);
|
||||
ArticleEditTableButton articleEditTableButton = new ArticleEditTableButton("Bearbeiten", articleTable, this);
|
||||
ArticleInspectTableButton articleInspectTableButton = new ArticleInspectTableButton("Details", articleTable, pModels);
|
||||
|
||||
for (int i = 3; i <= 4; i++){
|
||||
articleTable.getColumnModel().getColumn(i).setCellEditor(i == 3 ? articleEditTableButton : articleDeleteTableButton);
|
||||
articleTable.getColumnModel().getColumn(i).setCellRenderer(i == 3 ? articleEditTableButton : articleDeleteTableButton);
|
||||
for (int i = 3; i <= 5; i++){
|
||||
articleTable.getColumnModel().getColumn(i).setCellEditor(i == 3 ? articleInspectTableButton : i == 4 ? articleEditTableButton : articleDeleteTableButton);
|
||||
articleTable.getColumnModel().getColumn(i).setCellRenderer(i == 3 ? articleInspectTableButton : i == 4 ? articleEditTableButton : articleDeleteTableButton);
|
||||
|
||||
articleTable.getColumnModel().getColumn(i).setMinWidth(30);
|
||||
articleTable.getColumnModel().getColumn(i).setMaxWidth(30);
|
||||
|
||||
40
src/de/katho/kBorrow/listener/ArticleInspectTableButton.java
Normal file
40
src/de/katho/kBorrow/listener/ArticleInspectTableButton.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package de.katho.kBorrow.listener;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JTable;
|
||||
|
||||
import de.katho.kBorrow.gui.ArticleInspectFrame;
|
||||
|
||||
public class ArticleInspectTableButton extends TableButton {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2591133864537097893L;
|
||||
|
||||
public ArticleInspectTableButton(String pLabel, final JTable pTable, final HashMap<String, Object> pModels) throws IOException {
|
||||
super(pLabel);
|
||||
ImageIcon icon = new ImageIcon(ImageIO.read(new File("assets/icons/system-search.png")));
|
||||
|
||||
buttonE.setIcon(icon);
|
||||
buttonR.setIcon(icon);
|
||||
|
||||
buttonE.addActionListener(new ActionListener(){
|
||||
public void actionPerformed(ActionEvent e){
|
||||
fireEditingStopped();
|
||||
|
||||
int row = pTable.getSelectedRow();
|
||||
|
||||
new ArticleInspectFrame(row, pModels);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class ArticleTableModel extends AbstractTableModel {
|
||||
protected ArrayList<KArticle> data = new ArrayList<KArticle>();
|
||||
|
||||
public ArticleTableModel(DbConnector pDbCon){
|
||||
header = new String [] {"ID", "Artikelname", "Artikelbeschreibung", "", ""};
|
||||
header = new String [] {"ID", "Artikelname", "Artikelbeschreibung", "", "", ""};
|
||||
this.dbCon = pDbCon;
|
||||
this.updateModel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user