import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class Gui extends JFrame {
private static int WINDOW_WIDTH = 1024;
private static int WINDOW_HEIGHT = 768;
final int NUMBER_OF_GAMES = 13;
private String[] gameTitles = {
"Assassin's Creed II ", "Batman: Arkham Asylum ", "Cloudy With a Chance of Meatballs",
"Demon Soul's", "EyePet", "Final Fantasy XII", "God Of War III", "Heavy Rain", "Infamous II",
"James Bond: BloodStone", "Killzone 2", "Uncharted", "Warhawk", };
private JList jlst = new JList(gameTitles);
private ImageIcon[] gamebox = {
new ImageIcon("C:/gamebox/assassinscreedII.jpg"),
new ImageIcon("C:/gamebox/arkhamasylum.jpg"),
new ImageIcon("C:/gamebox/cloudy.jpg"),
new ImageIcon("C:/gamebox/demonsouls.jpg"),
new ImageIcon("C:/gamebox/eyepet.jpg"),
new ImageIcon("C:/gamebox/ff12.jpg"),
new ImageIcon("C:/gamebox/gow3.jpg"),
new ImageIcon("C:/gamebox/heavyrain.jpg"),
new ImageIcon("C:/gamebox/infamous2.jpg"),
new ImageIcon("C:/gamebox/bloodstone.jpg"),
new ImageIcon("C:/gamebox/killzone2.jpg"),
new ImageIcon("C:/gamebox/uncharted.jpg"),
new ImageIcon("C:/gamebox/warhawk.jpg"),
};
private JLabel[] jlblImageViewer = new JLabel[NUMBER_OF_GAMES];
public static void main(String [] args){
Gui frame = new Gui();
Scrollbar one = new Scrollbar();
frame.setTitle("Playstation 3");
frame.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public Gui() {
JPanel p = new JPanel(new GridLayout(1,0));
for (int i=0; i < NUMBER_OF_GAMES-9; i++){
p.add(jlblImageViewer[i] = new JLabel());
jlblImageViewer[i].setHorizontalAlignment
(SwingConstants.CENTER);
}
add(p, BorderLayout.CENTER);
add(new JScrollPane(jlst), BorderLayout.WEST);
jlst.addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e){
int[] indices = jlst.getSelectedIndices();
int i;
for(i = 0; i< indices.length; i++){
jlblImageViewer[i].setIcon(gamebox[indices[i]]);
}
for (; i<NUMBER_OF_GAMES-9; i++){
jlblImageViewer[i].setIcon(null);
}
}
});
}// end constructor
}