super();  JSplitPane splitter; JScrollPane listScroller, resultScroller; JPanel upperPanel, buttonPanel, lowerPanel;  autWin = _autWin;  upperPanel = new JPanel(new BorderLayout());  newAut = new JButton(new ImageIcon("src/images/stock_new.png")); renAut = new JButton(new ImageIcon("src/images/stock_edit.png")); delAut = new JButton(new ImageIcon("src/images/stock_cancel.png"));  newAut.setToolTipText("neuen Automaten einfgen"); renAut.setToolTipText("gewhlten Automat umbennen"); delAut.setToolTipText("gewhlten Automat entfernen");  autList = new JList(); autList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listModel = new DefaultListModel(); autList.setModel(listModel); lastSel = -1; listData = new LinkedList<FSA>();  listScroller = new JScrollPane(autList);  upperPanel.add(listScroller, BorderLayout.CENTER);  buttonPanel = new JPanel();  buttonPanel.add(newAut); buttonPanel.add(renAut); buttonPanel.add(delAut);   delAut.setEnabled(false);  upperPanel.add(buttonPanel, BorderLayout.SOUTH);  results = new JTextArea(); results.setEditable(false); resultScroller = new JScrollPane(results);  lowerPanel = new JPanel(new BorderLayout());  lowerPanel.add(resultScroller, BorderLayout.CENTER); lowerPanel.add(new JButton("Ausgabe lschen"), BorderLayout.SOUTH);  splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upperPanel, lowerPanel); splitter.setResizeWeight(0.55);  this.setLayout(new BorderLayout()); this.add(splitter, BorderLayout.CENTER);   delAut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int lastSelCopy = lastSel; if (lastSelCopy!=-1) { lastSel = -1; listData.remove(lastSelCopy); listModel.removeElementAt(lastSelCopy); autList.setSelectedIndex(listModel.getSize()-1); if (listModel.getSize()<=1) delAut.setEnabled(false); } } });   renAut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newName;  if (lastSel!=-1) { newName = JOptionPane.showInputDialog(autWin, "neuer Name:", listModel.elementAt(lastSel)); newName = newName.trim(); for (int i = 0 ; i <  newName.length()  ; i++ ) { if (!Character.isLetterOrDigit(newName.charAt(i))) { JOptionPane.showMessageDialog(autWin, "Ungltige Zeichen, fr den Automatennamen sind nur Zahlen oder Buchstaben zulssig.", "Fehler", JOptionPane.ERROR_MESSAGE); return; } } listModel.setElementAt(newName, lastSel); autWin.setCurrentName(newName); } } });    newAut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (listModel.getSize()<MAX_AUT) { insertNewAut(); } else { newAut.setEnabled(false); } } });   autList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent ev) { int selection = autList.getSelectedIndex(); if (selection!=lastSel) { if (lastSel!=-1) { listData.set(lastSel, autWin.toFSA()); } lastSel = selection; autWin.insertAut(listData.get(selection)); } } });
super();  JSplitPane splitter; JScrollPane listScroller, resultScroller; JPanel upperPanel, buttonPanel, lowerPanel;  autWin = _autWin;  upperPanel = new JPanel(new BorderLayout());  newAut = new JButton(new ImageIcon("src/images/stock_new.png")); renAut = new JButton(new ImageIcon("src/images/stock_edit.png")); delAut = new JButton(new ImageIcon("src/images/stock_cancel.png"));  newAut.setToolTipText("neuen Automaten einfgen"); renAut.setToolTipText("gewhlten Automat umbennen"); delAut.setToolTipText("gewhlten Automat entfernen");  autList = new JList(); autList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listModel = new DefaultListModel(); autList.setModel(listModel); lastSel = -1; listData = new LinkedList<FSA>();  listScroller = new JScrollPane(autList);  upperPanel.add(listScroller, BorderLayout.CENTER);  buttonPanel = new JPanel();  buttonPanel.add(newAut); buttonPanel.add(renAut); buttonPanel.add(delAut);   delAut.setEnabled(false);  upperPanel.add(buttonPanel, BorderLayout.SOUTH);  results = new JTextArea(); results.setEditable(false); resultScroller = new JScrollPane(results);  lowerPanel = new JPanel(new BorderLayout());  lowerPanel.add(resultScroller, BorderLayout.CENTER); lowerPanel.add(new JButton("Ausgabe lschen"), BorderLayout.SOUTH);  splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upperPanel, lowerPanel); splitter.setResizeWeight(0.55);  this.setLayout(new BorderLayout()); this.add(splitter, BorderLayout.CENTER);   delAut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int lastSelCopy = lastSel; if (lastSelCopy!=-1) { lastSel = -1; listData.remove(lastSelCopy); listModel.removeElementAt(lastSelCopy); autList.setSelectedIndex(listModel.getSize()-1); if (listModel.getSize()<=1) delAut.setEnabled(false); } } });   renAut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newName;  if (lastSel!=-1) { newName = JOptionPane.showInputDialog(autWin, "neuer Name:", listModel.elementAt(lastSel)); if (newName==null) return; newName = newName.trim(); for (int i = 0 ; i <  newName.length()  ; i++ ) { if (!Character.isJavaIdentifierPart(newName.charAt(i))) { JOptionPane.showMessageDialog(autWin, "Ungltige Zeichen, fr den Automatennamen sind nur Zahlen, Buchstaben und '_' zulssig.", "Fehler", JOptionPane.ERROR_MESSAGE); return; } } listModel.setElementAt(newName, lastSel); autWin.setCurrentName(newName); } } });    newAut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (listModel.getSize()<MAX_AUT) { insertNewAut(); } else { newAut.setEnabled(false); } } });   autList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent ev) { int selection = autList.getSelectedIndex(); if (selection!=lastSel) { if (lastSel!=-1) { listData.set(lastSel, autWin.toFSA()); } lastSel = selection; autWin.insertAut(listData.get(selection)); } } });
    public Sidebar(AutWindow _autWin) {	super();	JSplitPane splitter;	JScrollPane listScroller, resultScroller;	JPanel upperPanel, buttonPanel, lowerPanel;			autWin = _autWin;	upperPanel = new JPanel(new BorderLayout());			newAut = new JButton(new ImageIcon("src/images/stock_new.png"));	renAut = new JButton(new ImageIcon("src/images/stock_edit.png"));	delAut = new JButton(new ImageIcon("src/images/stock_cancel.png"));	newAut.setToolTipText("neuen Automaten einfgen");	renAut.setToolTipText("gewhlten Automat umbennen");	delAut.setToolTipText("gewhlten Automat entfernen");			autList = new JList();	autList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);	listModel = new DefaultListModel();		autList.setModel(listModel);	lastSel = -1;	listData = new LinkedList<FSA>();	listScroller = new JScrollPane(autList);			upperPanel.add(listScroller, BorderLayout.CENTER);			buttonPanel = new JPanel();			buttonPanel.add(newAut);	buttonPanel.add(renAut);	buttonPanel.add(delAut);	// initial ist nur ein Automat in der Liste, dieser kann nicht gelscht werden	delAut.setEnabled(false);	upperPanel.add(buttonPanel, BorderLayout.SOUTH);			results = new JTextArea();	results.setEditable(false);	resultScroller = new JScrollPane(results);	lowerPanel = new JPanel(new BorderLayout());			lowerPanel.add(resultScroller, BorderLayout.CENTER);	lowerPanel.add(new JButton("Ausgabe lschen"), BorderLayout.SOUTH);			splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upperPanel, lowerPanel);	splitter.setResizeWeight(0.55);			this.setLayout(new BorderLayout());	this.add(splitter, BorderLayout.CENTER);	// entfernen den gewhlten Automaten	delAut.addActionListener(new ActionListener() {		public void actionPerformed(ActionEvent e) {		    int lastSelCopy = lastSel;		    if (lastSelCopy!=-1) {			lastSel = -1;			listData.remove(lastSelCopy);			listModel.removeElementAt(lastSelCopy);			autList.setSelectedIndex(listModel.getSize()-1);			if (listModel.getSize()<=1)			    delAut.setEnabled(false);		    }		}	    });		// zeigt ein Dialogfenster mit dem der Automatenname gendert werden kann	renAut.addActionListener(new ActionListener() {		public void actionPerformed(ActionEvent e) {		    String newName;		    if (lastSel!=-1) {			newName = JOptionPane.showInputDialog(autWin, "neuer Name:", 						    listModel.elementAt(lastSel));			newName = newName.trim();			for (int i = 0 ; i <  newName.length()  ; i++ ) {			    if (!Character.isLetterOrDigit(newName.charAt(i))) {				JOptionPane.showMessageDialog(autWin,							      "Ungltige Zeichen, fr den Automatennamen sind nur Zahlen oder Buchstaben zulssig.", 							      "Fehler", JOptionPane.ERROR_MESSAGE);				return;			    }			}			listModel.setElementAt(newName, lastSel);			autWin.setCurrentName(newName);		    }		}	    });	// fge einen neuen Automaten in die Liste ein, bis zur Obergrenze	newAut.addActionListener(new ActionListener() {		public void actionPerformed(ActionEvent e) {		    if (listModel.getSize()<MAX_AUT) {			insertNewAut();		    }		    else {			newAut.setEnabled(false);		    }		}	    });	autList.addListSelectionListener(new ListSelectionListener() {		public void valueChanged(ListSelectionEvent ev) {		    int selection = autList.getSelectedIndex();		    if (selection!=lastSel) {			if (lastSel!=-1) {			    listData.set(lastSel, autWin.toFSA());			}			lastSel = selection;			autWin.insertAut(listData.get(selection));		    }		}	    });    }