import java.awt.Component;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.filechooser.FileFilter;
import jxl.JXLException;
public class Tool {
/**
* @param args
* @throws IOException
* @throws JXLException
*/
public static void main(String[] args) throws IOException, JXLException {
String SSPTree = "";
JFrame fenster = new JFrame("GridLayout");
fenster.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = fenster.getContentPane();
GridBagLayout gbl = new GridBagLayout();
c.setLayout(gbl);
fenster.setTitle("SSP-Dialog Vergleichstool v1.0");
JTextField SspPfad = new JTextField();
JTextField DialogPfad = new JTextField();
JTextField StopPfad = new JTextField();
JButton SspDurchsuchen = new JButton("Durchsuchen");
SspDurchsuchen.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
chooser.addChoosableFileFilter(new FileFilter() {
public boolean accept(File f) {
if (f.isDirectory()) return true;
return f.getName().toLowerCase().endsWith(".xls");
}
public String getDescription () { return ".xls"; }
});
chooser.setMultiSelectionEnabled(false);
if (chooser.showOpenDialog(fenster) ==
JFileChooser.APPROVE_OPTION)
SSPTree = chooser.getSelectedFile().getAbsolutePath();
System.out.println ("Datei "+chooser.getSelectedFile()+
" ausgewählt.");
SspPfad.setText(SSPTree);
}
});
JButton DialogDurchsuchen = new JButton ("Durchsuchen");
JButton StopDurchsuchen = new JButton("Durchsuchen");
JButton Ausfuhren = new JButton("Ausführen");
JLabel SspText = new JLabel("SSP:");
JLabel DialogText = new JLabel("Dialog:");
JLabel StopText = new JLabel("Stopliste:");
JLabel Titel = new JLabel("Bitte wählen Sie entsprechende Dateien aus");
addComponent( c, gbl, Titel, 0, 0, 3, 1, 1.0 , 0 );
addComponent( c, gbl, SspText, 0, 1, 1, 1, 0 , 0 );
addComponent( c, gbl, SspPfad, 1, 1, 1, 1, 1.0 , 0 );
addComponent( c, gbl, SspDurchsuchen, 2, 1, 1, 1, 0 , 0 );
addComponent( c, gbl, DialogText, 0, 2, 1, 1, 0 , 0 );
addComponent( c, gbl, DialogPfad, 1, 2, 1, 1, 1.0 , 0 );
addComponent( c, gbl, DialogDurchsuchen, 2, 2, 1, 1, 0 , 0 );
addComponent( c, gbl, StopText, 0, 3, 1, 1, 0 , 0 );
addComponent( c, gbl, StopPfad, 1, 3, 1, 1, 1.0 , 0 );
addComponent( c, gbl, StopDurchsuchen, 2, 3, 1, 1, 0 , 0 );
addComponent( c, gbl, Ausfuhren, 2, 4, 1, 1, 0 , 0 );
fenster.setSize(400,200);
fenster.setVisible(true);
}
}