-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestFrame2.java
44 lines (34 loc) · 1.15 KB
/
TestFrame2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class TestFrame2 implements ActionListener {
private JFrame frame;
private JList genreList;
private JLabel genreLabel;
private JButton next;
public TestFrame2() {
frame = new JFrame("Story Generator");
//frame.setForeground(Color.RED);
frame.setSize(new Dimension(300, 300));
frame.setLocation(new Point(100, 150));
//components
genreLabel= new JLabel ("What genre do you want?");
String[] genres = {"Sci-fi", "Mystery", "Fantasy", "Realistic", "Historical", "Superhero" ,"Any"};
genreList = new JList(genres);
next = new JButton("Next >");
next.addActionListener(this);
//layout
//frame = new JFrame("Story Generator");
frame.setLayout(new FlowLayout());
frame.add(genreLabel);
frame.add(genreList);
frame.add(next);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent event) {
int index = genreList.getSelectedIndex();
}
public static void main (String[] args) {
new TestFrame2();
}
}