From adc65f363641b2ccdd5f2044b56f63a9b1e7defd Mon Sep 17 00:00:00 2001 From: jechowma68968 Date: Tue, 12 Nov 2019 15:03:51 +0100 Subject: [PATCH] 2 - The real one --- src/Model/AdressverwaltungModel.java | 120 ------------ src/controller/Controller.java | 21 ++- src/controller/ControllerOeffnen.java | 45 ----- src/controller/Invoker.java | 11 ++ src/controller/commands/CommandAddRow.java | 38 ++++ src/controller/commands/CommandDeleteRow.java | 59 ++++++ src/controller/commands/CommandOpen.java | 5 +- src/controller/commands/CommandSave.java | 61 +++++++ .../CommandDeleteRowDataContainer.java | 20 ++ src/prfourgui/Constants.java | 14 ++ src/prfourgui/Start.java | 2 +- src/prfourgui/View/AdressTable.form | 6 +- src/prfourgui/View/AdressTable.java | 72 ++++---- src/prfourgui/View/AdressbuchView.form | 1 + src/prfourgui/View/AdressbuchView.java | 172 ++++++++++-------- 15 files changed, 361 insertions(+), 286 deletions(-) delete mode 100644 src/Model/AdressverwaltungModel.java delete mode 100644 src/controller/ControllerOeffnen.java create mode 100644 src/controller/commands/CommandAddRow.java create mode 100644 src/controller/commands/CommandDeleteRow.java create mode 100644 src/controller/commands/CommandSave.java create mode 100644 src/prfourgui/CommandDeleteRowDataContainer.java create mode 100644 src/prfourgui/Constants.java diff --git a/src/Model/AdressverwaltungModel.java b/src/Model/AdressverwaltungModel.java deleted file mode 100644 index fb7b2db..0000000 --- a/src/Model/AdressverwaltungModel.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package adressverwaltung.model; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.ArrayList; -import javax.swing.table.AbstractTableModel; - -/** - * - * @author le - */ -public class AdressverwaltungModel extends AbstractTableModel -{ - private ArrayList> daten; - private ArrayList adressEintraegeDaten; - private ArrayList adressEintraegeNamen; - - public AdressverwaltungModel() - { - adressEintraegeDaten = new ArrayList<>(); - adressEintraegeNamen = new ArrayList<>(); - daten = new ArrayList<>(); - adressEintraegeNamen.add("Name"); - adressEintraegeDaten.add("Lehner"); - adressEintraegeNamen.add("Telefon"); - adressEintraegeDaten.add("122345"); - daten.add(adressEintraegeDaten); - } - - @Override - public int getRowCount() - { - return daten.size(); - } - - @Override - public int getColumnCount() - { - return adressEintraegeDaten.size(); - } - - @Override - public Object getValueAt(int row, int col) - { - return daten.get(row).get(col); - } - @Override - public void setValueAt(Object value, int row, int col) - { - daten.get(row).set(col, (String)value); - } - - @Override - public boolean isCellEditable(int row, int col) - { - return true; - } - - @Override - public String getColumnName(int col) - { - return adressEintraegeNamen.get(col); - } - - public void eintragHinzufuegen() - { - adressEintraegeDaten = new ArrayList<>(); - adressEintraegeNamen.forEach(s -> adressEintraegeDaten.add(s)); - daten.add(adressEintraegeDaten); - this.fireTableDataChanged(); - } - - public void eintragLoeschen(int row) - { - daten.remove(row); - this.fireTableDataChanged(); - } - - public void spalteHinzufuegen(String name) - { - adressEintraegeNamen.add(name); - } - - public void datenSpeichern(File datei) throws FileNotFoundException, IOException - { - FileOutputStream fos = new FileOutputStream(datei); - BufferedOutputStream bos = new BufferedOutputStream(fos); - ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(daten); - oos.writeObject(adressEintraegeNamen); - oos.flush(); - oos.close(); - } - - public void datenLesen(File datei) throws FileNotFoundException, IOException, ClassNotFoundException - { - FileInputStream fis = new FileInputStream(datei); - BufferedInputStream bis = new BufferedInputStream(fis); - ObjectInputStream ois = new ObjectInputStream(bis); - daten = (ArrayList>)ois.readObject(); - adressEintraegeNamen = (ArrayList)ois.readObject(); - adressEintraegeDaten = daten.get(daten.size()-1); - ois.close(); - this.fireTableDataChanged(); - } - -} diff --git a/src/controller/Controller.java b/src/controller/Controller.java index 091d5f5..a5880d8 100644 --- a/src/controller/Controller.java +++ b/src/controller/Controller.java @@ -6,10 +6,13 @@ package controller; -import adressverwaltung.model.AdressverwaltungModel; +import controller.commands.CommandAddRow; +import controller.commands.CommandDeleteRow; import controller.commands.CommandOpen; +import controller.commands.CommandSave; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import model.AdressverwaltungModel; import prfourgui.View.AdressbuchView; /** @@ -32,16 +35,30 @@ public class Controller implements ActionListener */ public void registerEvents(){ view.getMnuOpen().addActionListener(this); + view.getToolAdd().addActionListener(this); + view.getToolRemove().addActionListener(this); + view.getMnuSave().addActionListener(this); + view.getAdressTable2().getDeleteItem().addActionListener(this); + view.getToolUndo().addActionListener(this); } public void registerCommands(){ invoker.addCommand(view.getMnuOpen(), new CommandOpen(view, model)); + invoker.addCommand(view.getToolAdd(), new CommandAddRow(view, model)); + invoker.addCommand(view.getToolRemove(), new CommandDeleteRow(view, model)); + invoker.addCommand(view.getMnuSave(), new CommandSave(view, model)); + invoker.addCommand(view.getAdressTable2().getDeleteItem(), new CommandDeleteRow(view, model)); } @Override public void actionPerformed(ActionEvent ae) { Object key = ae.getSource(); - invoker.executeCommand(key); + if (key == view.getToolUndo()){ + invoker.undo(key); + } + else{ + invoker.executeCommand(key); + } } } diff --git a/src/controller/ControllerOeffnen.java b/src/controller/ControllerOeffnen.java deleted file mode 100644 index 4af8db3..0000000 --- a/src/controller/ControllerOeffnen.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package controller; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import javax.swing.JFileChooser; -import prfourgui.View.AdressbuchView; - -/** - * - * @author baumannan68085 - */ -public class ControllerOeffnen implements ActionListener -{ - private AdressbuchView view; - - public ControllerOeffnen(AdressbuchView view) - { - this.view = view; - } - - public void registerEvents(){ - view.getMnuOpen().addActionListener(this); - } - - @Override - public void actionPerformed(ActionEvent ae) - { - JFileChooser fc = view.getjFileChooser1(); - int wahl = fc.showOpenDialog(view); - if(wahl == JFileChooser.APPROVE_OPTION){ - File datei = fc.getSelectedFile(); - String dateiname = datei.getAbsolutePath(); - view.getTxtStatus().setText("Dateipfad:" + dateiname); - - } - - } -} diff --git a/src/controller/Invoker.java b/src/controller/Invoker.java index ab06cfe..2ec989e 100644 --- a/src/controller/Invoker.java +++ b/src/controller/Invoker.java @@ -7,6 +7,7 @@ package controller; import java.util.HashMap; +import java.util.Stack; /** * @@ -15,10 +16,12 @@ import java.util.HashMap; public class Invoker { private HashMap commands; + private Stack commandHistory; public Invoker() { commands = new HashMap<>(); + commandHistory = new Stack(); } /** @@ -31,6 +34,14 @@ public class Invoker } public void executeCommand(Object key){ + commandHistory.push(key); commands.get(key).execute(); } + + public void undo(Object key){ + if (commandHistory.isEmpty()){ + return; + } + commands.get(commandHistory.pop()).undo(); + } } diff --git a/src/controller/commands/CommandAddRow.java b/src/controller/commands/CommandAddRow.java new file mode 100644 index 0000000..cc7c836 --- /dev/null +++ b/src/controller/commands/CommandAddRow.java @@ -0,0 +1,38 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package controller.commands; + +import model.AdressverwaltungModel; +import controller.Interface; +import prfourgui.View.AdressbuchView; + +/** + * + * @author jechowma68968 + */ +public class CommandAddRow implements Interface +{ + private final AdressbuchView view; + private final AdressverwaltungModel model; + + public CommandAddRow(AdressbuchView view, AdressverwaltungModel model) + { + this.view = view; + this.model = model; + } + + @Override + public void execute() + { + model.eintragHinzufuegen(); + } + + @Override + public void undo() + { + } +} diff --git a/src/controller/commands/CommandDeleteRow.java b/src/controller/commands/CommandDeleteRow.java new file mode 100644 index 0000000..372efa7 --- /dev/null +++ b/src/controller/commands/CommandDeleteRow.java @@ -0,0 +1,59 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package controller.commands; + +import model.AdressverwaltungModel; +import controller.Interface; +import java.util.Stack; +import javax.swing.JOptionPane; +import prfourgui.CommandDeleteRowDataContainer; +import prfourgui.View.AdressbuchView; + +/** + * + * @author jechowma68968 + */ +public class CommandDeleteRow implements Interface +{ + private final AdressbuchView view; + private final AdressverwaltungModel model; + private final Stack deleteHistory; + + + public CommandDeleteRow(AdressbuchView view, AdressverwaltungModel model) + { + this.view = view; + this.model = model; + this.deleteHistory = new Stack(); + } + + @Override + public void execute() + { + int rowCount = view.getAdressTable2().getTblAdressbuch().getSelectedRowCount(); + if (rowCount != 1){ + JOptionPane.showMessageDialog(view, "Genau eine Zeile auswählen zum löschen.", "Ein Satz mit x, das war wohl nox...", JOptionPane.INFORMATION_MESSAGE); + } + else{ + int row = view.getAdressTable2().getTblAdressbuch().getSelectedRow(); + deleteHistory.push(new CommandDeleteRowDataContainer(model.getValueAt(row, 0).toString(), model.getValueAt(row, 1).toString())); + model.eintragLoeschen(row); + } + } + + @Override + public void undo() + { + CommandDeleteRowDataContainer c = deleteHistory.pop(); + model.eintragHinzufuegen(); + System.out.println(c.name); + System.out.println(c.telephone); + System.out.println(model.getRowCount()); + model.setValueAt(c.name, model.getRowCount()-1, 0); + model.setValueAt(c.telephone, model.getRowCount()-1, 1); + } +} diff --git a/src/controller/commands/CommandOpen.java b/src/controller/commands/CommandOpen.java index 95c6d1d..c986753 100644 --- a/src/controller/commands/CommandOpen.java +++ b/src/controller/commands/CommandOpen.java @@ -6,12 +6,13 @@ package controller.commands; -import adressverwaltung.model.AdressverwaltungModel; +import model.AdressverwaltungModel; import controller.Interface; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import javax.swing.JFileChooser; +import prfourgui.Constants; import prfourgui.View.AdressbuchView; /** @@ -32,8 +33,10 @@ public class CommandOpen implements Interface @Override public void execute() { + String default_file = model.getPref(Constants.PREF_KEY_DIR); File datei; JFileChooser fc = view.getjFileChooser1(); + fc.setCurrentDirectory(new File(default_file)); int wahl = fc.showOpenDialog(view); if(wahl == JFileChooser.APPROVE_OPTION){ datei = fc.getSelectedFile(); diff --git a/src/controller/commands/CommandSave.java b/src/controller/commands/CommandSave.java new file mode 100644 index 0000000..7e4d29c --- /dev/null +++ b/src/controller/commands/CommandSave.java @@ -0,0 +1,61 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package controller.commands; + +import model.AdressverwaltungModel; +import controller.Interface; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import javax.swing.JFileChooser; +import prfourgui.Constants; +import prfourgui.View.AdressbuchView; + +/** + * + * @author jechowma68968 + */ +public class CommandSave implements Interface +{ + private final AdressbuchView view; + private final AdressverwaltungModel model; + + public CommandSave(AdressbuchView view, AdressverwaltungModel model) + { + this.view = view; + this.model = model; + } + + @Override + public void execute() + { + File datei; + JFileChooser fc = view.getjFileChooser1(); + int wahl = fc.showOpenDialog(view); + if(wahl == JFileChooser.APPROVE_OPTION){ + datei = fc.getSelectedFile(); + String dateiname = datei.getAbsolutePath(); + model.setPref(Constants.PREF_KEY_DIR, dateiname); + view.getTxtStatus().setText("Dateipfad:" + dateiname); + + try{ + model.datenSpeichern(datei); + } + catch(FileNotFoundException e){ + System.out.println("File not Found Error"); + } + catch(IOException e){ + System.out.println("Reading Error"); + } + } + } + + @Override + public void undo() + { + } +} diff --git a/src/prfourgui/CommandDeleteRowDataContainer.java b/src/prfourgui/CommandDeleteRowDataContainer.java new file mode 100644 index 0000000..e00680f --- /dev/null +++ b/src/prfourgui/CommandDeleteRowDataContainer.java @@ -0,0 +1,20 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package prfourgui; + +/** + * + * @author marku + */ +public class CommandDeleteRowDataContainer { + public String name; + public String telephone; + + public CommandDeleteRowDataContainer(String name, String telephone){ + this.name = name; + this.telephone = telephone; + } +} diff --git a/src/prfourgui/Constants.java b/src/prfourgui/Constants.java new file mode 100644 index 0000000..4049ee6 --- /dev/null +++ b/src/prfourgui/Constants.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package prfourgui; + +/** + * + * @author marku + */ +public class Constants{ + public static final String PREF_KEY_DIR = "PREF_KEY_DIR"; +} diff --git a/src/prfourgui/Start.java b/src/prfourgui/Start.java index 7462850..44df418 100644 --- a/src/prfourgui/Start.java +++ b/src/prfourgui/Start.java @@ -6,7 +6,7 @@ package prfourgui; -import adressverwaltung.model.AdressverwaltungModel; +import model.AdressverwaltungModel; import controller.Controller; import prfourgui.View.AdressbuchView; diff --git a/src/prfourgui/View/AdressTable.form b/src/prfourgui/View/AdressTable.form index 98f6be6..bc062ba 100644 --- a/src/prfourgui/View/AdressTable.form +++ b/src/prfourgui/View/AdressTable.form @@ -2,13 +2,13 @@
- + - + @@ -76,7 +76,7 @@ - + diff --git a/src/prfourgui/View/AdressTable.java b/src/prfourgui/View/AdressTable.java index 2f37140..8adfbc3 100644 --- a/src/prfourgui/View/AdressTable.java +++ b/src/prfourgui/View/AdressTable.java @@ -41,45 +41,49 @@ public class AdressTable extends javax.swing.JPanel * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() - { + // //GEN-BEGIN:initComponents + private void initComponents() { - jPopupMenu1 = new javax.swing.JPopupMenu(); - jMenuItem1 = new javax.swing.JMenuItem(); - jScrollPane1 = new javax.swing.JScrollPane(); - tblAdressbuch = new javax.swing.JTable(); + popupMenu = new javax.swing.JPopupMenu(); + deleteItem = new javax.swing.JMenuItem(); + jScrollPane1 = new javax.swing.JScrollPane(); + tblAdressbuch = new javax.swing.JTable(); - jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Delete24.gif"))); // NOI18N - jMenuItem1.setText("Remove"); - jPopupMenu1.add(jMenuItem1); + deleteItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Delete24.gif"))); // NOI18N + deleteItem.setText("Remove"); + popupMenu.add(deleteItem); - setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS)); + setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS)); - tblAdressbuch.setModel(new javax.swing.table.DefaultTableModel( - new Object [][] - { - {null, null, null, null}, - {null, null, null, null}, - {null, null, null, null}, - {null, null, null, null} - }, - new String [] - { - "Name", "Telefon", "Mobil", "E-Mail" - } - )); - tblAdressbuch.setComponentPopupMenu(jPopupMenu1); - jScrollPane1.setViewportView(tblAdressbuch); + tblAdressbuch.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] { + "Name", "Telefon", "Mobil", "E-Mail" + } + )); + tblAdressbuch.setComponentPopupMenu(popupMenu); + jScrollPane1.setViewportView(tblAdressbuch); - add(jScrollPane1); - }// //GEN-END:initComponents + add(jScrollPane1); + }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JMenuItem jMenuItem1; - private javax.swing.JPopupMenu jPopupMenu1; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JTable tblAdressbuch; - // End of variables declaration//GEN-END:variables + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JMenuItem deleteItem; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JPopupMenu popupMenu; + private javax.swing.JTable tblAdressbuch; + // End of variables declaration//GEN-END:variables + + /** + * @return the deleteItem + */ + public javax.swing.JMenuItem getDeleteItem() { + return deleteItem; + } } diff --git a/src/prfourgui/View/AdressbuchView.form b/src/prfourgui/View/AdressbuchView.form index 9742c17..96ad350 100644 --- a/src/prfourgui/View/AdressbuchView.form +++ b/src/prfourgui/View/AdressbuchView.form @@ -109,6 +109,7 @@ + diff --git a/src/prfourgui/View/AdressbuchView.java b/src/prfourgui/View/AdressbuchView.java index 102b3c0..e0cc64f 100644 --- a/src/prfourgui/View/AdressbuchView.java +++ b/src/prfourgui/View/AdressbuchView.java @@ -12,6 +12,20 @@ package prfourgui.View; public class AdressbuchView extends javax.swing.JFrame { + /** + * @return the toolUndo + */ + public javax.swing.JButton getToolUndo() { + return toolUndo; + } + + /** + * @param toolUndo the toolUndo to set + */ + public void setToolUndo(javax.swing.JButton toolUndo) { + this.toolUndo = toolUndo; + } + /** * Creates new form AdressbuchView */ @@ -26,87 +40,85 @@ public class AdressbuchView extends javax.swing.JFrame * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() - { + // //GEN-BEGIN:initComponents + private void initComponents() { - jFileChooser1 = new javax.swing.JFileChooser(); - toolBar = new javax.swing.JToolBar(); - toolAdd = new javax.swing.JButton(); - toolRemove = new javax.swing.JButton(); - toolUndo = new javax.swing.JButton(); - adressTable2 = new prfourgui.View.AdressTable(); - pnStatus = new javax.swing.JScrollPane(); - txtStatus = new javax.swing.JTextArea(); - mnuMain = new javax.swing.JMenuBar(); - mnuDatei = new javax.swing.JMenu(); - mnuOpen = new javax.swing.JMenuItem(); - mnuSave = new javax.swing.JMenuItem(); + jFileChooser1 = new javax.swing.JFileChooser(); + toolBar = new javax.swing.JToolBar(); + toolAdd = new javax.swing.JButton(); + toolRemove = new javax.swing.JButton(); + toolUndo = new javax.swing.JButton(); + adressTable2 = new prfourgui.View.AdressTable(); + pnStatus = new javax.swing.JScrollPane(); + txtStatus = new javax.swing.JTextArea(); + mnuMain = new javax.swing.JMenuBar(); + mnuDatei = new javax.swing.JMenu(); + mnuOpen = new javax.swing.JMenuItem(); + mnuSave = new javax.swing.JMenuItem(); - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - toolBar.setRollover(true); + toolBar.setRollover(true); - toolAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/New24.gif"))); // NOI18N - toolAdd.setMnemonic('A'); - toolAdd.setToolTipText("Add Address"); - toolAdd.setFocusable(false); - toolAdd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - toolAdd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - toolBar.add(toolAdd); + toolAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/New24.gif"))); // NOI18N + toolAdd.setMnemonic('A'); + toolAdd.setToolTipText("Add Address"); + toolAdd.setFocusable(false); + toolAdd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + toolAdd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + toolBar.add(toolAdd); - toolRemove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Delete24.gif"))); // NOI18N - toolRemove.setMnemonic('R'); - toolRemove.setToolTipText("Remove Address"); - toolRemove.setFocusable(false); - toolRemove.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - toolRemove.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - toolBar.add(toolRemove); + toolRemove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Delete24.gif"))); // NOI18N + toolRemove.setMnemonic('R'); + toolRemove.setToolTipText("Remove Address"); + toolRemove.setFocusable(false); + toolRemove.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + toolRemove.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + toolBar.add(toolRemove); - toolUndo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Undo24.gif"))); // NOI18N - toolUndo.setFocusable(false); - toolUndo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - toolUndo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - toolBar.add(toolUndo); + toolUndo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Undo24.gif"))); // NOI18N + toolUndo.setToolTipText("Undo"); + toolUndo.setFocusable(false); + toolUndo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + toolUndo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + toolBar.add(toolUndo); - getContentPane().add(toolBar, java.awt.BorderLayout.NORTH); - getContentPane().add(adressTable2, java.awt.BorderLayout.CENTER); + getContentPane().add(toolBar, java.awt.BorderLayout.NORTH); + getContentPane().add(adressTable2, java.awt.BorderLayout.CENTER); - txtStatus.setColumns(20); - txtStatus.setRows(5); - pnStatus.setViewportView(txtStatus); + txtStatus.setColumns(20); + txtStatus.setRows(5); + pnStatus.setViewportView(txtStatus); - getContentPane().add(pnStatus, java.awt.BorderLayout.PAGE_END); + getContentPane().add(pnStatus, java.awt.BorderLayout.PAGE_END); - mnuDatei.setMnemonic('D'); - mnuDatei.setText("Datei"); + mnuDatei.setMnemonic('D'); + mnuDatei.setText("Datei"); - mnuOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); - mnuOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Open24.gif"))); // NOI18N - mnuOpen.setMnemonic('O'); - mnuOpen.setText("Open"); - mnuOpen.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { - mnuOpenActionPerformed(evt); - } - }); - mnuDatei.add(mnuOpen); + mnuOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); + mnuOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Open24.gif"))); // NOI18N + mnuOpen.setMnemonic('O'); + mnuOpen.setText("Open"); + mnuOpen.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + mnuOpenActionPerformed(evt); + } + }); + mnuDatei.add(mnuOpen); - mnuSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); - mnuSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Save24.gif"))); // NOI18N - mnuSave.setMnemonic('S'); - mnuSave.setText("Save"); - mnuSave.setToolTipText(""); - mnuDatei.add(mnuSave); + mnuSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); + mnuSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Save24.gif"))); // NOI18N + mnuSave.setMnemonic('S'); + mnuSave.setText("Save"); + mnuSave.setToolTipText(""); + mnuDatei.add(mnuSave); - mnuMain.add(mnuDatei); + mnuMain.add(mnuDatei); - setJMenuBar(mnuMain); + setJMenuBar(mnuMain); - pack(); - }// //GEN-END:initComponents + pack(); + }// //GEN-END:initComponents private void mnuOpenActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_mnuOpenActionPerformed {//GEN-HEADEREND:event_mnuOpenActionPerformed @@ -162,20 +174,20 @@ public class AdressbuchView extends javax.swing.JFrame }); } - // Variables declaration - do not modify//GEN-BEGIN:variables - private prfourgui.View.AdressTable adressTable2; - private javax.swing.JFileChooser jFileChooser1; - private javax.swing.JMenu mnuDatei; - private javax.swing.JMenuBar mnuMain; - private javax.swing.JMenuItem mnuOpen; - private javax.swing.JMenuItem mnuSave; - private javax.swing.JScrollPane pnStatus; - private javax.swing.JButton toolAdd; - private javax.swing.JToolBar toolBar; - private javax.swing.JButton toolRemove; - private javax.swing.JButton toolUndo; - private javax.swing.JTextArea txtStatus; - // End of variables declaration//GEN-END:variables + // Variables declaration - do not modify//GEN-BEGIN:variables + private prfourgui.View.AdressTable adressTable2; + private javax.swing.JFileChooser jFileChooser1; + private javax.swing.JMenu mnuDatei; + private javax.swing.JMenuBar mnuMain; + private javax.swing.JMenuItem mnuOpen; + private javax.swing.JMenuItem mnuSave; + private javax.swing.JScrollPane pnStatus; + private javax.swing.JButton toolAdd; + private javax.swing.JToolBar toolBar; + private javax.swing.JButton toolRemove; + private javax.swing.JButton toolUndo; + private javax.swing.JTextArea txtStatus; + // End of variables declaration//GEN-END:variables /** * @return the mnuOpen