From 5c32997f8b1898107ab6b5cd5241d4df28b6e370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 7 May 2016 16:10:00 +0200 Subject: [PATCH] ApplicationFrame now correctly displays menu with maps on run() --- cicaprojekt/ApplicationFrame.java | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) 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); } }