TWiki . Catch0405 . GuiProgram

/*
 * Created on Dec 28, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author t100671
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */


import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class DataInputGui implements ActionListener {

   String returnMsg;

   JTextField textField2 = new JTextField(20);
   JTextField textField3 = new JTextField(20);
   JTextField textField4 = new JTextField(20);
   JTextField textField5 = new JTextField(20);
   JTextField textField6 = new JTextField(20);
   JTextField textField7 = new JTextField(20);
   JTextField textField8 = new JTextField(20);
   JTextField textField9 = new JTextField(20);
   JTextField textField10 = new JTextField(20);
   JTextField textField11 = new JTextField(20);
   JTextField textField12 = new JTextField(20);
   JTextField textField13 = new JTextField(20);
   JTextField textField14 = new JTextField(20);
   JTextField textField15 = new JTextField(20);

   JTextField returnField = new JTextField(40);

   public DataInputGui() {

      JLabel label2 = new JLabel("Haustyp");
      JLabel label3 = new JLabel("Anzahl");
      JLabel label4 = new JLabel("Name");
      JLabel label5 = new JLabel("Nname");
      JLabel label6 = new JLabel("Breite");
      JLabel label7 = new JLabel("Tiefe");
      JLabel label8 = new JLabel("Fläche");
      JLabel label9 = new JLabel("r");
      JLabel label10 = new JLabel("g");
      JLabel label11 = new JLabel("b");
      JLabel label12 = new JLabel("strasse");
      JLabel label13 = new JLabel("wasser");
      JLabel label14 = new JLabel("gruen");
      JLabel label15 = new JLabel("nix");

      //Create and set up the window.
      JFrame frame = new JFrame("generisches gui");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      
      JFrame.setDefaultLookAndFeelDecorated(true);

      JPanel panel = new JPanel();
      frame.getContentPane().add(panel);
      panel.setLayout(new GridLayout(16, 2));

      JButton saveDataButton = new JButton("save data now");
      saveDataButton.addActionListener(this);
      panel.add(saveDataButton);

      JLabel label = new JLabel("    inputfields :");
      panel.add(label);

      panel.add(label2);
      panel.add(textField2);

      panel.add(label3);
      panel.add(textField3);

      panel.add(label4);
      panel.add(textField4);

      panel.add(label5);
      panel.add(textField5);

      panel.add(label6);
      panel.add(textField6);

      panel.add(label7);
      panel.add(textField7);

      panel.add(label8);
      panel.add(textField8);

      panel.add(label9);
      panel.add(textField9);

      panel.add(label10);
      panel.add(textField10);

      panel.add(label11);
      panel.add(textField11);

      panel.add(label12);
      panel.add(textField12);

      panel.add(label13);
      panel.add(textField13);

      panel.add(label14);
      panel.add(textField14);

      panel.add(label15);
      panel.add(textField15);

      JLabel returnStatus = new JLabel("return status: ");
      panel.add(returnStatus);
      panel.add(returnField);

      //Display the window.
      frame.pack();
      frame.setSize(600, 600);
      frame.setVisible(true);

   }

   public void actionPerformed(ActionEvent e) {

      System.out.println("textField2 :" + textField2.getText());
      System.out.println("textField3 :" + textField3.getText());
      System.out.println("textField4 :" + textField4.getText());
      System.out.println("textField5 :" + textField5.getText());
      System.out.println("textField6 :" + textField6.getText());
      System.out.println("textField7 :" + textField7.getText());
      System.out.println("textField8 :" + textField8.getText());
      System.out.println("textField9 :" + textField9.getText());
      System.out.println("textField10 :" + textField10.getText());
      System.out.println("textField11 :" + textField11.getText());
      System.out.println("textField12 :" + textField12.getText());
      System.out.println("textField13 :" + textField13.getText());
      System.out.println("textField14 :" + textField14.getText());
      System.out.println("textField15 :" + textField15.getText());

      String[] array = { textField2.getText(), 
                       textField3.getText(),
                       textField4.getText(), 
                     textField5.getText(),
                       textField6.getText(), 
                     textField7.getText(),
                       textField8.getText(), 
                     textField9.getText(),
                       textField10.getText(), 
                     textField11.getText(),
                       textField12.getText(), 
                     textField13.getText(),
                       textField14.getText(), 
                     textField15.getText() };

      StoreData storeData = new StoreData();
      returnMsg = storeData.store(array);
      returnField.setText(returnMsg);
      
      //clear data in textfields          
      textField2.setText("");
      textField3.setText("");
      textField4.setText("");
      textField5.setText("");
      textField6.setText("");
      textField7.setText("");
      textField8.setText("");
      textField9.setText("");
      textField10.setText("");
      textField11.setText("");
      textField12.setText("");
      textField13.setText("");
      textField14.setText("");
      textField15.setText("");
   }
}



-- OtherDenisRaschpichler - 30 Dec 2004

----- Revision r1.1 - 30 Dec 2004 - 11:15 - OtherDenisRaschpichler
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

This website has been archived and is no longer maintained.