Debian Codegraph @

tests/reproducers/signed/CountingAppletSigned/srcs/CountingAppletSigned.java

raw
1
2 import java.applet.Applet;
3 import java.awt.BorderLayout;
4 import javax.swing.JLabel;
5 import javax.swing.SwingUtilities;
6
7 /* CountingAppletSigned.java
8 Copyright (C) 2012 Red Hat, Inc.
9
10 This file is part of IcedTea.
11
12 IcedTea is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, version 2.
15
16 IcedTea is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with IcedTea; see the file COPYING. If not, write to
23 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 02110-1301 USA.
25
26 Linking this library statically or dynamically with other modules is
27 making a combined work based on this library. Thus, the terms and
28 conditions of the GNU General Public License cover the whole
29 combination.
30
31 As a special exception, the copyright holders of this library give you
32 permission to link this library with independent modules to produce an
33 executable, regardless of the license terms of these independent
34 modules, and to copy and distribute the resulting executable under
35 terms of your choice, provided that you also meet, for each linked
36 independent module, the terms and conditions of the license of that
37 module. An independent module is a module which is not derived from
38 or based on this library. If you modify this library, you may extend
39 this exception to your version of the library, but you are not
40 obligated to do so. If you do not wish to do so, delete this
41 exception statement from your version.
42 */
43 public class CountingAppletSigned extends Applet {
44
45 public static void main(String[] args) throws InterruptedException {
46 Integer counter = null;
47 if (args.length > 0) {
48 counter = new Integer(args[0]);
49 ;
50 }
51 int i = 0;
52 while (true) {
53 System.out.println("counting... " + i);
54 System.out.flush();
55 if (counter != null && i == counter.intValue()) {
56 System.exit(-i);
57 }
58 i++;
59 Thread.sleep(1000);
60 }
61 }
62
63 @Override
64 public void init() {
65 System.out.println("applet was initialised");
66 final CountingAppletSigned self = this;
67 SwingUtilities.invokeLater(new Runnable() {
68
69 @Override
70 public void run() {
71 self.setLayout(new BorderLayout());
72 self.add(new JLabel("S"));
73 self.validate();
74 self.repaint();
75 }
76 });
77 }
78
79 @Override
80 public void start() {
81 System.out.println("applet was started");
82 String s = getParameter("kill");
83 final String[] params;
84 if (s != null) {
85 params = new String[]{s};
86 } else {
87 params = new String[0];
88 }
89 new Thread(new Runnable() {
90
91 @Override
92 public void run() {
93 try {
94 main(params);
95 } catch (Exception ex) {
96 ex.printStackTrace();
97 }
98 }
99 }).start();
100 }
101
102 @Override
103 public void stop() {
104 System.out.println("applet was stopped");
105 }
106
107 @Override
108 public void destroy() {
109 System.out.println("applet will be destroyed");
110 }
111 }