mport java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class test { ImageIcon imageIcon =new ImageIcon("透明旋转枫.gif");//images这个文件 ImageIcon imagebutton=new ImageIcon("button.png"); JLabel j2=new JLabel(); public test(){ final JFrame f= new JFrame(); f.setBounds(0,00,400,300); f.setDefaultCloseOperation(3); f.setUndecorated(true); com.sun.awt.AWTUtilities.setWindowOpaque(f,false);//设置窗体透明 JPanel p=new JPanel(){ public void paintComponent(Graphics g){//重写paintComponent super.paintComponent(g);//继承的绘制组件方法 Graphics2D gg=(Graphics2D)g; if(imageIcon !=null){//绘制背景 gg.drawImage(imageIcon.getImage(),0,0,f.getWidth(),f.getHeight(),f); } } }; p.setLayout(null);//空布局 任意摆放 与下面的b1.setBounds(280,80,60,25);呼应 JButton b1=new JButton("exit",imagebutton); b1.addActionListener(new ActionListener(){ public void actionPerformed (ActionEvent e){ System.exit(0); } });
- 1
- 粉丝: 4
- 资源: 2
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
- 1
- 2
前往页