Wat klopt er niet in de volgende source code?
Ben noob...
code:
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
| import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class file extends JFrame {
private JButton knop;
private String string1, string2, string3, string4, string5;
private JComboBox combobox1;
public file() {
setTitle("file");
Container c = getContentPane();
c.setLayout(null);
knop = new JButton("start");
knop.setBounds(170, 90, 130, 25);
c.add(knop);
string1 = new String("/Program Files/Microsoft Office/Office/Winword.exe");
string2 = new String("/Program Files/Microsoft Office/Office/Powerpnt.exe");
string3 = new String("/Program Files/Microsoft Office/Office/Excel.exe");
string4 = new String("/Program Files/Microsoft Office/Office/Acces.exe");
String keuzes[] = {string1,string2,string3,string4};
combobox1 = new JComboBox(keuzes);
combobox1.setBounds(110, 140, 250, 25);
combobox1.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
String string5 = (String)e.getItem();
System.out.println(string5);
}
});
c.add(combobox1);
ButtonHandler handler = new ButtonHandler();
knop.addActionListener(handler);
setSize(476, 365);
setVisible(true);
}
public static void main(String args[]) {
file app = new file();
app.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
}
private class ButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e)
{
try
{
Runtime.getRuntime().exec(string5);
}
catch (java.io.IOException a) {
a.printStackTrace();
}
}
}
} |
Ben noob...