Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. package box.java.juke.airtime;
  2.  
  3. import java.awt.BorderLayout;
  4.  
  5. import javax.swing.JButton;
  6. import javax.swing.JFrame;
  7. import javax.swing.JList;
  8. import javax.swing.ListSelectionModel;
  9.  
  10. public class JukeBox {
  11. public static final int WIDTH = 300;
  12. public static final int HEIGHT = 400;
  13. public static final String NAME = "Java JukeBox";
  14.  
  15. public static void main(String[] args) {
  16. JFrame j = new JFrame(NAME);
  17. j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  18. j.setSize(WIDTH, HEIGHT);
  19. j.setVisible(true);
  20. j.setLocationRelativeTo(null);
  21.  
  22. String[] songs = { "Cipher", "Flight", "To the Stars",
  23. "Last Train to Paradise", "Surge" };
  24. @SuppressWarnings({ "unchecked", "rawtypes" })
  25. JList list = new JList(songs);
  26. list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  27. j.add(list);
  28. System.out.println(list.getSelectedValue());
  29. JButton b = new JButton();
  30. b.setText("Play");
  31. j.getContentPane().add(BorderLayout.SOUTH, b);
  32. j.setResizable(false);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement