added proof of concept mouse listener to JList in ApplicationFrame
This commit is contained in:
parent
04afbf83a4
commit
22553d657f
@ -4,6 +4,8 @@ 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.awt.*;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -20,6 +22,13 @@ public class ApplicationFrame implements Runnable
|
|||||||
|
|
||||||
public ApplicationFrame(){}
|
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(){
|
public void init(){
|
||||||
jframe = new JFrame();
|
jframe = new JFrame();
|
||||||
jframe.setMinimumSize(new Dimension(600, 400));
|
jframe.setMinimumSize(new Dimension(600, 400));
|
||||||
@ -39,10 +48,13 @@ public class ApplicationFrame implements Runnable
|
|||||||
filelist = new JList<>(dungeonslist);
|
filelist = new JList<>(dungeonslist);
|
||||||
filelist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
filelist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
filelist.setLayoutOrientation(JList.HORIZONTAL_WRAP);
|
filelist.setLayoutOrientation(JList.HORIZONTAL_WRAP);
|
||||||
|
filelist.addMouseListener(new ListMouseHandler());
|
||||||
|
|
||||||
mapselectorpanel.add(filelist);
|
mapselectorpanel.add(filelist);
|
||||||
|
|
||||||
jframe.add(mapselectorpanel);
|
jframe.add(mapselectorpanel);
|
||||||
|
|
||||||
|
//TODO rewrite demo ListMouseHandler and do Game stuff...
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user