ApplicationFrame now correctly displays menu with maps on run()

This commit is contained in:
Kjistóf 2016-05-07 16:10:00 +02:00
parent 46ced04536
commit 5c32997f8b

View File

@ -3,6 +3,7 @@ package cicaprojekt;
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane; import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import java.awt.*;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -10,32 +11,42 @@ import java.util.List;
public class ApplicationFrame implements Runnable public class ApplicationFrame implements Runnable
{ {
private JFrame jframe; private JFrame jframe;
private JPanel mapselectorpanel; private JPanel mapselectorpanel;
private JPanel gamepanel; private JPanel gamepanel;
private JList<File> filelist;
public ApplicationFrame(){} public ApplicationFrame(){}
public void init(){ public void init(){
jframe = new JFrame(); jframe = new JFrame();
jframe.setMinimumSize(new Dimension(600, 400));
mapselectorpanel = new JPanel(); mapselectorpanel = new JPanel();
List<File> dungeons = new ArrayList<>(); DefaultListModel<File> dungeonslist = new DefaultListModel<>();
File dir = new File(System.getProperty("user.dir")); 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()) { for (File f : dir.listFiles()) {
if (filter.accept(f)){ if (filter.accept(f) && f.isFile()){
dungeons.add(f); 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 @Override
public void run() public void run() {
{ jframe.setVisible(true);
} }
} }