📄 chyong.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.util.EventListener;
public class ChYong extends JFrame implements MouseListener/*, ActionListener*/ {
JLabel []jl= new JLabel[16];
String []str = {"<html><u>百度一下</u></html>",
"<html><u>雅虎</u></html>",
"<html><u>搜狐</u></html>",
"<html><u>新浪</u></html>",
"<html><u>网易</u></html>",
"<html><u>腾讯</u></html>",
"<html><u>51</u></html>",
"<html><u>Google</u></html>",
"<html><u>土豆</u></html>",
"<html><u>优酷</u></html>",
"<html><u>中央电视台</u></html>",
"<html><u>凤凰网</u></html>",
"<html><u>Sun中国</u></html>",
"<html><u>微软中国</u></html>",
"<html><u>IBM中国</u></html>",
"<html><u>Intel中国</u></html>"};
JButton but01,but02;
JTextField jtf01,jtf02;
JPanel pan_new;
Container con;
public ChYong()
{
con = this.getContentPane();
con.setLayout(new GridLayout(6,1));
JPanel []pan = new JPanel[5];
for(int i = 0;i<5;i++)
{
pan[i] = new JPanel();
pan[i].setLayout(new FlowLayout(FlowLayout.LEFT));
}
int j = 0;
for(int i =0;i<=15;i++)
{
jl[i] = new JLabel(str[i]);
jl[i].setFont(new Font(null,Font.BOLD,15));
jl[i].setCursor(new Cursor(Cursor.HAND_CURSOR));
jl[i].setForeground(Color.BLUE);
jl[i].addMouseListener(this);
pan[j].add(jl[i]);
if((i+1)%4==0)
{
con.add(pan[j]);
j = j+1;
}
}
setTitle("常用网址");
setSize(400,400);
setLocation(300,200);
setResizable(false);
setVisible(true);
setDefaultLookAndFeelDecorated(true);
}
public void mouseClicked(MouseEvent e) {
// TODO: Add your code here
}
public void mousePressed(MouseEvent e) {
// TODO: Add your code here
if(e.getSource()==jl[0])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.baidu.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[1])
{
try
{Runtime.getRuntime().exec("cmd /c start http://cn.yahoo.com/?id=40084");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[2])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.souhu.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[3])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.sina.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[4])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.163.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[5])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.qq.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[6])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.51.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[7])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.google.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[8])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.tudou.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[9])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.youku.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[10])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.cctv.com/default.shtml");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[11])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.ifeng.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[12])
{
try
{Runtime.getRuntime().exec("cmd /c start http://cn.sun.com");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[13])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.microsoft.com/zh/cn");}
catch(Exception ex)
{ex.printStackTrace();}
}
else if(e.getSource() ==jl[14])
{
try
{Runtime.getRuntime().exec("cmd /c start http://www.ibm.com/cn");}
catch(Exception ex)
{ex.printStackTrace();}
}
else
{
try
{
Runtime.getRuntime().exec("cmd /c start http://www.intel.com/cd/corporate/home/apac/zho/324811.htm");
}
catch(Exception ex)
{ex.printStackTrace();}
}
}
public void mouseReleased(MouseEvent e) {
// TODO: Add your code here
}
public void mouseEntered(MouseEvent e) {
// TODO: Add your code here
}
public void mouseExited(MouseEvent e) {
// TODO: Add your code here
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -