Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
53 lines (47 loc) · 1.17 KB

File metadata and controls

53 lines (47 loc) · 1.17 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
45
46
47
48
49
50
51
52
53
package chapter16;
/* J16_12.java */
/* Using List Component */
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class J16_12 extends Applet implements ActionListener {
List os, lang;
String msg = "";
public void init() {
os = new List(2, false);
lang = new List(3, true);
// add items to os list
os.add("Windows 7");
os.add("Windows 10");
os.add("Solaris");
os.add("MacOS");
os.select(1);
// add items to lang list
lang.add("C");
lang.add("CPP");
lang.add("Java");
lang.add("Oracle");
lang.select(2);
// add lists to window
add(os);
add(lang);
// register to receive action events
os.addActionListener(this);
lang.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
repaint();
}
// display current selections.
public void paint(Graphics g) {
int idx[];
msg = "Current Operating System: ";
idx = os.getSelectedIndexes();
for(int i=0; i<idx.length; i++)
msg += os.getItem(idx[i]) + " ";
g.drawString(msg, 10, 100);
msg = "Current Language: ";
msg += lang.getSelectedItem();
g.drawString(msg, 10, 120);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.