here’s the code attached =)
//////////////////////////////////////
// Panel for Tile Game Area
//////////////////////////////////////
JPanel gamearea = new JPanel();
gamearea.add(game);
gamearea.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
game.requestFocus(true); // also try adding the param 'true'
}
});
//////////////////////////////////////
// Panel for UserList and Login Button
//////////////////////////////////////
JPanel userlistPane = new JPanel();
userList = new JList(new DefaultListModel());
userList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
userList.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
if (evt.getClickCount() > 1) {
BYTEARRAY ba = (BYTEARRAY) userList.getSelectedValue();
if (ba != null) {
String message = JOptionPane.showInputDialog(
Login.this, "Enter private message:");
doDCCMessage(ba.data(), message);
}
}
}
});
userList.setCellRenderer(new ListCellRenderer() {
JLabel text = new JLabel();
public Component getListCellRendererComponent(JList arg0,
Object arg1, int arg2, boolean arg3, boolean arg4) {
byte[] data = ((BYTEARRAY) arg1).data();
text.setText(StringUtils.bytesToHex(data,0,data.length>4?4:data.length));
return text;
}
});
userlistPane.setLayout(new BorderLayout(1,2));
userlistPane.add(new JScrollPane(userList));
login.setSize(100, 200);
userlistPane.add(login, BorderLayout.SOUTH);
userlistPane.setBackground(Color.gray);
//////////////////////////////////////
// Main Panel for Adding other Panels
//////////////////////////////////////
//JPanel c = new JPanel();
Container c = getContentPane();
c.setLayout(new BoxLayout(c, BoxLayout.X_AXIS));
//c.setLayout(new BorderLayout());
c.setBackground(Color.gray);
//desktop = new JDesktopPane();
c.add(desktop, BorderLayout.CENTER);
c.add(gamearea, BorderLayout.CENTER);
c.add(userlistPane, BorderLayout.EAST);
c.setSize(600, 400);
//... Set window characteristics
//setContentPane(c);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Game");
c.setVisible(true);
pack();