package filetree;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
public class Software extends JFrame {
private static final long serialVersionUID = 1L;
JButton startProgramm;
JLabel vorname;
JLabel nachname;
JLabel datum;
JLabel zeit;
JButton openTree;
JLabel chosenPath;
JLabel path;
JList liste;
DefaultListModel listModel;
File[] array;
boolean btnVorhanden;
SoftwareListener softwareListener;
public Software() {
btnVorhanden = false;
setSize(800, 600);
setLocationRelativeTo(null);
setResizable(false);
setVisible(true);
setTitle("Bitte wählen Sie eine Datei aus");
setLayout(new BorderLayout());
chosenPath = new JLabel("Gewählter Pfad");
chosenPath.setBounds(140, 10, 150, 40);
add(chosenPath, BorderLayout.NORTH);
path = new JLabel("");
path.setBounds(300, 10, 400, 40);
add(path, BorderLayout.NORTH);
openTree = new JButton("Pfad wählen");
softwareListener = new SoftwareListener(this);
openTree.addActionListener(softwareListener);
openTree.setBounds(10, 10, 110, 30);
add(openTree, BorderLayout.NORTH);
liste = new JList();
JScrollPane scrollableList = new JScrollPane(liste);
liste.setFont(new Font("Courier New",Font.BOLD, 14));
//listModel = new DefaultListModel();
liste.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//liste.setBounds(20, 60, 600, 500);
//add(liste);
scrollableList.setBounds(20, 100, 600, 400);
add(scrollableList, BorderLayout.CENTER);
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
liste = (JList) e.getSource();
if (btnVorhanden == false) {
startProgramm = new JButton();
startProgramm.setBounds(650, 150, 100, 50);
add(startProgramm, BorderLayout.EAST);
btnVorhanden = true;
}
}
};
liste.addMouseListener(mouseListener);
vorname = new JLabel("Vorname:");
vorname.setFont(new Font("Courier New",Font.BOLD, 14));
vorname.setBounds(20, 60, 160, 40);
add(vorname);
nachname = new JLabel("Nachname:");
nachname.setFont(new Font("Courier New",Font.BOLD, 14));
nachname.setBounds(160, 60, 160, 40);
add(nachname);
datum = new JLabel("Datum:");
datum.setFont(new Font("Courier New",Font.BOLD, 14));
datum.setBounds(310, 60, 160, 40);
add(datum);
zeit = new JLabel("Zeit:");
zeit.setFont(new Font("Courier New",Font.BOLD, 14));
zeit.setBounds(450, 60, 160, 40);
add(zeit);
}
public static void main(String[] args) {
Software fenster = new Software();
}
}