Dateien hochladen nach „“
initial commit
This commit is contained in:
parent
6095e99bbf
commit
9a8663bb44
172
AdressmanagementModel.java
Normal file
172
AdressmanagementModel.java
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
///*
|
||||||
|
// * 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 adressmanagement.model;
|
||||||
|
//
|
||||||
|
//import java.io.BufferedInputStream;
|
||||||
|
//import java.io.BufferedReader;
|
||||||
|
//import java.io.File;
|
||||||
|
//import java.io.FileInputStream;
|
||||||
|
//import java.io.FileNotFoundException;
|
||||||
|
//import java.io.IOException;
|
||||||
|
//import java.io.InputStreamReader;
|
||||||
|
//import java.io.UnsupportedEncodingException;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// *
|
||||||
|
// * @author chris
|
||||||
|
// */
|
||||||
|
//public class AdressmanagementModel
|
||||||
|
//{
|
||||||
|
// private String text;
|
||||||
|
// public AdressmanagementModel()
|
||||||
|
// {
|
||||||
|
// text = "?";
|
||||||
|
// }
|
||||||
|
// public String getText()
|
||||||
|
// {
|
||||||
|
// return text;
|
||||||
|
// }
|
||||||
|
// public void readFromFile(File f) throws FileNotFoundException, UnsupportedEncodingException, IOException
|
||||||
|
// {
|
||||||
|
// //Streams
|
||||||
|
// FileInputStream fis = new FileInputStream(f);
|
||||||
|
// InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
|
||||||
|
// BufferedReader in = new BufferedReader(isr);
|
||||||
|
// StringBuilder data = new StringBuilder();
|
||||||
|
// String line = "";
|
||||||
|
// while((line = in.readLine()) != null)
|
||||||
|
// {
|
||||||
|
// data.append(line);
|
||||||
|
// data.append("\n");
|
||||||
|
// }
|
||||||
|
// text = data.toString();
|
||||||
|
// in.close();
|
||||||
|
// //BufferedInputStream bin = new BufferedInputStream(fis);
|
||||||
|
// //WICHTIG: ObjectInputStream, ObjectOutputStream --> readObject oder writeObject = Serialisierung und damit Persistenz
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
///*
|
||||||
|
// * 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 adressmanagement.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 AdressmanagementModel extends AbstractTableModel
|
||||||
|
{
|
||||||
|
private ArrayList<ArrayList<String>> daten;
|
||||||
|
private ArrayList<String> adressEintraegeDaten;
|
||||||
|
private ArrayList<String> adressEintraegeNamen;
|
||||||
|
|
||||||
|
public AdressmanagementModel()
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
161
AdressmanagementView.form
Normal file
161
AdressmanagementView.form
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||||
|
<NonVisualComponents>
|
||||||
|
<Component class="javax.swing.JFileChooser" name="FileChooser">
|
||||||
|
</Component>
|
||||||
|
<Container class="javax.swing.JPopupMenu" name="pmFile">
|
||||||
|
|
||||||
|
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||||
|
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<MenuItem class="javax.swing.JMenuItem" name="pmOpen">
|
||||||
|
<Properties>
|
||||||
|
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||||
|
<Image iconType="3" name="/adressmanagement/view/icons/Open24.gif"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" value="Open"/>
|
||||||
|
</Properties>
|
||||||
|
</MenuItem>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
<Menu class="javax.swing.JMenuBar" name="Menu">
|
||||||
|
<SubComponents>
|
||||||
|
<Menu class="javax.swing.JMenu" name="mnuFile">
|
||||||
|
<Properties>
|
||||||
|
<Property name="mnemonic" type="int" value="70"/>
|
||||||
|
<Property name="text" type="java.lang.String" value="File"/>
|
||||||
|
</Properties>
|
||||||
|
<SubComponents>
|
||||||
|
<MenuItem class="javax.swing.JMenuItem" name="mnuOpen">
|
||||||
|
<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="/adressmanagement/view/icons/Open24.gif"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="text" type="java.lang.String" value="Open"/>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||||
|
</Properties>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem class="javax.swing.JMenuItem" name="mnuSave">
|
||||||
|
<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="/adressmanagement/view/icons/Save24.gif"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="text" type="java.lang.String" value="Save"/>
|
||||||
|
</Properties>
|
||||||
|
</MenuItem>
|
||||||
|
</SubComponents>
|
||||||
|
</Menu>
|
||||||
|
<Menu class="javax.swing.JMenu" name="mnuEdit">
|
||||||
|
<Properties>
|
||||||
|
<Property name="mnemonic" type="int" value="69"/>
|
||||||
|
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||||
|
</Properties>
|
||||||
|
</Menu>
|
||||||
|
</SubComponents>
|
||||||
|
</Menu>
|
||||||
|
</NonVisualComponents>
|
||||||
|
<Properties>
|
||||||
|
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||||
|
<Property name="title" type="java.lang.String" value="Adressverwaltung"/>
|
||||||
|
</Properties>
|
||||||
|
<SyntheticProperties>
|
||||||
|
<SyntheticProperty name="menuBar" type="java.lang.String" value="Menu"/>
|
||||||
|
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-11,0,0,2,-12"/>
|
||||||
|
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
|
||||||
|
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
|
||||||
|
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
|
||||||
|
</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 class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||||
|
<SubComponents>
|
||||||
|
<Container class="javax.swing.JToolBar" name="tbToolbar">
|
||||||
|
<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="btnOpen">
|
||||||
|
<Properties>
|
||||||
|
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||||
|
<Image iconType="3" name="/adressmanagement/view/icons/Open24.gif"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" value="Open"/>
|
||||||
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
|
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||||
|
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="btnSave">
|
||||||
|
<Properties>
|
||||||
|
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||||
|
<Image iconType="3" name="/adressmanagement/view/icons/Save24.gif"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" value="Save"/>
|
||||||
|
<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="lblStatus">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="File:"/>
|
||||||
|
<Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor">
|
||||||
|
<ComponentRef name="pmFile"/>
|
||||||
|
</Property>
|
||||||
|
</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.JPanel" name="mainPanel">
|
||||||
|
<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.DesignGridLayout">
|
||||||
|
<Property name="columns" type="int" value="0"/>
|
||||||
|
<Property name="rows" type="int" value="1"/>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="adressmanagement.view.Table" name="table1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor">
|
||||||
|
<ComponentRef name="default"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
230
AdressmanagementView.java
Normal file
230
AdressmanagementView.java
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
/*
|
||||||
|
* 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 adressmanagement.view;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author chris
|
||||||
|
*/
|
||||||
|
public class AdressmanagementView extends javax.swing.JFrame
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form EditorView
|
||||||
|
*/
|
||||||
|
public AdressmanagementView()
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
|
||||||
|
FileChooser = new javax.swing.JFileChooser();
|
||||||
|
pmFile = new javax.swing.JPopupMenu();
|
||||||
|
pmOpen = new javax.swing.JMenuItem();
|
||||||
|
tbToolbar = new javax.swing.JToolBar();
|
||||||
|
btnOpen = new javax.swing.JButton();
|
||||||
|
btnSave = new javax.swing.JButton();
|
||||||
|
lblStatus = new javax.swing.JLabel();
|
||||||
|
mainPanel = new javax.swing.JPanel();
|
||||||
|
table1 = new adressmanagement.view.Table();
|
||||||
|
Menu = new javax.swing.JMenuBar();
|
||||||
|
mnuFile = new javax.swing.JMenu();
|
||||||
|
mnuOpen = new javax.swing.JMenuItem();
|
||||||
|
mnuSave = new javax.swing.JMenuItem();
|
||||||
|
mnuEdit = new javax.swing.JMenu();
|
||||||
|
|
||||||
|
pmOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/adressmanagement/view/icons/Open24.gif"))); // NOI18N
|
||||||
|
pmOpen.setToolTipText("Open");
|
||||||
|
pmFile.add(pmOpen);
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
setTitle("Adressverwaltung");
|
||||||
|
|
||||||
|
tbToolbar.setRollover(true);
|
||||||
|
|
||||||
|
btnOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/adressmanagement/view/icons/Open24.gif"))); // NOI18N
|
||||||
|
btnOpen.setToolTipText("Open");
|
||||||
|
btnOpen.setFocusable(false);
|
||||||
|
btnOpen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||||
|
btnOpen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||||
|
tbToolbar.add(btnOpen);
|
||||||
|
|
||||||
|
btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/adressmanagement/view/icons/Save24.gif"))); // NOI18N
|
||||||
|
btnSave.setToolTipText("Save");
|
||||||
|
btnSave.setFocusable(false);
|
||||||
|
btnSave.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||||
|
btnSave.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||||
|
tbToolbar.add(btnSave);
|
||||||
|
|
||||||
|
getContentPane().add(tbToolbar, java.awt.BorderLayout.PAGE_START);
|
||||||
|
|
||||||
|
lblStatus.setText("File:");
|
||||||
|
lblStatus.setComponentPopupMenu(pmFile);
|
||||||
|
getContentPane().add(lblStatus, java.awt.BorderLayout.PAGE_END);
|
||||||
|
|
||||||
|
mainPanel.setLayout(new java.awt.GridLayout(1, 0));
|
||||||
|
|
||||||
|
mainPanel.add(table1);
|
||||||
|
|
||||||
|
getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);
|
||||||
|
|
||||||
|
mnuFile.setMnemonic('F');
|
||||||
|
mnuFile.setText("File");
|
||||||
|
|
||||||
|
mnuOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_DOWN_MASK));
|
||||||
|
mnuOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/adressmanagement/view/icons/Open24.gif"))); // NOI18N
|
||||||
|
mnuOpen.setText("Open");
|
||||||
|
mnuOpen.setToolTipText("");
|
||||||
|
mnuFile.add(mnuOpen);
|
||||||
|
|
||||||
|
mnuSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_DOWN_MASK));
|
||||||
|
mnuSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/adressmanagement/view/icons/Save24.gif"))); // NOI18N
|
||||||
|
mnuSave.setText("Save");
|
||||||
|
mnuFile.add(mnuSave);
|
||||||
|
|
||||||
|
Menu.add(mnuFile);
|
||||||
|
|
||||||
|
mnuEdit.setMnemonic('E');
|
||||||
|
mnuEdit.setText("Edit");
|
||||||
|
Menu.add(mnuEdit);
|
||||||
|
|
||||||
|
setJMenuBar(Menu);
|
||||||
|
|
||||||
|
setSize(new java.awt.Dimension(756, 501));
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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(AdressmanagementView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
catch (InstantiationException ex)
|
||||||
|
{
|
||||||
|
java.util.logging.Logger.getLogger(AdressmanagementView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
catch (IllegalAccessException ex)
|
||||||
|
{
|
||||||
|
java.util.logging.Logger.getLogger(AdressmanagementView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
catch (javax.swing.UnsupportedLookAndFeelException ex)
|
||||||
|
{
|
||||||
|
java.util.logging.Logger.getLogger(AdressmanagementView.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 AdressmanagementView().setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JFileChooser FileChooser;
|
||||||
|
private javax.swing.JMenuBar Menu;
|
||||||
|
private javax.swing.JButton btnOpen;
|
||||||
|
private javax.swing.JButton btnSave;
|
||||||
|
private javax.swing.JLabel lblStatus;
|
||||||
|
private javax.swing.JPanel mainPanel;
|
||||||
|
private javax.swing.JMenu mnuEdit;
|
||||||
|
private javax.swing.JMenu mnuFile;
|
||||||
|
private javax.swing.JMenuItem mnuOpen;
|
||||||
|
private javax.swing.JMenuItem mnuSave;
|
||||||
|
private javax.swing.JPopupMenu pmFile;
|
||||||
|
private javax.swing.JMenuItem pmOpen;
|
||||||
|
private adressmanagement.view.Table table1;
|
||||||
|
private javax.swing.JToolBar tbToolbar;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the btnOpen
|
||||||
|
*/
|
||||||
|
public javax.swing.JButton getBtnOpen()
|
||||||
|
{
|
||||||
|
return btnOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the btnSave
|
||||||
|
*/
|
||||||
|
public javax.swing.JButton getBtnSave()
|
||||||
|
{
|
||||||
|
return btnSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the lblStatus
|
||||||
|
*/
|
||||||
|
public javax.swing.JLabel getLblStatus()
|
||||||
|
{
|
||||||
|
return lblStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the mnuOpen
|
||||||
|
*/
|
||||||
|
public javax.swing.JMenuItem getMnuOpen()
|
||||||
|
{
|
||||||
|
return mnuOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the mnuSave
|
||||||
|
*/
|
||||||
|
public javax.swing.JMenuItem getMnuSave()
|
||||||
|
{
|
||||||
|
return mnuSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the pmOpen
|
||||||
|
*/
|
||||||
|
public javax.swing.JMenuItem getPmOpen()
|
||||||
|
{
|
||||||
|
return pmOpen;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the FileChooser
|
||||||
|
*/
|
||||||
|
public javax.swing.JFileChooser getFileChooser()
|
||||||
|
{
|
||||||
|
return FileChooser;
|
||||||
|
}
|
||||||
|
}
|
68
ControllerOpen.java
Normal file
68
ControllerOpen.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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 adressmanagement.controller;
|
||||||
|
|
||||||
|
import adressmanagement.model.AdressmanagementModel;
|
||||||
|
import adressmanagement.view.AdressmanagementView;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author chris
|
||||||
|
*/
|
||||||
|
public class ControllerOpen implements ActionListener
|
||||||
|
{
|
||||||
|
private AdressmanagementView view;
|
||||||
|
private AdressmanagementModel model;
|
||||||
|
|
||||||
|
public ControllerOpen()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllerOpen(AdressmanagementView view, AdressmanagementModel model)
|
||||||
|
{
|
||||||
|
// lasteSelected = Preferences
|
||||||
|
this.view = view;
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerEvents()
|
||||||
|
{
|
||||||
|
view.getBtnOpen().addActionListener(this);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
int choice = view.getFileChooser().showOpenDialog(view);
|
||||||
|
if (choice == JFileChooser.APPROVE_OPTION)
|
||||||
|
{
|
||||||
|
File selectedFile = view.getFileChooser().getSelectedFile();
|
||||||
|
view.getLblStatus().setText("File +" + selectedFile.getAbsolutePath());
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// model.readFromFile(selectedFile);
|
||||||
|
// String text = model.getText();
|
||||||
|
// }
|
||||||
|
// catch (UnsupportedEncodingException ex)
|
||||||
|
// {
|
||||||
|
// view.getLblStatus().setText(ex.toString());
|
||||||
|
// }
|
||||||
|
// catch (IOException ex)
|
||||||
|
// {
|
||||||
|
// view.getLblStatus().setText(ex.toString());
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
45
Start.java
Normal file
45
Start.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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 adressmanagement;
|
||||||
|
|
||||||
|
import adressmanagement.controller.ControllerOpen;
|
||||||
|
import adressmanagement.model.AdressmanagementModel;
|
||||||
|
import adressmanagement.view.AdressmanagementView;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author chris
|
||||||
|
*/
|
||||||
|
public class Start
|
||||||
|
{
|
||||||
|
public Start()
|
||||||
|
{
|
||||||
|
AdressmanagementView view = new AdressmanagementView();
|
||||||
|
AdressmanagementModel model = new AdressmanagementModel();
|
||||||
|
|
||||||
|
ControllerOpen ctrOpen = new ControllerOpen(view, model);
|
||||||
|
ctrOpen.registerEvents();
|
||||||
|
view.setVisible(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog(null, ex.toString());
|
||||||
|
}
|
||||||
|
new Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user