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
71
| public class FileTransfer extends JFrame implements ActionListener {
private JButton bCancel = new JButton("Cancel");
private JLabel lFile = new JLabel("File:");
private JLabel lFile2 = new JLabel();
private JLabel lFrom = new JLabel("From:");
private JLabel lFrom2 = new JLabel();
private JLabel lTo = new JLabel("To:");
private JLabel lTo2 = new JLabel();
private JLabel lStatus = new JLabel("Status:");
public JLabel lStatus2 = new JLabel("Asking user for permission");
private JPanel panel;
private JProgressBar progressBar;
final static double f = TableLayout.FILL;
public FileTransfer(String file, String from, String to) {
super("Send a file");
lFile2.setText(file);
lFrom2.setText(from);
lTo2.setText(to);
progressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100) {
public Dimension getPreferredSize() {
return new Dimension(100, super.getPreferredSize().height);
}
};
Container pane = getContentPane();
panel = new JPanel();
double size[][] = {{10, 80, 100, 80, f}, {10, 20, 5, 20, 5, 20, 5, 20, 20, 10, 25, f}};
TableLayout layout = new TableLayout(size);
panel.setLayout (layout);
panel.add(lFile, "1, 1");
panel.add(lFile2, "2, 1, 3, 1");
panel.add(lFrom, "1, 3");
panel.add(lFrom2, "2, 3, 3, 3");
panel.add(lTo, "1, 5");
panel.add(lTo2, "2, 5, 3, 5");
panel.add(lStatus, "1, 7");
panel.add(progressBar, "2, 7, 3, 7");
panel.add(lStatus2, "2, 8, 3, 8");
panel.add(bCancel, "3, 10");
bCancel.addActionListener(this);
pane.add(panel);
setSize(300,200);
setVisible(true);
}
public void actie(){
lStatus2.setText("Transfer aborted");
}
public void actionPerformed(ActionEvent evt){
if (evt.getSource() == bCancel) {
dispose();
}
}
} |