added proof of concept mouse listener to JList in ApplicationFrame

This commit is contained in:
Kjistóf 2016-05-07 17:07:27 +02:00
parent 04afbf83a4
commit 22553d657f

View File

@ -4,6 +4,8 @@ import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@ -20,6 +22,13 @@ public class ApplicationFrame implements Runnable
public ApplicationFrame(){}
private class ListMouseHandler extends MouseAdapter{
@Override
public void mouseClicked(MouseEvent e) {
JOptionPane.showMessageDialog(null, ((JList<File>)e.getComponent()).getSelectedValue().toString());
}
}
public void init(){
jframe = new JFrame();
jframe.setMinimumSize(new Dimension(600, 400));
@ -39,10 +48,13 @@ public class ApplicationFrame implements Runnable
filelist = new JList<>(dungeonslist);
filelist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
filelist.setLayoutOrientation(JList.HORIZONTAL_WRAP);
filelist.addMouseListener(new ListMouseHandler());
mapselectorpanel.add(filelist);
jframe.add(mapselectorpanel);
//TODO rewrite demo ListMouseHandler and do Game stuff...
}
@Override