package rcpf1;
import java.io.InputStream;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
/**
* @author qzc
* 闪屏
*/
public class RcpSplash extends Shell implements Runnable{
private Integer iSleep=3000;//闪屏 时长
public Label c;
/**
*填充背景,能够随着宽高变化重新填充 setBackgroundImage的话是一次性填充不会重绘
*/
public void fillbg(Composite obj ,InputStream c) {//parent.setBackgroundImage(new Image(parent.getDisplay(),this.getClass().getResourceAsStream("/icons/bg.png")));
final Image image=new Image(obj.getDisplay(),c);
final int imgWidth = image.getBounds().width;
final int imgHeight = image.getBounds().height;
obj.addPaintListener(new PaintListener() {
@Override //jdk1.8需要 1.7不要
public void paintControl(PaintEvent event) {
event.gc.drawImage(image, 0, 0, imgWidth, imgHeight, 0, 0, event.width, event.height);
}
});
}
/**
* Create the shell.
* @param display
*/
public RcpSplash(Display display ) {
super(display, SWT.NO_TRIM |SWT.TOP);
//setBackgroundImage(new Image(display,this.getClass().getResourceAsStream("/icons/splash.png")));
//this.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
//this.setBackgroundMode(SWT.INHERIT_DEFAULT);
c=new Label(this,SWT.None);
c.setSize(800, 600);
c.setLocation(0, 0);
c.setImage(new Image(c.getDisplay(),this.getClass().getResourceAsStream("/icons/splash.png")));
fillbg(c.getParent(),this.getClass().getResourceAsStream("/icons/splash.png"));
setSize(800, 600);
setCenter(this);
open();
setActive();
}
@Override
public void run() {
try {
Display.getDefault().syncExec(new Runnable() {
public void run() {
open();
//layout();
try {
Thread.sleep(iSleep);
} catch (InterruptedException e) {
e.printStackTrace();
}
closesplash();
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
public static void setCenter(Shell shl)
{
int width = shl.getMonitor().getClientArea().width;
int height = shl.getMonitor().getClientArea().height;
int x = shl.getSize().x;
int y = shl.getSize().y;
if(x > width)
{
shl.getSize().x = width;
}
if(y > height)
{
shl.getSize().y = height;
}
shl.setLocation((width - x) / 2, (height - y) / 2);
}
@Override
protected void checkSubclass () {
//这个空函数不可少 解除不被子类化
}
public Integer getiSleep() {
return iSleep;
}
public void setiSleep(Integer iSleep) {
this.iSleep = iSleep;
}
public void closesplash() {
this.dispose();
}
}
eclipse开发rcp4应用示例


Eclipse RCP4是Eclipse Rich Client Platform的第四代版本,是一个用于构建桌面应用程序的框架。这个框架基于Java,提供了一种模块化、可扩展的方式来创建功能丰富的应用程序。在"eclipse开发rcp4应用示例"中,我们将探讨如何使用Eclipse RCP4构建一个应用程序,同时整合log4j日志系统以及自定义的启动画面(splashscreen)。 了解Eclipse RCP4的基础架构至关重要。它基于OSGi服务,允许你按需加载和卸载插件,这使得应用程序更加灵活且易于维护。要开始一个RCP4项目,你需要在Eclipse IDE中创建一个新的"RCP Application"项目,然后添加必要的组件和视图。 Log4j是一个广泛使用的Java日志框架,它提供了丰富的日志记录功能,如不同级别的日志输出(DEBUG、INFO、WARN、ERROR等)、日志配置的灵活性以及多种输出目的地(控制台、文件、数据库等)。在RCP4应用中集成log4j,你需要在项目中引入log4j的库,然后配置log4j.properties文件以定义日志级别、输出格式和目的地。你还可以编写代码来记录应用程序中的关键事件,帮助调试和监控程序运行状态。 自定义的splashscreen是在应用程序启动时显示的图片或动画,通常用来展示品牌信息或加载进度。在Eclipse RCP4中实现自定义splashscreen,你需要创建一个继承自`ISplashScreen`接口的类,并在其中实现展示和关闭启动画面的方法。然后,你需要在应用程序启动配置中指定你的自定义splashscreen类。这样,当应用程序启动时,自定义的启动画面就会先于主应用程序界面显示。 在压缩包文件"rcpf1"中,可能包含了项目源码、配置文件以及资源文件,例如log4j.properties配置、splashscreen图片等。这些文件可以帮助你理解和学习如何在实际项目中应用上述知识点。源码中可能展示了如何在Eclipse RCP4应用中导入并使用log4j,以及如何创建和使用自定义splashscreen的Java代码。 Eclipse RCP4提供了一个强大的平台来开发桌面应用程序,而通过整合log4j和自定义splashscreen,你可以提高应用程序的可维护性和用户体验。通过深入研究"eclipse开发rcp4应用示例"中的源码和配置,你将能够掌握这些技术的实用技巧,并进一步提升你的Java桌面应用开发能力。

























































- 1














- 粉丝: 90
- 资源: 55
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 永磁同步电机三闭环位置控制Simulink模型设计与实现:电流环、转速环及位置环控制,完美跟随指令信号的转子位置波形图(附设计原理文档),永磁同步电机三闭环位置控制Simulink模型设计与实现:电流
- 基于C语言实现的scc_compiler编译器设计源码
- 永磁同步电机最大转矩电流比与弱磁控制MATLAB Simulink仿真模型设计与运行展示:波形完美呈现,永磁同步电机MTPA+弱磁控制仿真模型:调试完毕,完美波形呈现,永磁同步电机最大转矩电流比控制M
- 自动驾驶技术下的五次多项式轨迹规划与智能车多性能综合评价函数MATLAB编程实现,自动驾驶技术下的五次多项式轨迹规划与智能车性能综合评价:MATLAB编程实现及算法优化,自动驾驶五次多项式轨迹规划
- 基于储能电站服务的冷热电多微网系统双层优化配置模型复现:长时间尺度储能配置与短时间尺度微网优化协同研究 ,“基于共享储能电站服务的冷热电多微网系统双层优化配置模型及其实时运行仿真”,基于储能电站服务的
- 基于交流变频调速系统的三相异步电机调速仿真技术研究,基于交流变频调速系统的三相异步电机调速仿真技术研究,交流变频调速系统 三相异步电机交流变频调速仿真 ,交流变频调速系统; 三相异步电机; 交流变频
- 基于PHP和前端技术的邮箱发送功能设计源码
- 基于Java技术的学校教务管理系统设计源码
- 基于SEO优化的京东招商页面CSS设计源码
- 基于TypeScript的综合性门户网站设计源码
- 基于STM32平台的便携式心电监测仪设计源码
- 苏苏源码-springboot406-基于Java的学生课堂管理系统(编号:619802100).zip
- 基于Java和HTML的CloudStreetVendor线上流动摊贩管理系统设计源码
- 基于Html与JavaScript的代码表白程序设计源码
- 基于Flink的Java与Scala混合编程实践教程设计源码
- 基于Java开发的青年志愿者信息管理系统设计源码



评论0