-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainFrame.java
More file actions
69 lines (60 loc) · 1.81 KB
/
MainFrame.java
File metadata and controls
69 lines (60 loc) · 1.81 KB
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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class MainFrame extends JFrame {
private JPanel contentPane;
private BorderLayout borderLayout1 = new BorderLayout();
private JLabel jLabel1 = new JLabel();
//Construct the frame
public MainFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(MainFrame.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
jLabel1.setToolTipText("");
jLabel1.setDisplayedMnemonic('0');
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
jLabel1.setText("<html><body><font size=10 ><a href=http://www.pku.edu.cn>±± ¾© ´ó ѧ</a></font></body></html>");
jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(MouseEvent e) {
jLabel1_mouseReleased(e);
}
});
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(398, 158));
this.setTitle("JLabelDemo2");
contentPane.add(jLabel1, BorderLayout.CENTER);
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void jLabel1_mouseReleased(MouseEvent e) {
try{
Runtime.getRuntime().exec("cmd /c start http://www.pku.edu.cn");
}catch(Exception err)
{
err.printStackTrace();
}
}
}