diff --git a/cicaprojekt/ApplicationFrame.java b/cicaprojekt/ApplicationFrame.java index 6b364db..89e0151 100644 --- a/cicaprojekt/ApplicationFrame.java +++ b/cicaprojekt/ApplicationFrame.java @@ -3,6 +3,7 @@ package cicaprojekt; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.plaf.basic.BasicInternalFrameTitlePane; +import java.awt.*; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -10,32 +11,42 @@ import java.util.List; public class ApplicationFrame implements Runnable { private JFrame jframe; + private JPanel mapselectorpanel; private JPanel gamepanel; + private JList filelist; + public ApplicationFrame(){} public void init(){ jframe = new JFrame(); + jframe.setMinimumSize(new Dimension(600, 400)); + mapselectorpanel = new JPanel(); - List dungeons = new ArrayList<>(); + DefaultListModel dungeonslist = new DefaultListModel<>(); File dir = new File(System.getProperty("user.dir")); - FileNameExtensionFilter filter = new FileNameExtensionFilter("dungeon"); + FileNameExtensionFilter filter = new FileNameExtensionFilter("N/A", "dungeon"); for (File f : dir.listFiles()) { - if (filter.accept(f)){ - dungeons.add(f); + if (filter.accept(f) && f.isFile()){ + dungeonslist.addElement(f); } } - //TODO create a JTable and put it into mapselectorpanel + filelist = new JList<>(dungeonslist); + filelist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + filelist.setLayoutOrientation(JList.HORIZONTAL_WRAP); + + mapselectorpanel.add(filelist); + + jframe.add(mapselectorpanel); } @Override - public void run() - { - + public void run() { + jframe.setVisible(true); } }