Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package box.java.juke.airtime;
- import java.awt.BorderLayout;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JList;
- import javax.swing.ListSelectionModel;
- public class JukeBox {
- public static final int WIDTH = 300;
- public static final int HEIGHT = 400;
- public static final String NAME = "Java JukeBox";
- public static void main(String[] args) {
- JFrame j = new JFrame(NAME);
- j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- j.setSize(WIDTH, HEIGHT);
- j.setVisible(true);
- j.setLocationRelativeTo(null);
- String[] songs = { "Cipher", "Flight", "To the Stars",
- "Last Train to Paradise", "Surge" };
- @SuppressWarnings({ "unchecked", "rawtypes" })
- JList list = new JList(songs);
- list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- j.add(list);
- System.out.println(list.getSelectedValue());
- JButton b = new JButton();
- b.setText("Play");
- j.getContentPane().add(BorderLayout.SOUTH, b);
- j.setResizable(false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement