
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;


import java.util.Vector;


public class analyse extends JFrame {
     JTextArea _edit;

    JLabel label1 = new JLabel("Auszuwertender Text");
    JComboBox cbListe;

    JButton BnAction;


  //Frame konstruieren
  public analyse() {
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setSize(800, 600);
    setTitle("Beispiel Analyse");
    setGUI();
  }

  private void setGUI(){
    Vector liste = new Vector();
    liste.add("123 444 5555 6666");
    liste.add("123\t4444\t55555");
    cbListe = new JComboBox(liste);
    cbListe.setEditable(true);

    label1.setFont( new Font("Arial", Font.BOLD,20));
    cbListe.setFont( new Font("Arial", Font.BOLD,20));

    this.getContentPane().setLayout( new GridBagLayout() );

    this.getContentPane().add(label1,
           new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(0,20,0,0), 0, 6));

    this.getContentPane().add(cbListe,
          new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(0,20,0,20), 22, 6));



    BnAction = new JButton( "Ok" );
    BnAction.setFont( new Font("Arial", Font.BOLD,20));

    this.getContentPane().add(BnAction,
          new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(0,20,0,20), 22, 6));

    _edit = new JTextArea("");
    _edit.setFont( new Font("Arial", Font.BOLD,20));
    JScrollPane scrollpane = new JScrollPane(_edit);
    this.getContentPane().add(scrollpane,
          new GridBagConstraints(0, 1, 3, 1, 1.0, 1.0
            ,GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(20,20,0,20), 22, 6));


    BnAction.addActionListener(new java.awt.event.ActionListener() {
       public void actionPerformed(ActionEvent e) {
        BnAction_Click();
       }
    });

  } // create

  private void BnAction_Click() {
    String s="";
    String sStr = (String) cbListe.getSelectedItem();
    sStr = sStr.trim();
    if (sStr.length()>0) {
      int zahlen[] = Analyze(sStr);
      for(int i:zahlen){
		_edit.append( "\n\r"+Integer.toString(i) );
	}
      
    }
  }


  private int [] Analyze(String sStr) {
    String[] sZahlen;
    int [] zahlen;
    int i, intVal;
    // test auf Leerzeichen
	String t = "123##123##123";
	String[] ts = t.split("##");
	for(String s:ts){
		System.out.println(s);
	}

    sZahlen = sStr.split(" ");
    if (sZahlen.length>0) {
      // umwandeln in int-Zahlen
      zahlen = new int[ sZahlen.length ];
      for (i=0; i<sZahlen.length; i++) {
            try {
                System.out.println("z["+i+"] = "+sZahlen[i]);
                intVal = Integer.valueOf( sZahlen[i] ).intValue();                
                zahlen[i]=intVal;
            }
            catch (NumberFormatException e) {
                return null;
            }
      }
	 return zahlen;
    }
    else {
      // Test auf Tab
      sZahlen = sStr.split("\t");
      if (sZahlen.length>0) {
      }
      else {
        Message("Hinweis","Im Text waren keine Leerstelle oder Tabs");
      }
    }
    return null;
  }



    /**
    * description: Zeigt eine Nachricht an
    * @see Message, Yes-No, Yes-No-Esc, Ok-Esc
    *
    * @version     1.0  07.07.2002
    * @author      Michael Wilhelm HS Harz, FB AI
    * @param String sTitle, String sMessage
    * @return keinen
    * @exception keine
    */
  public void Message( String sTitle, String sMessage) {
    JOptionPane.showConfirmDialog(null,sMessage,sTitle,
      JOptionPane.DEFAULT_OPTION,
      JOptionPane.INFORMATION_MESSAGE);  // Symbol
    /*  Optionen der Schalter:
         DEFAULT_OPTION    Ok
         YES_NO_OPTION
         YES_NO_CANCEL_OPTION
         OK_CANCEL_OPTION
     */
     /*  Symbole:
      ERROR_MESSAGE
      INFORMATION_MESSAGE
      WARNING_MESSAGE
      QUESTION_MESSAGE
      PLAIN_MESSAGE
     */

  } // Message



  public static void main(String[] args) {
    analyse frame = new analyse();
    frame.setVisible(true);
  }


}


