Initial Commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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;
|
||||
import controller.CommandController;
|
||||
import view.MainWindow;
|
||||
import controller.OpenController;
|
||||
import model.AdressVerwaltungModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PC
|
||||
*/
|
||||
public class main {
|
||||
|
||||
|
||||
|
||||
public main() {
|
||||
MainWindow mainwindow = new MainWindow();
|
||||
OpenController opencontroller = new OpenController(mainwindow);
|
||||
AdressVerwaltungModel model = new AdressVerwaltungModel();
|
||||
CommandController cmdController = new CommandController(mainwindow, model);
|
||||
|
||||
mainwindow.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new main();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* 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 command;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PC
|
||||
*/
|
||||
public interface CommandInterface {
|
||||
public void execute();
|
||||
public void undo();
|
||||
//public void redo();
|
||||
public boolean isUndoable();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 command;
|
||||
|
||||
import command.CommandInterface;
|
||||
import java.util.HashMap;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PC
|
||||
*/
|
||||
public class CommandInvoker {
|
||||
private HashMap<Object, CommandInterface> commands;
|
||||
private Stack<CommandInterface> undoStack;
|
||||
|
||||
public CommandInvoker()
|
||||
{
|
||||
commands = new HashMap<>();
|
||||
undoStack = new Stack<>();
|
||||
}
|
||||
|
||||
public void addCommand(Object key, CommandInterface value)
|
||||
{
|
||||
commands.put(key, value);
|
||||
}
|
||||
|
||||
public void executeCommand(Object key)
|
||||
{
|
||||
CommandInterface cmd = commands.get(key);
|
||||
cmd.execute();
|
||||
if(cmd.isUndoable())
|
||||
{
|
||||
undoStack.push(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public void undoCommand()
|
||||
{
|
||||
if(!undoStack.empty())
|
||||
{
|
||||
undoStack.pop().undo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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 command.commands;
|
||||
|
||||
import command.CommandInterface;
|
||||
import model.AdressVerwaltungModel;
|
||||
import view.MainWindow;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PC
|
||||
*/
|
||||
public class CommandEintragHinzufuegen implements CommandInterface{
|
||||
|
||||
private MainWindow view;
|
||||
private AdressVerwaltungModel model;
|
||||
|
||||
|
||||
public CommandEintragHinzufuegen(MainWindow view, AdressVerwaltungModel model)
|
||||
{
|
||||
this.view = view;
|
||||
this.model = model;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
this.model.eintragHinzufuegen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUndoable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 command.commands;
|
||||
|
||||
import command.CommandInterface;
|
||||
import java.util.ArrayList;
|
||||
import model.AdressVerwaltungModel;
|
||||
import view.MainWindow;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PC
|
||||
*/
|
||||
public class CommandEintragLoeschen implements CommandInterface{
|
||||
|
||||
private MainWindow view;
|
||||
private AdressVerwaltungModel model;
|
||||
private ArrayList<String> cache;
|
||||
|
||||
public CommandEintragLoeschen(MainWindow view, AdressVerwaltungModel model) {
|
||||
|
||||
this.view = view;
|
||||
this.model = model;
|
||||
this.cache = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
this.cache = this.model.getLastRowData();
|
||||
this.model.eintragLoeschen(this.model.getRowCount()-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
this.model.eintragHinzufuegen(this.cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUndoable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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 command.CommandInterface;
|
||||
import command.CommandInvoker;
|
||||
import command.commands.CommandEintragHinzufuegen;
|
||||
import command.commands.CommandEintragLoeschen;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.util.prefs.Preferences;
|
||||
import model.AdressVerwaltungModel;
|
||||
import view.MainWindow;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PC
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public class CommandController implements ActionListener, WindowListener{
|
||||
|
||||
private MainWindow view;
|
||||
private AdressVerwaltungModel model;
|
||||
private CommandInvoker invoker;
|
||||
private Preferences prefs;
|
||||
|
||||
public CommandController(MainWindow view, AdressVerwaltungModel model)
|
||||
{
|
||||
this.view = view;
|
||||
this.model = model;
|
||||
this.invoker = new CommandInvoker();
|
||||
this.prefs = Preferences.userRoot().node(this.getClass().getName());
|
||||
|
||||
view.getjTableAdressen().setModel(model); //Übernehme Model
|
||||
|
||||
registerEvents();
|
||||
registerCommands();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void registerEvents()
|
||||
{
|
||||
view.getJpopEintragHinzufuegen().addActionListener(this);
|
||||
view.getJpopEintragLoeschen().addActionListener(this);
|
||||
}
|
||||
|
||||
|
||||
public void registerCommands()
|
||||
{
|
||||
CommandEintragHinzufuegen cmdHinzufuegen = new CommandEintragHinzufuegen(view, model);
|
||||
CommandEintragLoeschen cmdLoeschen = new CommandEintragLoeschen(view, model);
|
||||
|
||||
invoker.addCommand(view.getJpopEintragHinzufuegen(), cmdHinzufuegen);
|
||||
invoker.addCommand(view.getJpopEintragLoeschen(), cmdLoeschen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
Object key = evt.getSource();
|
||||
invoker.executeCommand(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowOpened(WindowEvent we) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent we) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosed(WindowEvent we) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowIconified(WindowEvent we) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeiconified(WindowEvent we) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent we) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent we) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 java.util.Locale;
|
||||
import javax.swing.JFileChooser;
|
||||
import view.MainWindow;
|
||||
/**
|
||||
*
|
||||
* @author PC
|
||||
*/
|
||||
public class OpenController implements ActionListener{
|
||||
private MainWindow mainwindow;
|
||||
|
||||
public OpenController(MainWindow mainwindow)
|
||||
{
|
||||
this.mainwindow = mainwindow;
|
||||
registerEvents();
|
||||
}
|
||||
public void registerEvents()
|
||||
{
|
||||
mainwindow.getJbOpen().addActionListener(this);
|
||||
mainwindow.getFileOpen().addActionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
int wahl = mainwindow.getjFileChooser().showOpenDialog(mainwindow);
|
||||
if(wahl == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File file = mainwindow.getjFileChooser().getSelectedFile();
|
||||
mainwindow.getStatusbar().setText(file.getAbsolutePath());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* 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 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 PC
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @author le
|
||||
*/
|
||||
public class AdressVerwaltungModel extends AbstractTableModel
|
||||
{
|
||||
private ArrayList<ArrayList<String>> daten;
|
||||
private ArrayList<String> adressEintraegeDaten;
|
||||
private ArrayList<String> adressEintraegeNamen;
|
||||
|
||||
|
||||
/**
|
||||
*Konstruktor für AdressverwaltungModel
|
||||
*/
|
||||
public AdressVerwaltungModel()
|
||||
{
|
||||
adressEintraegeDaten = new ArrayList<>();
|
||||
adressEintraegeNamen = new ArrayList<>();
|
||||
daten = new ArrayList<>();
|
||||
|
||||
adressEintraegeNamen.add("Vorname");
|
||||
adressEintraegeNamen.add("Name");
|
||||
adressEintraegeNamen.add("Adresse");
|
||||
adressEintraegeNamen.add("E-Mail");
|
||||
adressEintraegeDaten.add("");
|
||||
adressEintraegeDaten.add("");
|
||||
adressEintraegeDaten.add("");
|
||||
adressEintraegeDaten.add("");
|
||||
|
||||
|
||||
|
||||
// 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 ArrayList<String> getLastRowData()
|
||||
{
|
||||
ArrayList<String> lastRow = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i <= daten.get(0).size()-1; i++)
|
||||
{
|
||||
lastRow.add(daten.get(daten.size()-1).get(i));
|
||||
}
|
||||
|
||||
return lastRow;
|
||||
}
|
||||
|
||||
|
||||
public void eintragHinzufuegen(ArrayList<String> letzteSpalte)
|
||||
{
|
||||
daten.add(letzteSpalte);
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void eintragHinzufuegen()
|
||||
{
|
||||
adressEintraegeDaten = new ArrayList<>();
|
||||
adressEintraegeNamen.forEach(s -> adressEintraegeDaten.add(""));
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Container class="javax.swing.JPopupMenu" name="jpopMenu">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jpopEintragHinzufuegen">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Eintrag hinzufügen"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jpopEintragLoeschen">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Eintrag löschen"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jpopEintragLoeschenActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JFileChooser" name="jFileChooser">
|
||||
</Component>
|
||||
<Menu class="javax.swing.JMenuBar" name="jMainMenu">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="jmFile">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="102"/>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="General File Menu"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="FileOpen">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+O"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/view/icons/Open16.gif"/>
|
||||
</Property>
|
||||
<Property name="mnemonic" type="int" value="111"/>
|
||||
<Property name="text" type="java.lang.String" value="Open"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Open a selected File"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="FileSave">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+S"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/view/icons/Save16.gif"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Save"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Save a file"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="miUndo">
|
||||
<Properties>
|
||||
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
|
||||
<KeyStroke key="Ctrl+Z"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Undo"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="miUndoActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMainMenu"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jpmainpanel" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jpmainpanel" alignment="0" pref="410" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jpmainpanel">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JToolBar" name="jtbmaintoolbar">
|
||||
<Properties>
|
||||
<Property name="rollover" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="First"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jbOpen">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/view/icons/Open16.gif"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Open a file"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbOpenActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jbSave">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/view/icons/Save16.gif"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Save a file"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JLabel" name="statusbar">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value=" "/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Last"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jSPAdressPane">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTable" name="jTableAdressen">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
|
||||
<Table columnCount="3" rowCount="4">
|
||||
<Column editable="true" title="Telefonnummer" type="java.lang.Object"/>
|
||||
<Column editable="true" title="Adresse" type="java.lang.Object"/>
|
||||
<Column editable="true" title="Name" type="java.lang.Object"/>
|
||||
</Table>
|
||||
</Property>
|
||||
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
|
||||
<TableColumnModel selectionModel="0">
|
||||
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
|
||||
<Title/>
|
||||
<Editor/>
|
||||
<Renderer/>
|
||||
</Column>
|
||||
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
|
||||
<Title/>
|
||||
<Editor/>
|
||||
<Renderer/>
|
||||
</Column>
|
||||
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
|
||||
<Title/>
|
||||
<Editor/>
|
||||
<Renderer/>
|
||||
</Column>
|
||||
</TableColumnModel>
|
||||
</Property>
|
||||
<Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor">
|
||||
<ComponentRef name="jpopMenu"/>
|
||||
</Property>
|
||||
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
|
||||
<TableHeader reorderingAllowed="true" resizingAllowed="true"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* 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 view;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PC
|
||||
*/
|
||||
public class MainWindow extends javax.swing.JFrame {
|
||||
|
||||
/**
|
||||
* @return the jpopEintragHinzufuegen
|
||||
*/
|
||||
public javax.swing.JMenuItem getJpopEintragHinzufuegen() {
|
||||
return jpopEintragHinzufuegen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the jpopEintragLoeschen
|
||||
*/
|
||||
public javax.swing.JMenuItem getJpopEintragLoeschen() {
|
||||
return jpopEintragLoeschen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form MainFrame
|
||||
*/
|
||||
public MainWindow() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jpopMenu = new javax.swing.JPopupMenu();
|
||||
jpopEintragHinzufuegen = new javax.swing.JMenuItem();
|
||||
jpopEintragLoeschen = new javax.swing.JMenuItem();
|
||||
jFileChooser = new javax.swing.JFileChooser();
|
||||
jpmainpanel = new javax.swing.JPanel();
|
||||
jtbmaintoolbar = new javax.swing.JToolBar();
|
||||
jbOpen = new javax.swing.JButton();
|
||||
jbSave = new javax.swing.JButton();
|
||||
statusbar = new javax.swing.JLabel();
|
||||
jSPAdressPane = new javax.swing.JScrollPane();
|
||||
jTableAdressen = new javax.swing.JTable();
|
||||
jMainMenu = new javax.swing.JMenuBar();
|
||||
jmFile = new javax.swing.JMenu();
|
||||
FileOpen = new javax.swing.JMenuItem();
|
||||
FileSave = new javax.swing.JMenuItem();
|
||||
jMenu2 = new javax.swing.JMenu();
|
||||
miUndo = new javax.swing.JMenuItem();
|
||||
|
||||
jpopEintragHinzufuegen.setText("Eintrag hinzufügen");
|
||||
jpopMenu.add(jpopEintragHinzufuegen);
|
||||
|
||||
jpopEintragLoeschen.setText("Eintrag löschen");
|
||||
jpopEintragLoeschen.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jpopEintragLoeschenActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jpopMenu.add(jpopEintragLoeschen);
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
jpmainpanel.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jtbmaintoolbar.setRollover(true);
|
||||
|
||||
jbOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/icons/Open16.gif"))); // NOI18N
|
||||
jbOpen.setToolTipText("Open a file");
|
||||
jbOpen.setFocusable(false);
|
||||
jbOpen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
jbOpen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
jbOpen.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbOpenActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jtbmaintoolbar.add(jbOpen);
|
||||
|
||||
jbSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/icons/Save16.gif"))); // NOI18N
|
||||
jbSave.setToolTipText("Save a file");
|
||||
jbSave.setFocusable(false);
|
||||
jbSave.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
jbSave.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
jtbmaintoolbar.add(jbSave);
|
||||
|
||||
jpmainpanel.add(jtbmaintoolbar, java.awt.BorderLayout.PAGE_START);
|
||||
|
||||
statusbar.setText(" ");
|
||||
jpmainpanel.add(statusbar, java.awt.BorderLayout.PAGE_END);
|
||||
|
||||
jTableAdressen.setModel(new javax.swing.table.DefaultTableModel(
|
||||
new Object [][] {
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null},
|
||||
{null, null, null}
|
||||
},
|
||||
new String [] {
|
||||
"Telefonnummer", "Adresse", "Name"
|
||||
}
|
||||
));
|
||||
jTableAdressen.setComponentPopupMenu(jpopMenu);
|
||||
jSPAdressPane.setViewportView(jTableAdressen);
|
||||
|
||||
jpmainpanel.add(jSPAdressPane, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jmFile.setMnemonic('f');
|
||||
jmFile.setText("File");
|
||||
jmFile.setToolTipText("General File Menu");
|
||||
|
||||
FileOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_DOWN_MASK));
|
||||
FileOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/icons/Open16.gif"))); // NOI18N
|
||||
FileOpen.setMnemonic('o');
|
||||
FileOpen.setText("Open");
|
||||
FileOpen.setToolTipText("Open a selected File");
|
||||
jmFile.add(FileOpen);
|
||||
|
||||
FileSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_DOWN_MASK));
|
||||
FileSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/icons/Save16.gif"))); // NOI18N
|
||||
FileSave.setText("Save");
|
||||
FileSave.setToolTipText("Save a file");
|
||||
jmFile.add(FileSave);
|
||||
|
||||
jMainMenu.add(jmFile);
|
||||
|
||||
jMenu2.setText("Edit");
|
||||
|
||||
miUndo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_DOWN_MASK));
|
||||
miUndo.setText("Undo");
|
||||
miUndo.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
miUndoActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jMenu2.add(miUndo);
|
||||
|
||||
jMainMenu.add(jMenu2);
|
||||
|
||||
setJMenuBar(jMainMenu);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jpmainpanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jpmainpanel, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jpopEintragLoeschenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jpopEintragLoeschenActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jpopEintragLoeschenActionPerformed
|
||||
|
||||
private void jbOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbOpenActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jbOpenActionPerformed
|
||||
|
||||
private void miUndoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miUndoActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_miUndoActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the form */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new MainWindow().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JMenuItem FileOpen;
|
||||
private javax.swing.JMenuItem FileSave;
|
||||
private javax.swing.JFileChooser jFileChooser;
|
||||
private javax.swing.JMenuBar jMainMenu;
|
||||
private javax.swing.JMenu jMenu2;
|
||||
private javax.swing.JScrollPane jSPAdressPane;
|
||||
private javax.swing.JTable jTableAdressen;
|
||||
private javax.swing.JButton jbOpen;
|
||||
private javax.swing.JButton jbSave;
|
||||
private javax.swing.JMenu jmFile;
|
||||
private javax.swing.JPanel jpmainpanel;
|
||||
private javax.swing.JMenuItem jpopEintragHinzufuegen;
|
||||
private javax.swing.JMenuItem jpopEintragLoeschen;
|
||||
private javax.swing.JPopupMenu jpopMenu;
|
||||
private javax.swing.JToolBar jtbmaintoolbar;
|
||||
private javax.swing.JMenuItem miUndo;
|
||||
private javax.swing.JLabel statusbar;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
/**
|
||||
* @return the FileOpen
|
||||
*/
|
||||
public javax.swing.JMenuItem getFileOpen() {
|
||||
return FileOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the FileSave
|
||||
*/
|
||||
public javax.swing.JMenuItem getFileSave() {
|
||||
return FileSave;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the jbOpen
|
||||
*/
|
||||
public javax.swing.JButton getJbOpen() {
|
||||
return jbOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the jbSave
|
||||
*/
|
||||
public javax.swing.JButton getJbSave() {
|
||||
return jbSave;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the jFileChooser1
|
||||
*/
|
||||
public javax.swing.JFileChooser getjFileChooser() {
|
||||
return jFileChooser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the statusbar
|
||||
*/
|
||||
public javax.swing.JLabel getStatusbar() {
|
||||
return statusbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the jTableAdressen
|
||||
*/
|
||||
public javax.swing.JTable getjTableAdressen() {
|
||||
return jTableAdressen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jTableAdressen the jTableAdressen to set
|
||||
*/
|
||||
public void setjTableAdressen(javax.swing.JTable jTableAdressen) {
|
||||
this.jTableAdressen = jTableAdressen;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 228 B |
Binary file not shown.
|
After Width: | Height: | Size: 206 B |
Binary file not shown.
|
After Width: | Height: | Size: 239 B |
Reference in New Issue
Block a user