QQ截图20150826182536.png (41.28 KB, 下载次数: 1074)
下载附件 保存到相册
9 年前 上传
111.png (6.36 KB, 下载次数: 1039)
1.png (9.3 KB, 下载次数: 1075)
2.png (8.64 KB, 下载次数: 1067)
package com.haozi.UI; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JProgressBar; import com.haozi.Bean.UrlBean; public class MyJProgressBar extends JComponent{ private BufferedImage img; private short img_w; private short img_h; private BufferedImage imgbg; private short imgbg_w; private short imgbg_h; private BufferedImage imgend; private short imgend_w; private short imgend_h; private BufferedImage imgl; private short imgl_w; private short imgl_h; private BufferedImage imgr; private short imgr_w; private short imgr_h; /** * 显示的最大/小 宽度 */ private Integer minsize; private Integer maxsize=880; private Integer value=1; /** * 进度的大小 */ private int max=100; public MyJProgressBar(){ super(); LoadImage(new File(UrlBean.progreess_url),new File(UrlBean.progreess_BackGround_url),new File(UrlBean.progreess_end_url) ,new File(UrlBean.progreess_l_url),new File(UrlBean.progreess_r_url)); } @Override protected void paintComponent(Graphics g) { // TODO Auto-generated method stub g.drawImage(imgbg, 0, 0, imgbg_w, imgbg_h, null); for(int i=0;i<=value;i++){ if(i==0){ g.drawImage(imgl, 15, 14, imgl_w, imgl_h, null); g.drawImage(img, i+22, 14, img_w, img_h, null); }else if(i==value){ g.drawImage(imgr, value+22, 14, imgr_w, imgr_h, null); g.drawImage(imgend, (value+22)-(imgend_w-1)/2, 14, imgend_w, imgend_h, null); }else{ g.drawImage(img, i+22, 14, img_w, img_h, null); } } } public void LoadImage(File file,File filebg,File fileend,File filel,File filer){ try { img = ImageIO.read(file); img_w = (short) img.getWidth(); img_h = (short) img.getHeight(); imgbg = ImageIO.read(filebg); imgbg_w = (short) imgbg.getWidth(); imgbg_h = (short) imgbg.getHeight(); imgend = ImageIO.read(fileend); imgend_w = (short) imgend.getWidth(); imgend_h = (short) imgend.getHeight(); imgl = ImageIO.read(filel); imgl_w = (short) imgl.getWidth(); imgl_h = (short) imgl.getHeight(); imgr = ImageIO.read(filer); imgr_w = (short) imgr.getWidth(); imgr_h = (short) imgr.getHeight(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public BufferedImage getImg() { return img; } public void setImg(BufferedImage img) { this.img = img; } public short getImg_w() { return img_w; } public void setImg_w(short img_w) { this.img_w = img_w; } public short getImg_h() { return img_h; } public void setImg_h(short img_h) { this.img_h = img_h; } public BufferedImage getImgbg() { return imgbg; } public void setImgbg(BufferedImage imgbg) { this.imgbg = imgbg; } public short getImgbg_w() { return imgbg_w; } public void setImgbg_w(short imgbg_w) { this.imgbg_w = imgbg_w; } public short getImgbg_h() { return imgbg_h; } public void setImgbg_h(short imgbg_h) { this.imgbg_h = imgbg_h; } public BufferedImage getImgend() { return imgend; } public void setImgend(BufferedImage imgend) { this.imgend = imgend; } public short getImgend_w() { return imgend_w; } public void setImgend_w(short imgend_w) { this.imgend_w = imgend_w; } public short getImgend_h() { return imgend_h; } public void setImgend_h(short imgend_h) { this.imgend_h = imgend_h; } public BufferedImage getImgl() { return imgl; } public void setImgl(BufferedImage imgl) { this.imgl = imgl; } public short getImgl_w() { return imgl_w; } public void setImgl_w(short imgl_w) { this.imgl_w = imgl_w; } public short getImgl_h() { return imgl_h; } public void setImgl_h(short imgl_h) { this.imgl_h = imgl_h; } public BufferedImage getImgr() { return imgr; } public void setImgr(BufferedImage imgr) { this.imgr = imgr; } public short getImgr_w() { return imgr_w; } public void setImgr_w(short imgr_w) { this.imgr_w = imgr_w; } public short getImgr_h() { return imgr_h; } public void setImgr_h(short imgr_h) { this.imgr_h = imgr_h; } public Integer getValue() { return value; } public Integer getMinsize() { return minsize; } public void setMinsize(Integer minsize) { this.minsize = minsize; } public Integer getMaxsize() { return maxsize; } public void setMaxsize(Integer maxsize) { this.maxsize = maxsize; } public int getMax() { return max; } public void setMax(int max) { this.max = max; } public void setValue(Integer value) { if(value==0){ return; } double maxx = Double.parseDouble(max+""); double valuee = Double.parseDouble(value+""); double maxxx = Double.parseDouble(maxsize+""); value = (int) (valuee/maxx*maxxx); if(value<=maxsize){ this.value = value; repaint(); } } }
来源:即时通讯网 - 即时通讯开发者社区!
轻量级开源移动端即时通讯框架。
快速入门 / 性能 / 指南 / 提问
轻量级Web端即时通讯框架。
详细介绍 / 精编源码 / 手册教程
移动端实时音视频框架。
详细介绍 / 性能测试 / 安装体验
基于MobileIMSDK的移动IM系统。
详细介绍 / 产品截图 / 安装体验
一套产品级Web端IM系统。
详细介绍 / 产品截图 / 演示视频
引用此评论
引用:amumu 发表于 2015-8-26 19:20 看我头像,我家妹纸
引用:撸王之王撸断肠 发表于 2015-8-26 20:41 楼主代码能否提炼下,这样就能重用了,话说撸完妹子再撸你这代码试试
引用:lp563161210 发表于 2015-8-26 23:37 可以
引用:潴頭鎶鎶 发表于 2015-8-28 17:24 很明显,楼主就是大神!
引用:码神 发表于 2015-8-28 17:53 你这头像,是偷看女孩子上厕所被打的吗
引用:ionlywantto 发表于 2015-11-27 00:37 为什么在15,14这个坐标开始画
精华主题数超过100个。
连续任职达2年以上的合格正式版主
为论区做出突出贡献的开发者、版主等。
Copyright © 2014-2024 即时通讯网 - 即时通讯开发者社区 / 版本 V4.4
苏州网际时代信息科技有限公司 (苏ICP备16005070号-1)
Processed in 0.136724 second(s), 46 queries , Gzip On.