Implemented main menu

This commit is contained in:
Bokros Bálint 2016-05-14 00:13:29 +02:00
parent 9d551ad376
commit a17de768eb
2 changed files with 28 additions and 3 deletions

BIN
Menu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

View File

@ -1,5 +1,6 @@
package cicaprojekt; package cicaprojekt;
import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*; import java.awt.*;
@ -40,7 +41,7 @@ public class ApplicationFrame implements Runnable
public void init(){ public void init(){
jframe = new JFrame(); jframe = new JFrame();
jframe.setFocusable(true); jframe.setFocusable(true);
jframe.setMinimumSize(new Dimension(600, 400)); jframe.setMinimumSize(new Dimension(640, 395));
jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
initMapselector(); initMapselector();
@ -64,7 +65,18 @@ public class ApplicationFrame implements Runnable
private void initMapselector() { private void initMapselector() {
if(mapselectorpanel != null) if(mapselectorpanel != null)
jframe.remove(mapselectorpanel); jframe.remove(mapselectorpanel);
mapselectorpanel = new JPanel(); mapselectorpanel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
try {
g.drawImage(ImageIO.read(new File("Menu.png")), 0, 0, null);
}
catch (IOException ioe) {
Control.ioErrorMessage();
}
}
};
DefaultListModel<File> dungeonslist = new DefaultListModel<>(); DefaultListModel<File> dungeonslist = new DefaultListModel<>();
File dir = new File(System.getProperty("user.dir")); File dir = new File(System.getProperty("user.dir"));
@ -80,8 +92,21 @@ public class ApplicationFrame implements Runnable
filelist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); filelist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
filelist.setLayoutOrientation(JList.HORIZONTAL_WRAP); filelist.setLayoutOrientation(JList.HORIZONTAL_WRAP);
filelist.addMouseListener(new ListMouseHandler()); filelist.addMouseListener(new ListMouseHandler());
filelist.setMaximumSize(new Dimension(400, 80));
mapselectorpanel.setLayout(new BorderLayout());
mapselectorpanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(e.getX() > 229 && e.getY() > 186 && e.getX() < 433 && e.getY() < 219) {
//JOptionPane.showConfirmDialog(mapselectorpanel, "Ingyen sör");
mapselectorpanel.add(filelist, BorderLayout.SOUTH);
mapselectorpanel.updateUI();
}
}
});
mapselectorpanel.add(filelist);
} }
private void setGameParams(File dungeonFile) throws IOException { private void setGameParams(File dungeonFile) throws IOException {