commit efac852d3de5576a34837fd3f4ca28af19c2ae8d Author: jechowma68968 Date: Wed Oct 30 10:14:34 2019 +0100 Numer 1 - Have fun! diff --git a/src/controller/ControllerOeffnen.java b/src/controller/ControllerOeffnen.java new file mode 100644 index 0000000..4af8db3 --- /dev/null +++ b/src/controller/ControllerOeffnen.java @@ -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 controller; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import javax.swing.JFileChooser; +import prfourgui.View.AdressbuchView; + +/** + * + * @author baumannan68085 + */ +public class ControllerOeffnen implements ActionListener +{ + private AdressbuchView view; + + public ControllerOeffnen(AdressbuchView view) + { + this.view = view; + } + + public void registerEvents(){ + view.getMnuOpen().addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent ae) + { + JFileChooser fc = view.getjFileChooser1(); + int wahl = fc.showOpenDialog(view); + if(wahl == JFileChooser.APPROVE_OPTION){ + File datei = fc.getSelectedFile(); + String dateiname = datei.getAbsolutePath(); + view.getTxtStatus().setText("Dateipfad:" + dateiname); + + } + + } +} diff --git a/src/prfourgui/Icons/Delete24.gif b/src/prfourgui/Icons/Delete24.gif new file mode 100644 index 0000000..96d799a Binary files /dev/null and b/src/prfourgui/Icons/Delete24.gif differ diff --git a/src/prfourgui/Icons/New24.gif b/src/prfourgui/Icons/New24.gif new file mode 100644 index 0000000..1cc488d Binary files /dev/null and b/src/prfourgui/Icons/New24.gif differ diff --git a/src/prfourgui/Icons/Open24.gif b/src/prfourgui/Icons/Open24.gif new file mode 100644 index 0000000..2086bc2 Binary files /dev/null and b/src/prfourgui/Icons/Open24.gif differ diff --git a/src/prfourgui/Icons/Save24.gif b/src/prfourgui/Icons/Save24.gif new file mode 100644 index 0000000..bfa98a8 Binary files /dev/null and b/src/prfourgui/Icons/Save24.gif differ diff --git a/src/prfourgui/Start.java b/src/prfourgui/Start.java new file mode 100644 index 0000000..6ba5860 --- /dev/null +++ b/src/prfourgui/Start.java @@ -0,0 +1,35 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package prfourgui; + +import controller.ControllerOeffnen; +import prfourgui.View.AdressbuchView; + +/** + * Builder Class + * @author baumannan68085 + */ +public class Start +{ + public Start() + { + AdressbuchView view = new AdressbuchView(); + ControllerOeffnen ctrlOeffnen = new ControllerOeffnen(view); + ctrlOeffnen.registerEvents(); + view.setVisible(true); + + + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) + { + new Start(); + } +} diff --git a/src/prfourgui/View/AdressTable.form b/src/prfourgui/View/AdressTable.form new file mode 100644 index 0000000..fe67fd2 --- /dev/null +++ b/src/prfourgui/View/AdressTable.form @@ -0,0 +1,89 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + <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> + <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="jPopupMenu1"/> + </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> +</Form> diff --git a/src/prfourgui/View/AdressTable.java b/src/prfourgui/View/AdressTable.java new file mode 100644 index 0000000..76a7f89 --- /dev/null +++ b/src/prfourgui/View/AdressTable.java @@ -0,0 +1,70 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package prfourgui.View; + +/** + * + * @author baumannan68085 + */ +public class AdressTable extends javax.swing.JPanel +{ + + /** + * Creates new form AdressTable + */ + public AdressTable() + { + 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() + { + + jPopupMenu1 = new javax.swing.JPopupMenu(); + jMenuItem1 = new javax.swing.JMenuItem(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + + jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Delete24.gif"))); // NOI18N + jMenuItem1.setText("Remove"); + jPopupMenu1.add(jMenuItem1); + + setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS)); + + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] + { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] + { + "Name", "Telefon", "Mobil", "E-Mail" + } + )); + jTable1.setComponentPopupMenu(jPopupMenu1); + jScrollPane1.setViewportView(jTable1); + + add(jScrollPane1); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JMenuItem jMenuItem1; + private javax.swing.JPopupMenu jPopupMenu1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTable jTable1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/prfourgui/View/AdressbuchView.form b/src/prfourgui/View/AdressbuchView.form new file mode 100644 index 0000000..7d7de59 --- /dev/null +++ b/src/prfourgui/View/AdressbuchView.form @@ -0,0 +1,142 @@ +<?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="jFileChooser1"> + </Component> + <Menu class="javax.swing.JMenuBar" name="mnuMain"> + <SubComponents> + <Menu class="javax.swing.JMenu" name="mnuDatei"> + <Properties> + <Property name="mnemonic" type="int" value="68"/> + <Property name="text" type="java.lang.String" value="Datei"/> + </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="/prfourgui/Icons/Open24.gif"/> + </Property> + <Property name="mnemonic" type="int" value="79"/> + <Property name="text" type="java.lang.String" value="Open"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mnuOpenActionPerformed"/> + </Events> + </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="/prfourgui/Icons/Save24.gif"/> + </Property> + <Property name="mnemonic" type="int" value="83"/> + <Property name="text" type="java.lang.String" value="Save"/> + <Property name="toolTipText" type="java.lang.String" value=""/> + </Properties> + </MenuItem> + </SubComponents> + </Menu> + </SubComponents> + </Menu> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="menuBar" type="java.lang.String" value="mnuMain"/> + <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"/> + <AuxValue name="designerSize" 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,-126,0,0,2,17"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JToolBar" name="toolBar"> + <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="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="toolAdd"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/prfourgui/Icons/New24.gif"/> + </Property> + <Property name="mnemonic" type="int" value="65"/> + <Property name="toolTipText" type="java.lang.String" value="Add Address"/> + <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="toolRemove"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/prfourgui/Icons/Delete24.gif"/> + </Property> + <Property name="mnemonic" type="int" value="82"/> + <Property name="toolTipText" type="java.lang.String" value="Remove Address"/> + <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="prfourgui.View.AdressTable" name="adressTable2"> + <Properties> + <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="default"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="pnStatus"> + <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="Last"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtStatus"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/prfourgui/View/AdressbuchView.java b/src/prfourgui/View/AdressbuchView.java new file mode 100644 index 0000000..cf61bd5 --- /dev/null +++ b/src/prfourgui/View/AdressbuchView.java @@ -0,0 +1,228 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package prfourgui.View; + +/** + * + * @author baumannan68085 + */ +public class AdressbuchView extends javax.swing.JFrame +{ + + /** + * Creates new form AdressbuchView + */ + public AdressbuchView() + { + 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() + { + + jFileChooser1 = new javax.swing.JFileChooser(); + toolBar = new javax.swing.JToolBar(); + toolAdd = new javax.swing.JButton(); + toolRemove = new javax.swing.JButton(); + adressTable2 = new prfourgui.View.AdressTable(); + pnStatus = new javax.swing.JScrollPane(); + txtStatus = new javax.swing.JTextArea(); + mnuMain = new javax.swing.JMenuBar(); + mnuDatei = new javax.swing.JMenu(); + mnuOpen = new javax.swing.JMenuItem(); + mnuSave = new javax.swing.JMenuItem(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + toolBar.setRollover(true); + + toolAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/New24.gif"))); // NOI18N + toolAdd.setMnemonic('A'); + toolAdd.setToolTipText("Add Address"); + toolAdd.setFocusable(false); + toolAdd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + toolAdd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + toolBar.add(toolAdd); + + toolRemove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Delete24.gif"))); // NOI18N + toolRemove.setMnemonic('R'); + toolRemove.setToolTipText("Remove Address"); + toolRemove.setFocusable(false); + toolRemove.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + toolRemove.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + toolBar.add(toolRemove); + + getContentPane().add(toolBar, java.awt.BorderLayout.NORTH); + + getContentPane().add(adressTable2, java.awt.BorderLayout.CENTER); + + txtStatus.setColumns(20); + txtStatus.setRows(5); + pnStatus.setViewportView(txtStatus); + + getContentPane().add(pnStatus, java.awt.BorderLayout.PAGE_END); + + mnuDatei.setMnemonic('D'); + mnuDatei.setText("Datei"); + + mnuOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); + mnuOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Open24.gif"))); // NOI18N + mnuOpen.setMnemonic('O'); + mnuOpen.setText("Open"); + mnuOpen.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + mnuOpenActionPerformed(evt); + } + }); + mnuDatei.add(mnuOpen); + + mnuSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); + mnuSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/prfourgui/Icons/Save24.gif"))); // NOI18N + mnuSave.setMnemonic('S'); + mnuSave.setText("Save"); + mnuSave.setToolTipText(""); + mnuDatei.add(mnuSave); + + mnuMain.add(mnuDatei); + + setJMenuBar(mnuMain); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void mnuOpenActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_mnuOpenActionPerformed + {//GEN-HEADEREND:event_mnuOpenActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_mnuOpenActionPerformed + + /** + * @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(AdressbuchView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + catch (InstantiationException ex) + { + java.util.logging.Logger.getLogger(AdressbuchView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + catch (IllegalAccessException ex) + { + java.util.logging.Logger.getLogger(AdressbuchView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + catch (javax.swing.UnsupportedLookAndFeelException ex) + { + java.util.logging.Logger.getLogger(AdressbuchView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() + { + public void run() + { + new AdressbuchView().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private prfourgui.View.AdressTable adressTable2; + private javax.swing.JFileChooser jFileChooser1; + private javax.swing.JMenu mnuDatei; + private javax.swing.JMenuBar mnuMain; + private javax.swing.JMenuItem mnuOpen; + private javax.swing.JMenuItem mnuSave; + private javax.swing.JScrollPane pnStatus; + private javax.swing.JButton toolAdd; + private javax.swing.JToolBar toolBar; + private javax.swing.JButton toolRemove; + private javax.swing.JTextArea txtStatus; + // End of variables declaration//GEN-END:variables + + /** + * @return the mnuOpen + */ + public javax.swing.JMenuItem getMnuOpen() + { + return mnuOpen; + } + + /** + * @return the mnuSave + */ + public javax.swing.JMenuItem getMnuSave() + { + return mnuSave; + } + + /** + * @return the toolAdd + */ + public javax.swing.JButton getToolAdd() + { + return toolAdd; + } + + /** + * @return the toolRemove + */ + public javax.swing.JButton getToolRemove() + { + return toolRemove; + } + + /** + * @return the jFileChooser1 + */ + public javax.swing.JFileChooser getjFileChooser1() + { + return jFileChooser1; + } + + /** + * @return the txtStatus + */ + public javax.swing.JTextArea getTxtStatus() + { + return txtStatus; + } + + /** + * @param txtStatus the txtStatus to set + */ + public void setTxtStatus(javax.swing.JTextArea txtStatus) + { + this.txtStatus = txtStatus; + } +}