Browse Source

Initial Commit

master
Sebastian Schneider 3 years ago
commit
41ba75bd7c

+ 73
- 0
build.xml View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="Adressverwaltung" default="default" basedir=".">
<description>Builds, tests, and runs the project Adressverwaltung.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="Adressverwaltung-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

+ 3
- 0
manifest.mf View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

+ 1770
- 0
nbproject/build-impl.xml
File diff suppressed because it is too large
View File


+ 8
- 0
nbproject/genfiles.properties View File

@@ -0,0 +1,8 @@
build.xml.data.CRC32=d49cad62
build.xml.script.CRC32=bbedcb41
build.xml.stylesheet.CRC32=f85dc8f2@1.96.0.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=d49cad62
nbproject/build-impl.xml.script.CRC32=d791273f
nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.96.0.48

+ 95
- 0
nbproject/project.properties View File

@@ -0,0 +1,95 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.modulepath=\
${run.modulepath}
debug.test.classpath=\
${run.test.classpath}
debug.test.modulepath=\
${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/Adressverwaltung.jar
dist.javadoc.dir=${dist.dir}/javadoc
dist.jlink.dir=${dist.dir}/jlink
dist.jlink.output=${dist.jlink.dir}/Adressverwaltung
excludes=
includes=**
jar.compress=false
javac.classpath=
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.modulepath=
javac.processormodulepath=
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.modulepath=\
${javac.modulepath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.html5=false
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
# The jlink additional root modules to resolve
jlink.additionalmodules=
# The jlink additional command line parameters
jlink.additionalparam=
jlink.launcher=true
jlink.launcher.name=Adressverwaltung
main.class=adressverwaltung.main
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.modulepath=\
${javac.modulepath}
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
run.test.modulepath=\
${javac.test.modulepath}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

+ 15
- 0
nbproject/project.xml View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>Adressverwaltung</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

+ 40
- 0
src/adressverwaltung/main.java View File

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

+ 17
- 0
src/command/CommandInterface.java View File

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

+ 50
- 0
src/command/CommandInvoker.java View File

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

+ 44
- 0
src/command/commands/CommandEintragHinzufuegen.java View File

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

+ 50
- 0
src/command/commands/CommandEintragLoeschen.java View File

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

+ 108
- 0
src/controller/CommandController.java View File

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

+ 43
- 0
src/controller/OpenController.java View File

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

+ 156
- 0
src/model/AdressVerwaltungModel.java View File

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

+ 224
- 0
src/view/MainWindow.form View File

@@ -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&#xfc;gen"/>
</Properties>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jpopEintragLoeschen">
<Properties>
<Property name="text" type="java.lang.String" value="Eintrag l&#xf6;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>

+ 290
- 0
src/view/MainWindow.java View File

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

BIN
src/view/icons/Open16.gif View File


BIN
src/view/icons/Save16.gif View File


BIN
src/view/icons/Undo24.gif View File


Loading…
Cancel
Save