asignacion
Publicado por Marian (2 intervenciones) el 08/03/2020 21:12:43
si me pueden ayudar en esta asiganacion
Utilizando LinkRotator, cree una nueva versión con sus propios enlaces.
Utilizando LinkRotator, cree una nueva versión con sus propios enlaces.
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.java8talleres;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.net.*;
public class LinkRotator extends JFrame
implements Runnable, ActionListener {
String[] pageTitle = new String[6];
URI[] pageLink = new URI[6];
int current = 0;
Thread runner;
JLabel siteLabel = new JLabel();
public LinkRotator() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300, 100);
FlowLayout flo = new FlowLayout();
setLayout(flo);
add(siteLabel);
pageTitle = new String[] {
"Oracle's Java site",
"Cafe au Lait",
"JavaWorld",
"Java in 24 Hours",
"Sams Publishing",
"Workbench"
};
pageLink[0] = getURI("http://www.oracle.com/technetwork/java");
pageLink[1] = getURI("http://www.ibiblio.org/javafaq");
pageLink[2] = getURI("http://www.javaworld.com");
pageLink[3] = getURI("http://www.java24hours.com");
pageLink[4] = getURI("http://www.samspublishing.com");
pageLink[5] = getURI("http://workbench.cadenhead.org");
Button visitButton = new Button("Visit Site");
visitButton.addActionListener(this);
add(visitButton);
setVisible(true);
start();
}
private URI getURI(String urlText) {
URI pageURI = null;
try {
pageURI = new URI(urlText);
} catch (URISyntaxException ex) {
// do nothing
}
return pageURI;
}
public void start() {
if (runner == null) {
runner = new Thread(this);
runner.start();
}
}
public void run() {
Thread thisThread = Thread.currentThread();
while (runner == thisThread) {
current++;
if (current > 5) {
current = 0;
}
siteLabel.setText(pageTitle[current]);
repaint();
try {
Thread.sleep(1000);
} catch (InterruptedException exc) {
// do nothing
}
}
}
public void actionPerformed(ActionEvent event) {
Desktop desktop = Desktop.getDesktop();
if (pageLink[current] != null) {
try {
desktop.browse(pageLink[current]);
runner = null;
System.exit(0);
} catch (IOException exc) {
// do nothing
}
}
}
public static void main(String[] arguments) {
new LinkRotator();
}
}
Valora esta pregunta


-1