java swing

上一篇 / 下一篇  2012-07-17 10:21:12 / 个人分类:java应用

package test;
import java.awt.*;
$Y.EJ}6DSX MB$xa0import java.awt.event.ActionEvent;
%in(D7?5h:vVrm+?0import java.awt.event.ActionListener;
7P#p[-G}0import java.awt.event.MouseEvent;51Testing软件测试网6SSgP| k,s
import java.awt.event.MouseListener;51Testing软件测试网X-r r/a"Q&k3]2x
import java.awt.event.WindowEvent;51Testing软件测试网~3x{d[
import java.awt.event.WindowListener;51Testing软件测试网Pd|F,X$C
import java.awt.image.BufferedImage;
+H!g"m Z7o}G0import java.io.File;
Ox2X'|!x0import java.io.IOException;
 
51Testing软件测试网o9`RkS5^E
import javax.imageio.ImageIO;51Testing软件测试网7hF*n"I5h4}2J
import javax.swing.*;51Testing软件测试网L Kh%XJ~O.w`
import javax.swing.event.AncestorListener;
import com.sun.org.apache.xerces.internal.util.URI;
public class ShortCutTool extends JFrame. implements MouseListener{
 /**
;M\EQblw| U0  * @param args51Testing软件测试网2kQ N`J
  */
*W.v"BF Q7Lo*B0 public static void main(String[] args) {51Testing软件测试网#ZG T7T;F ^ A9@#A
  ShortCutTool shortct=new ShortCutTool();51Testing软件测试网F,I$~.U g;E@
  shortct.uiFrame();
 }
 @SuppressWarnings("serial")
"cKi9gFr/^3D0 private void uiFrame() {  51Testing软件测试网!P o s,a ]"guZd't;x
  JFrame. jf=new JFrame("网站集合工具");51Testing软件测试网"|M+hJ*G7P(k7^
//  ImageIcon image = new ImageIcon("E:\\eclipse\\eclipse-SDK-3.4.2-win32\\DSC01268.JPG");   51Testing软件测试网)SA/|Kb6sM0Z ^
  jf.setLayout(new BorderLayout());
m"`;_v/r}5c.S0  jf.setSize(630, 500);51Testing软件测试网 h*{)J~1PN
  jf.setVisible(true);
7u] e.Le*bx?A}0    
  JTabbedPane jtp=new JTabbedPane();
  jf.add(jtp);
#A(U5{'L0_{ c:e+LA0  Font tabFont = new Font("宋体", Font.BOLD, 12);51Testing软件测试网2q YE:~F2e
  jtp.setFont(tabFont);
  JPanel jp1=new JPanel(){ 
            protected void paintComponent(Graphics g) {ImageIcon icon = new ImageIcon("E:\\eclipse\\eclipse-SDK-3.4.2-win32\\DSC01268.JPG"); 51Testing软件测试网 H&h tl+^x5S5K
            Image img = icon.getImage(); 51Testing软件测试网^,@.z fwA1h.L
            g.drawImage(img, 0, 0, 630, 
&r*E"o6m.m0              450, icon.getImageObserver());                  51Testing软件测试网c#_*\_-Cps7J H X1o
  } 
 }; 
gs~4C.N(Qn~0  jp1.setLayout(new FlowLayout(FlowLayout.LEFT,50,60));51Testing软件测试网a/FZ#O!Ql
 // jp1.setBackground(Color.lightGray);
7D#z1Xt6f0  JPanel jp2=new JPanel(){ 
            protected void paintComponent(Graphics g) {ImageIcon icon = new ImageIcon("E:\\eclipse\\eclipse-SDK-3.4.2-win32\\20114623365102117113.jpg"); 51Testing软件测试网'XY;`)D JzO5O`e
            Image img = icon.getImage(); 51Testing软件测试网@I,[g@ W9Jw
            g.drawImage(img, 0, 0, 630, 51Testing软件测试网A ]~ qWD/]$l
              450, icon.getImageObserver());                  51Testing软件测试网Y!B/[ S:kj
  } 
 }; 51Testing软件测试网'W `2_udw[N
  jp2.setLayout(new FlowLayout(FlowLayout.LEFT,50,60));
mMxF/MO5g[q0  JPanel jp3=new JPanel();
t-UR7vg0  JPanel jp4=new JPanel();51Testing软件测试网v @v$U3D
  JPanel jp5=new JPanel();51Testing软件测试网$x,W*p-mq}1lk
  JPanel jp6=new JPanel();
;a!H ~$V)PXd0  JPanel jp7=new JPanel();
$s&W+_Nk5k D0  JPanel jp8=new JPanel();
M1|v!R4ht0  jtp.add("常用网站集合",jp1);
mJ6m&^k]*~#O)A0  jtp.add("视频网站",jp2);51Testing软件测试网Ya P!m*_\]hm
  jtp.add("小说网站",jp3);51Testing软件测试网'ON]J)H] y8a;c
  jtp.add("游戏网站",jp4);51Testing软件测试网X!HQ]hx~d
  jtp.add("新闻网站",jp5);51Testing软件测试网)m/f HF)~;w(f8X
  jtp.add("邮箱网站",jp6);
7|N \yl+As:t'Pr0  jtp.add("音乐网站",jp7);51Testing软件测试网 z9kWJOH2w
  jtp.add("团购网站",jp8);
;W| C8_HN;O E?Qp0a0     JLabel linklabel1 = new JLabel("<html><a href='http://www.google.com'>谷歌</a></html>");
nZR f.o6G0u4y|D0     JLabel linklabel2= new JLabel("<html><a href='http://www.baidu.com'>百度</a></html>");
4@3nQ-B;H'Div {0     JLabel linklabel3= new JLabel("<html><a href='http://www.sina.com'>新浪</a></html>");51Testing软件测试网$`H ?Wk+o^
     JLabel linklabel4= new JLabel("<html><a href='http://www.qq.com'>腾讯</a></html>");
Q S xMA @E5q/]0     JLabel linklabel5= new JLabel("<html><a href='http://www.sohu.com'>搜狐</a></html>");
^ gL!s+p,Lb;z;|X0     JLabel linklabel6= new JLabel("<html><a href='http://www.163.com'>网易</a></html>");
h9cC{.B:`+M?*zW0     JLabel linklabel7= new JLabel("<html><a href='http://www.ifeng.com'>凤凰网</a></br></html>");51Testing软件测试网^(LHWV ht
     JLabel linklabel8= new JLabel("<html><a href='http://www.weibo.com'>新浪微博</a></html>");51Testing软件测试网(maz g0v3G|&~
     JLabel linklabel9= new JLabel("<html><a href='http://qzone.qq.com'>QQ空间</a></html>");
M.cA_6v+VZ1f0     JLabel linklabel10= new JLabel("<html><a href='http://www.xinhuanet.com'>新华网</a></html>");
~ Q9_|Q0     JLabel linklabel11= new JLabel("<html><a href='http://www.10086.cn/service'>移动营业厅</a></html>");51Testing软件测试网b2wPLC q4cW.d_ J:~
     JLabel linklabel12= new JLabel("<html><a href='http://www.youku.com'>优酷网</a></html>");
-r8H? jl*@`q0     JLabel linklabel13= new JLabel("<html><a href='http://www.iqiyi.com'>奇艺高清</a></html>");
9[V_(z.gt} Ky*Dm0     JLabel linklabel14= new JLabel("<html><a href='http://www.tudou.com'>土豆</a></html>");
] t]b,n6x+KgkcU0     JLabel linklabel15= new JLabel("<html><a href='http://www.pptv.com'>PPTV</a></html>");51Testing软件测试网 _#R&bb.I k(I
     JLabel linklabel16= new JLabel("<html><a href='http://www.letv.com'>乐视网</a></html>");51Testing软件测试网!D-kJYu:Z
     JLabel linklabel17= new JLabel("<html><a href='http://www.xunlei.com'>迅雷看看</a></html>");51Testing软件测试网"y9g'EB#L!D$w z
     jp1.add(linklabel1);
*A(It y.i0     jp1.add(linklabel2);
?)xt}7KH;@ BP I0     jp1.add(linklabel3);
E\:pMh)o"{T2X1O0     jp1.add(linklabel4);51Testing软件测试网%_ P0v\6{;`;t#[{
     jp1.add(linklabel5);
7EMN!zv7ijw0     jp1.add(linklabel6);51Testing软件测试网;o6i\&D%M
     jp1.add(linklabel7);51Testing软件测试网5K] R*{+PW-L
     jp1.add(linklabel8);
,w Jt\I Y9_6B0     jp1.add(linklabel9);51Testing软件测试网&s_ BD*Du,Dn%w*A
     jp1.add(linklabel10);51Testing软件测试网2\t'}!} LnI$J }
     jp1.add(linklabel11);
Q \ r6YE2Vo `0}0     jp2.add(linklabel12);
)o9a,kZJ8^7d8^N0     jp2.add(linklabel13);
U4y-o4x3} XS%X.c0     jp2.add(linklabel14);
L(g3x g xkW g0     jp2.add(linklabel15);
{Q Wx |6n2~0     jp2.add(linklabel16);51Testing软件测试网+?{_+u%H
     jp2.add(linklabel17);
p:V6X M2NP.`1oIT0     linklabel1.addMouseListener(this); 51Testing软件测试网(`+uS9Fey"X8lC
     linklabel2.addMouseListener(this);
_/Z$C'ar2AQF,P4Z0     linklabel3.addMouseListener(this);
y`,b#Uy,aJe0     linklabel4.addMouseListener(this);
*S,O]6Xg~0     linklabel12.addMouseListener(this);
+}.y%}2f`F] U E0     linklabel13.addMouseListener(this);51Testing软件测试网P-BJZM o8~;lfY
     linklabel14.addMouseListener(this);51Testing软件测试网)E'bL.]&^2z;c,j
     linklabel15.addMouseListener(this);
4T+T9]a4]5h[0     linklabel16.addMouseListener(this);51Testing软件测试网Z8_,THp H`
     linklabel17.addMouseListener(this);51Testing软件测试网/O S:u1E'r(Qw
     linklabel1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
AswOiC:]9m B0     linklabel2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));51Testing软件测试网)e,~.N5Y r T6|{x0HX
     linklabel3.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));51Testing软件测试网,m.X#\6Is B
     linklabel4.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));51Testing软件测试网+~w {!vX(`JfV
     linklabel5.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));51Testing软件测试网C3u7dI*s\
     linklabel6.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
5\![t H/aXs#B0     linklabel7.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));51Testing软件测试网zw W0YeBZ
     linklabel8.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));51Testing软件测试网,za$v)X \4II o|
     linklabel9.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));51Testing软件测试网OM4z O Y(rU
     linklabel10.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));51Testing软件测试网6B.P} Rp%bih
     linklabel11.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
;|b wCl{7WT,GM0     linklabel12.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
8}#{)|+S(e Qx-Xj0     linklabel13.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));51Testing软件测试网o\5q6_WF Qb
     linklabel14.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
m"AY V@+J~$s0     linklabel15.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
U'`9h {0AY*QT a6{IL0     linklabel16.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
Np m4_M~#N9~t6E0     linklabel17.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
E1q2Lp ~Y|0     linklabel1.setToolTipText("点击可以弹出网页");//设置提示文字51Testing软件测试网7{-I7\,ol,|J
     linklabel1.setForeground(Color.blue);
f/NV,|&DK9h/f0E0    
51Testing软件测试网$fs&ppp1gO{
 }
 public void mouseClicked(MouseEvent m) {51Testing软件测试网)qu:g_'U;OmZ6i A
  String str1=m.toString();  
l;Bf6rjU0  int a=str1.indexOf("<a href='");
[:V$F*j"b'T&q$RaV l}0  int b=str1.indexOf("'>");
S Vk3k)XJ ~0//  System.out.println(a);
l!X0KH i2^/w0  String str=str1.substring(a+9, b);51Testing软件测试网3V|%Y xkT K
//  System.out.println(str);
;y)ed/HE&d(}#~1@;B0  try {51Testing软件测试网a8Mp$Oo6o^GP*[ s
   Runtime.getRuntime().exec( "C:\\Program   Files\\Internet   Explorer\\IEXPLORE.EXE   "+str);
QL8ardg^0  } catch (IOException e) {
,s,CO!B-}3y0   // TODO Auto-generated catch block51Testing软件测试网\Y;rl4`
   e.printStackTrace();
,}2^ k y/j!k0  }

#J ]_SCUC$[v0 }
B-X3tMk/B0  
  
){WJ Z+VA0 
 public void mouseEntered(MouseEvent arg0) {
J/dLz{#V0  // TODO Auto-generated method stub
Y$|O9_]X0  51Testing软件测试网:m7E UGb;G|%i+{
 }
 public void mouseExited(MouseEvent arg0) {
&B/w_/O{d,Y7ii(z0  // TODO Auto-generated method stub51Testing软件测试网2PX"Y|%y)r9S6g
  
1K-Xh(Ii I$zd0 }
 public void mousePressed(MouseEvent arg0) {
\_M^d*k\;d&h#V+tx0  // TODO Auto-generated method stub
G`.B~JO~N0  
r w1Vt/Go }`0 }
 public void mouseReleased(MouseEvent arg0) {
9J@cn H}W0  // TODO Auto-generated method stub
^8Mp]W5x pi0  
#C)w4rU0|@'I0 }
}51Testing软件测试网U:zW MLfc rL

TAG:

 

评分:0

我来说两句

日历

« 2024-01-28  
 123456
78910111213
14151617181920
21222324252627
28293031   

数据统计

  • 访问量: 19320
  • 日志数: 24
  • 建立时间: 2012-07-11
  • 更新时间: 2012-09-04

RSS订阅

Open Toolbar