import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;
public class JImagePane extends JPanel
{
private static final long serialVersionUID = -8251916094895167058L;
/**
* 居中
*/
public static final String CENTRE = "Centre";
/**
* 平铺
*/
public static final String TILED = "Tiled";
/**
* 拉伸
*/
public static final String SCALED = "Scaled";
/**
* 背景图片
*/
private Image backgroundImage;
/**
* 背景图片显示模式
*/
private String imageDisplayMode;
/**
* 背景图片显示模式索引(引入此属性有助于必要时扩展)
*/
private int modeIndex;
/**
* 构造一个没有背景图片的JImagePane
*/
public JImagePane()
{
this(null, CENTRE);
}
/**
* 构造一个具有指定背景图片和指定显示模式的JImagePane
* @param image 背景图片
* @param modeName 背景图片显示模式
*/
public JImagePane(Image image, String modeName)
{
super();
setBackgroundImage(image);
setImageDisplayMode(modeName);
}
/**
* 设置背景图片
* @param image 背景图片
*/
public void setBackgroundImage(Image image)
{
this.backgroundImage = image;
this.repaint();
}
/**
* 获取背景图片
* @return 背景图片
*/
public Image getBackgroundImage()
{
return backgroundImage;
}
/**
* 设置背景图片显示模式
* @param modeName 模式名称,取值仅限于ImagePane.TILED ImagePane.SCALED ImagePane.CENTRE
*/
public void setImageDisplayMode(String modeName)
{
if(modeName != null)
{
modeName = modeName.trim();
//居中
if(modeName.equalsIgnoreCase(CENTRE))
{
this.imageDisplayMode = CENTRE;
modeIndex = 0;
}
//平铺
else if(modeName.equalsIgnoreCase(TILED))
{
this.imageDisplayMode = TILED;
modeIndex = 1;
}
//拉伸
else if(modeName.equalsIgnoreCase(SCALED))
{
this.imageDisplayMode = SCALED;
modeIndex = 2;
}
this.repaint();
}
}
/**
* 获取背景图片显示模式
* @return 显示模式
*/
public String getImageDisplayMode()
{
return imageDisplayMode;
}
/**
* 绘制组件
* @see javax.swing.JComponent#paintComponent(Graphics)
*/
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
//如果设置了背景图片则显示
if(backgroundImage != null)
{
int width = this.getWidth();
int height = this.getHeight();
int imageWidth = backgroundImage.getWidth(this);
int imageHeight = backgroundImage.getHeight(this);
switch(modeIndex)
{
//居中
case 0:
{
int x = (width - imageWidth) / 2;
int y = (height - imageHeight) / 2;
g.drawImage(backgroundImage, x, y, this);
break;
}
//平铺
case 1:
{
for(int ix = 0; ix < width; ix += imageWidth)
{
for(int iy = 0; iy < height; iy += imageHeight)
{
g.drawImage(backgroundImage, ix, iy, this);
}
}
break;
}
//拉伸
case 2:
{
g.drawImage(backgroundImage, 0, 0, width, height, this);
break;
}
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
使用exe4j 制作java启动程序的 等候界面
共60个文件
png:13个
class:10个
java:9个
需积分: 50 33 下载量 4 浏览量
2014-06-12
09:47:27
上传
评论 1
收藏 5.32MB RAR 举报
温馨提示
使用exe4j 制作java启动程序的 等候界面,使用了 JDK6 自带splash功能。 备注 exe/jre 文件夹中 包含了 jre ,但由于大小问题,无法上传。
资源推荐
资源详情
资源评论
收起资源包目录
splash+EXE4J.rar (60个子文件)
splash+EXE4J
splash
bin
SplashTest
1.jpg 232KB
ssms.png 59KB
Main.class 982B
Main$1.class 1KB
META-INF
MANIFEST.MF 161B
.settings
org.eclipse.jdt.core.prefs 629B
src
SplashTest
1.jpg 232KB
ssms.png 59KB
Main.java 3KB
.project 382B
.classpath 301B
Logo
bin
1.jpg 3KB
测试.jpg 232KB
Logo.class 2KB
JWindowDemo.class 4KB
src
1.jpg 3KB
Logo.java 1KB
测试.jpg 232KB
JWindowDemo.java 2KB
.project 380B
.classpath 232B
Sample
bin
Test.class 489B
JImagePane.class 2KB
1.jpg 232KB
img
ssms.png 59KB
fqdb.png 72KB
epms.png 49KB
ssms.png 59KB
ECreateIcon.class 2KB
ESplash.class 3KB
WelcomeWindow.class 2KB
Sample.class 3KB
.settings
org.eclipse.jdt.core.prefs 629B
src
1.jpg 232KB
img
ssms.png 59KB
fqdb.png 72KB
epms.png 49KB
ssms.png 59KB
ECreateIcon.java 746B
JImagePane.java 4KB
ESplash.java 3KB
Sample.java 2KB
Test.java 360B
WelcomeWindow.java 2KB
.project 382B
.classpath 295B
exe
error.log 73B
fqdb.exe 430KB
ui-7_2.png 99KB
Sample.exe 714KB
splash
Splash.jar 26KB
fffff.jar 286KB
ff.jar 60KB
test_lib
test.jar 467KB
ui-3.png 113KB
ssms.exe 362KB
final.jar 286KB
exe.rar 768KB
ui-5.png 181KB
epms.exe 348KB
共 60 条
- 1
资源评论
OkidoGreen
- 粉丝: 7234
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功