package buecher;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import javax.swing.WindowConstants;
import buecher.Buecherausleihe.Ereignisabhoerer;
public class Kundenanlage extends JFrame {
Kunden k[] = new Kunden[10]; // @jve:decl-index=0:
private Ereignisabhoerer ea1 = new Ereignisabhoerer(); // @jve:decl-index=0:
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
private JTextField jTextField = null;
private JTextField jTextField2 = null;
private JTextField jTextField3 = null;
private JButton anl = null;
private JLabel knr = null;
private JTextField textf = null;
private JLabel kunden = null;
private JTextArea jTextArea = null;
private JScrollPane jScrollPane = null;
public Kundenanlage() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(577, 350);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
}
});
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
kunden = new JLabel();
kunden.setBounds(new Rectangle(426, 157, 128, 18));
kunden.setText("Kunden: (Anzeige)");
knr = new JLabel();
knr.setBounds(new Rectangle(438, 36, 85, 32));
knr.setText("Knr vergeben:");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(30, 172, 143, 38));
jLabel3.setText("Ort :");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(31, 107, 139, 38));
jLabel2.setText("Straße :");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(31, 45, 137, 36));
jLabel1.setText("Name :");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(jLabel3, null);
jContentPane.add(getJTextField(), null);
jContentPane.add(getJTextField2(), null);
jContentPane.add(getJTextField3(), null);
jContentPane.add(getAnl(), null);
jContentPane.add(knr, null);
jContentPane.add(getTextf(), null);
jContentPane.add(kunden, null);
jContentPane.add(getJTextArea(), null);
jContentPane.add(getJScrollPane(), null);
}
return jContentPane;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(211, 44, 160, 37));
}
return jTextField;
}
/**
* This method initializes jTextField2
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField2() {
if (jTextField2 == null) {
jTextField2 = new JTextField();
jTextField2.setBounds(new Rectangle(210, 107, 163, 33));
}
return jTextField2;
}
/**
* This method initializes jTextField3
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField3() {
if (jTextField3 == null) {
jTextField3 = new JTextField();
jTextField3.setBounds(new Rectangle(211, 175, 162, 31));
}
return jTextField3;
}
/**
* This method initializes anl
*
* @return javax.swing.JButton
*/
private JButton getAnl() {
if (anl == null) {
anl = new JButton();
anl.setBounds(new Rectangle(124, 239, 151, 40));
anl.setText("Anlegen");
anl.addActionListener(ea1);
}
return anl;
}
/**
* This method initializes textf
*
* @return javax.swing.JTextField
*/
private JTextField getTextf() {
if (textf == null) {
textf = new JTextField();
textf.setBounds(new Rectangle(438, 82, 81, 49));
textf.setEditable(false);
}
return textf;
}
/**
* This method initializes jTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setBounds(new Rectangle(405, 184, 155, 124));
jTextArea.setColumns(1);
}
return jTextArea;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane(jTextArea);
jScrollPane.setBounds(new Rectangle(406, 186, 154, 122));
jScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
return jScrollPane;
}
public class Ereignisabhoerer implements ActionListener {
public void actionPerformed(ActionEvent arg0) {
for(int i=1; i<=10 ;i++){
if(k[i] == null){
anlegen(i);
break;
}
}
}
private void anlegen(int i) {
if(k[i] == null){
textf.setText(Integer.toString(i));
k[i] = new Kunden();
k[i].setKname(jTextField.getText());
k[i].setKstra(jTextField2.getText());
k[i].setKort(jTextField3.getText());
//
// k[i] = new Kunden(jTextField.getText(),jTextField2.getText(),jTextField3.getText());
jTextField.setText(null);
jTextField2.setText(null);
jTextField3.setText(null);
jTextArea.append("\nName: "+k[i].getKname()+ "\nStraße: "+k[i].getKstra()+"\nOrt:"+
k[i].getKort()+"\nKnr:"+i+"\n");
System.out.println(i);
}
}
public void kundendatenausgabe(){
for(int i=0;i<k.length;i++){
System.out.println("\nName: "+k[i].getKname()+ "\nStraße: "+k[i].getKstra()+"\nOrt:"+
k[i].getKort()+"\nKnr:"+i+"\n");
}
}
}
}