2 - The real one

This commit is contained in:
jechowma68968 2019-11-12 15:03:51 +01:00
parent fa08e56964
commit adc65f3636
15 changed files with 361 additions and 286 deletions

View File

@ -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<ArrayList<String>> daten;
private ArrayList<String> adressEintraegeDaten;
private ArrayList<String> 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<ArrayList<String>>)ois.readObject();
adressEintraegeNamen = (ArrayList<String>)ois.readObject();
adressEintraegeDaten = daten.get(daten.size()-1);
ois.close();
this.fireTableDataChanged();
}
}

View File

@ -6,10 +6,13 @@
package controller; package controller;
import adressverwaltung.model.AdressverwaltungModel; import controller.commands.CommandAddRow;
import controller.commands.CommandDeleteRow;
import controller.commands.CommandOpen; import controller.commands.CommandOpen;
import controller.commands.CommandSave;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import model.AdressverwaltungModel;
import prfourgui.View.AdressbuchView; import prfourgui.View.AdressbuchView;
/** /**
@ -32,16 +35,30 @@ public class Controller implements ActionListener
*/ */
public void registerEvents(){ public void registerEvents(){
view.getMnuOpen().addActionListener(this); 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(){ public void registerCommands(){
invoker.addCommand(view.getMnuOpen(), new CommandOpen(view, model)); 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 @Override
public void actionPerformed(ActionEvent ae) public void actionPerformed(ActionEvent ae)
{ {
Object key = ae.getSource(); Object key = ae.getSource();
invoker.executeCommand(key); if (key == view.getToolUndo()){
invoker.undo(key);
}
else{
invoker.executeCommand(key);
}
} }
} }

View File

@ -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);
}
}
}

View File

@ -7,6 +7,7 @@
package controller; package controller;
import java.util.HashMap; import java.util.HashMap;
import java.util.Stack;
/** /**
* *
@ -15,10 +16,12 @@ import java.util.HashMap;
public class Invoker public class Invoker
{ {
private HashMap<Object, Interface> commands; private HashMap<Object, Interface> commands;
private Stack commandHistory;
public Invoker() public Invoker()
{ {
commands = new HashMap<>(); commands = new HashMap<>();
commandHistory = new Stack();
} }
/** /**
@ -31,6 +34,14 @@ public class Invoker
} }
public void executeCommand(Object key){ public void executeCommand(Object key){
commandHistory.push(key);
commands.get(key).execute(); commands.get(key).execute();
} }
public void undo(Object key){
if (commandHistory.isEmpty()){
return;
}
commands.get(commandHistory.pop()).undo();
}
} }

View File

@ -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()
{
}
}

View File

@ -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<CommandDeleteRowDataContainer> 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);
}
}

View File

@ -6,12 +6,13 @@
package controller.commands; package controller.commands;
import adressverwaltung.model.AdressverwaltungModel; import model.AdressverwaltungModel;
import controller.Interface; import controller.Interface;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import prfourgui.Constants;
import prfourgui.View.AdressbuchView; import prfourgui.View.AdressbuchView;
/** /**
@ -32,8 +33,10 @@ public class CommandOpen implements Interface
@Override @Override
public void execute() public void execute()
{ {
String default_file = model.getPref(Constants.PREF_KEY_DIR);
File datei; File datei;
JFileChooser fc = view.getjFileChooser1(); JFileChooser fc = view.getjFileChooser1();
fc.setCurrentDirectory(new File(default_file));
int wahl = fc.showOpenDialog(view); int wahl = fc.showOpenDialog(view);
if(wahl == JFileChooser.APPROVE_OPTION){ if(wahl == JFileChooser.APPROVE_OPTION){
datei = fc.getSelectedFile(); datei = fc.getSelectedFile();

View File

@ -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()
{
}
}

View File

@ -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;
}
}

View File

@ -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";
}

View File

@ -6,7 +6,7 @@
package prfourgui; package prfourgui;
import adressverwaltung.model.AdressverwaltungModel; import model.AdressverwaltungModel;
import controller.Controller; import controller.Controller;
import prfourgui.View.AdressbuchView; import prfourgui.View.AdressbuchView;

View File

@ -2,13 +2,13 @@
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> <Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents> <NonVisualComponents>
<Container class="javax.swing.JPopupMenu" name="jPopupMenu1"> <Container class="javax.swing.JPopupMenu" name="popupMenu">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/> <Property name="useNullLayout" type="boolean" value="true"/>
</Layout> </Layout>
<SubComponents> <SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1"> <MenuItem class="javax.swing.JMenuItem" name="deleteItem">
<Properties> <Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/prfourgui/Icons/Delete24.gif"/> <Image iconType="3" name="/prfourgui/Icons/Delete24.gif"/>
@ -76,7 +76,7 @@
</TableColumnModel> </TableColumnModel>
</Property> </Property>
<Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="jPopupMenu1"/> <ComponentRef name="popupMenu"/>
</Property> </Property>
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
<TableHeader reorderingAllowed="true" resizingAllowed="true"/> <TableHeader reorderingAllowed="true" resizingAllowed="true"/>

View File

@ -41,45 +41,49 @@ public class AdressTable extends javax.swing.JPanel
* regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() private void initComponents() {
{
jPopupMenu1 = new javax.swing.JPopupMenu(); popupMenu = new javax.swing.JPopupMenu();
jMenuItem1 = new javax.swing.JMenuItem(); deleteItem = new javax.swing.JMenuItem();
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
tblAdressbuch = new javax.swing.JTable(); tblAdressbuch = new javax.swing.JTable();
jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Delete24.gif"))); // NOI18N deleteItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Delete24.gif"))); // NOI18N
jMenuItem1.setText("Remove"); deleteItem.setText("Remove");
jPopupMenu1.add(jMenuItem1); 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( tblAdressbuch.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] new Object [][] {
{ {null, null, null, null},
{null, null, null, null}, {null, null, null, null},
{null, null, null, null}, {null, null, null, null},
{null, null, null, null}, {null, null, null, null}
{null, null, null, null} },
}, new String [] {
new String [] "Name", "Telefon", "Mobil", "E-Mail"
{ }
"Name", "Telefon", "Mobil", "E-Mail" ));
} tblAdressbuch.setComponentPopupMenu(popupMenu);
)); jScrollPane1.setViewportView(tblAdressbuch);
tblAdressbuch.setComponentPopupMenu(jPopupMenu1);
jScrollPane1.setViewportView(tblAdressbuch);
add(jScrollPane1); add(jScrollPane1);
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem deleteItem;
private javax.swing.JPopupMenu jPopupMenu1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JPopupMenu popupMenu;
private javax.swing.JTable tblAdressbuch; private javax.swing.JTable tblAdressbuch;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
/**
* @return the deleteItem
*/
public javax.swing.JMenuItem getDeleteItem() {
return deleteItem;
}
} }

View File

@ -109,6 +109,7 @@
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/prfourgui/Icons/Undo24.gif"/> <Image iconType="3" name="/prfourgui/Icons/Undo24.gif"/>
</Property> </Property>
<Property name="toolTipText" type="java.lang.String" value="Undo"/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/> <Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/> <Property name="verticalTextPosition" type="int" value="3"/>

View File

@ -12,6 +12,20 @@ package prfourgui.View;
public class AdressbuchView extends javax.swing.JFrame 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 * Creates new form AdressbuchView
*/ */
@ -26,87 +40,85 @@ public class AdressbuchView extends javax.swing.JFrame
* regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() private void initComponents() {
{
jFileChooser1 = new javax.swing.JFileChooser(); jFileChooser1 = new javax.swing.JFileChooser();
toolBar = new javax.swing.JToolBar(); toolBar = new javax.swing.JToolBar();
toolAdd = new javax.swing.JButton(); toolAdd = new javax.swing.JButton();
toolRemove = new javax.swing.JButton(); toolRemove = new javax.swing.JButton();
toolUndo = new javax.swing.JButton(); toolUndo = new javax.swing.JButton();
adressTable2 = new prfourgui.View.AdressTable(); adressTable2 = new prfourgui.View.AdressTable();
pnStatus = new javax.swing.JScrollPane(); pnStatus = new javax.swing.JScrollPane();
txtStatus = new javax.swing.JTextArea(); txtStatus = new javax.swing.JTextArea();
mnuMain = new javax.swing.JMenuBar(); mnuMain = new javax.swing.JMenuBar();
mnuDatei = new javax.swing.JMenu(); mnuDatei = new javax.swing.JMenu();
mnuOpen = new javax.swing.JMenuItem(); mnuOpen = new javax.swing.JMenuItem();
mnuSave = 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.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/New24.gif"))); // NOI18N
toolAdd.setMnemonic('A'); toolAdd.setMnemonic('A');
toolAdd.setToolTipText("Add Address"); toolAdd.setToolTipText("Add Address");
toolAdd.setFocusable(false); toolAdd.setFocusable(false);
toolAdd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); toolAdd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
toolAdd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); toolAdd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
toolBar.add(toolAdd); toolBar.add(toolAdd);
toolRemove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Delete24.gif"))); // NOI18N toolRemove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Delete24.gif"))); // NOI18N
toolRemove.setMnemonic('R'); toolRemove.setMnemonic('R');
toolRemove.setToolTipText("Remove Address"); toolRemove.setToolTipText("Remove Address");
toolRemove.setFocusable(false); toolRemove.setFocusable(false);
toolRemove.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); toolRemove.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
toolRemove.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); toolRemove.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
toolBar.add(toolRemove); toolBar.add(toolRemove);
toolUndo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Undo24.gif"))); // NOI18N toolUndo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Undo24.gif"))); // NOI18N
toolUndo.setFocusable(false); toolUndo.setToolTipText("Undo");
toolUndo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); toolUndo.setFocusable(false);
toolUndo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); toolUndo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
toolBar.add(toolUndo); toolUndo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
toolBar.add(toolUndo);
getContentPane().add(toolBar, java.awt.BorderLayout.NORTH); getContentPane().add(toolBar, java.awt.BorderLayout.NORTH);
getContentPane().add(adressTable2, java.awt.BorderLayout.CENTER); getContentPane().add(adressTable2, java.awt.BorderLayout.CENTER);
txtStatus.setColumns(20); txtStatus.setColumns(20);
txtStatus.setRows(5); txtStatus.setRows(5);
pnStatus.setViewportView(txtStatus); pnStatus.setViewportView(txtStatus);
getContentPane().add(pnStatus, java.awt.BorderLayout.PAGE_END); getContentPane().add(pnStatus, java.awt.BorderLayout.PAGE_END);
mnuDatei.setMnemonic('D'); mnuDatei.setMnemonic('D');
mnuDatei.setText("Datei"); mnuDatei.setText("Datei");
mnuOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); 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.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Open24.gif"))); // NOI18N
mnuOpen.setMnemonic('O'); mnuOpen.setMnemonic('O');
mnuOpen.setText("Open"); mnuOpen.setText("Open");
mnuOpen.addActionListener(new java.awt.event.ActionListener() mnuOpen.addActionListener(new java.awt.event.ActionListener() {
{ public void actionPerformed(java.awt.event.ActionEvent evt) {
public void actionPerformed(java.awt.event.ActionEvent evt) mnuOpenActionPerformed(evt);
{ }
mnuOpenActionPerformed(evt); });
} mnuDatei.add(mnuOpen);
});
mnuDatei.add(mnuOpen);
mnuSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); 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.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Save24.gif"))); // NOI18N
mnuSave.setMnemonic('S'); mnuSave.setMnemonic('S');
mnuSave.setText("Save"); mnuSave.setText("Save");
mnuSave.setToolTipText(""); mnuSave.setToolTipText("");
mnuDatei.add(mnuSave); mnuDatei.add(mnuSave);
mnuMain.add(mnuDatei); mnuMain.add(mnuDatei);
setJMenuBar(mnuMain); setJMenuBar(mnuMain);
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void mnuOpenActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_mnuOpenActionPerformed private void mnuOpenActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_mnuOpenActionPerformed
{//GEN-HEADEREND: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 // Variables declaration - do not modify//GEN-BEGIN:variables
private prfourgui.View.AdressTable adressTable2; private prfourgui.View.AdressTable adressTable2;
private javax.swing.JFileChooser jFileChooser1; private javax.swing.JFileChooser jFileChooser1;
private javax.swing.JMenu mnuDatei; private javax.swing.JMenu mnuDatei;
private javax.swing.JMenuBar mnuMain; private javax.swing.JMenuBar mnuMain;
private javax.swing.JMenuItem mnuOpen; private javax.swing.JMenuItem mnuOpen;
private javax.swing.JMenuItem mnuSave; private javax.swing.JMenuItem mnuSave;
private javax.swing.JScrollPane pnStatus; private javax.swing.JScrollPane pnStatus;
private javax.swing.JButton toolAdd; private javax.swing.JButton toolAdd;
private javax.swing.JToolBar toolBar; private javax.swing.JToolBar toolBar;
private javax.swing.JButton toolRemove; private javax.swing.JButton toolRemove;
private javax.swing.JButton toolUndo; private javax.swing.JButton toolUndo;
private javax.swing.JTextArea txtStatus; private javax.swing.JTextArea txtStatus;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
/** /**
* @return the mnuOpen * @return the mnuOpen