大屏客户端

master
王兵 11 months ago
parent 1361b1cb55
commit dc5cafb06d

7
.gitignore vendored

@ -4,8 +4,5 @@ pom.xml.releaseBackup
pom.xml.versionsBackup pom.xml.versionsBackup
pom.xml.next pom.xml.next
release.properties release.properties
dependency-reduced-pom.xml *.iml
buildNumber.properties .idea/
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

@ -0,0 +1,20 @@
## 大屏客户端
### 介绍
一体机、大屏、展示屏等终端设备需要全屏展示H5应用或统计大屏客户端
本程序采用java编写内核采用jcef java版本目前支持直接打包为exe其他系统支持需要二次开发
### 开发环境
jdk 11+
### 构建工具
Maven 3+
##### 版本说明
###### v0.0.1-SNAPSHOT
1. 开机自启
2. 自动全屏
3. 支持本地静态文件和在线地址
### 联系方式
E-Mailwangbing@wbsite.xyz

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

@ -0,0 +1,8 @@
#标题,默认ScreenClient
title=ScreenClient
#启动打开地址不写默认html/index.html
url=html/index.html
#默认大小full全屏normal正常
size=full

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<title>Welcome to ScreenClient!</title>
<style>
html { color-scheme: light dark; }
body { width: 40em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to ScreenClient!</h1>
<p>If you see this page, the ScreenClient server is successfully installed and
working. Further configuration is required.</p>
<h4>Config</h4>
<p>To modify the configuration please refer to 【default.config】</p>
<ul>
<li>title : Title of the application</li>
<li>url : File path (absolute or relative) or online address, default to html/index.htm</li>
<li>size : Default size at startup, full or normal</li>
</ul>
<h4>Shortcut</h4>
<ul>
<li>Esc : exit</li>
<li>F1 : set auto start</li>
<li>F2 : del auto start</li>
<li>F5 : refresh</li>
<li>F11 : full screen or normal</li>
</ul>
<p><em>Thank you for using ScreenClient.</em></p>
</body>
</html>

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.wbsite</groupId>
<artifactId>ScreenClient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ScreenClient</name>
<description>ScreenClient</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<maven.test.skip>true</maven.test.skip>
<spring-boot.version>2.3.7.RELEASE</spring-boot.version>
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
</properties>
<repositories>
<!-- 将中央仓库地址指向阿里云聚合仓库,提高下载速度 -->
<repository>
<id>central</id>
<name>Central Repository</name>
<layout>default</layout>
<url>https://maven.aliyun.com/repository/public</url>
</repository>
</repositories>
<pluginRepositories>
<!-- 将插件的仓库指向阿里云聚合仓库解决低版本maven下载插件异常或提高下载速度 -->
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://maven.aliyun.com/repository/public</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>me.friwi</groupId>
<artifactId>jcefmaven</artifactId>
<version>110.0.25.1</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.0.M2</version>
</dependency>
<!-- 首次运行自动解压出来,为了不增加包体积这边去除 -->
<dependency>
<groupId>me.friwi</groupId>
<artifactId>jcef-natives-windows-amd64</artifactId>
<version>jcef-87476e9+cef-110.0.25+g75b1c96+chromium-110.0.5481.78</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>me.friwi</groupId>-->
<!-- <artifactId>jcef-natives-windows-arm64</artifactId>-->
<!-- <version>jcef-87476e9+cef-110.0.25+g75b1c96+chromium-110.0.5481.78</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>me.friwi</groupId>-->
<!-- <artifactId>jcef-natives-linux-amd64</artifactId>-->
<!-- <version>jcef-87476e9+cef-110.0.25+g75b1c96+chromium-110.0.5481.78</version>-->
<!-- </dependency>-->
<!-- java注册全局热键 -->
<dependency>
<groupId>com.melloware</groupId>
<artifactId>jintellitype</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
<build>
<!-- 项目名称 -->
<finalName>${artifactId}-${version}</finalName>
<!-- 默认的主代码目录 -->
<sourceDirectory>src/main/java</sourceDirectory>
<!-- 默认的测试代码目录 -->
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${project.basedir}/src/main/resources/lib</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<!-- 打包可执行文件 -->
<plugin>
<groupId>io.github.fvarrui</groupId>
<artifactId>javapackager</artifactId>
<version>1.7.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
<configuration>
<!-- 程序入口 -->
<mainClass>xyz.wbsite.screen.Starter</mainClass>
<!-- 携带jre -->
<bundleJre>true</bundleJre>
<generateInstaller>true</generateInstaller>
<administratorRequired>false</administratorRequired>
<platform>windows</platform>
<displayName>${artifactId}</displayName>
<version>${version}</version>
<additionalResources>
<additionalResource>${project.basedir}/html</additionalResource>
<additionalResource>${project.basedir}/log</additionalResource>
<additionalResource>${project.basedir}/default.config</additionalResource>
<additionalResource>${project.basedir}/service.bat</additionalResource>
</additionalResources>
<linuxConfig></linuxConfig>
<macConfig></macConfig>
<winConfig>
<icoFile>${project.basedir}/ScreenClient.ico</icoFile>
<generateSetup>false</generateSetup>
<generateMsi>false</generateMsi>
<generateMsm>false</generateMsm>
</winConfig>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,63 @@
package xyz.wbsite.screen;
import cn.hutool.core.io.FileUtil;
import cn.hutool.log.StaticLog;
import cn.hutool.setting.dialect.Props;
import me.friwi.jcefmaven.CefInitializationException;
import me.friwi.jcefmaven.UnsupportedPlatformException;
import xyz.wbsite.screen.client.ShortCutUtil;
import xyz.wbsite.screen.client.WebClient;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
public class Starter {
public void run() throws InterruptedException, UnsupportedPlatformException, CefInitializationException, IOException {
// 检查配置文件
File configFile = new File("default.config");
System.out.println(configFile.getAbsolutePath());
if (!FileUtil.exist(configFile)) {
throw new IllegalArgumentException("default.config not exist!");
}
// 初始化配置
Props props = new Props(configFile);
// 初始化客户端
WebClient webClient = new WebClient(props);
// 焦点事件监听
webClient.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
StaticLog.debug("获得焦点事件");
}
@Override
public void focusLost(FocusEvent e) {
StaticLog.debug("丢失焦点事件");
}
});
// 添加一个鼠标点击监听
webClient.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
StaticLog.debug("鼠标点击事件");
}
});
// 调用脚本
webClient.executeJavaScript("console.log('java 调用 JavaScript')");
// 创建快捷方式使用
File targetFile = new File("ScreenClient.exe");
ShortCutUtil.createShortCutForDesktop(targetFile);
}
public static void main(String[] args) throws InterruptedException, UnsupportedPlatformException, CefInitializationException, IOException {
new Starter().run();
}
}

@ -0,0 +1,58 @@
package xyz.wbsite.screen.client;
public enum KeyEnum {
F1(112),
F2(113),
F3(114),
F4(115),
F5(116),
F6(117),
F7(118),
F8(119),
F9(120),
F10(121),
F11(122),
F12(123),
ESC(27),
TAB(9),
CAPSLOCK(20),
SHIFT(16),
CTRL(17),
START_LEFT(91),
START_RIGHT(92),
CONTEXT_MENU(93),
ALT(18),
SPACE(32),
CARRIAGE_RETURN(13),
LINE_FEED(10),
BACK_SLASH(220),
BACK_SPACE(8),
INSERT(45),
DEL(46),
HOME(36),
END(35),
PAGE_UP(33),
PAGE_DOWN(34),
PRINT_SCREEN(44),
SCR_LK(145),
PAUSE(19),
LEFT_ARROW_KEY(37),
UP_ARROW_KEY(38),
RIGHT_ARROW_KEY(39),
DOWN_ARROW_KEY(40),
MOD_ALT(1),
MOD_CONTROL(2),
MOD_SHIFT(4),
MOD_WIN(8);
private int value;
KeyEnum(int value) {
this.value = value;
}
public int value() {
return value;
}
}

@ -0,0 +1,177 @@
package xyz.wbsite.screen.client;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.system.SystemUtil;
import javax.swing.filechooser.FileSystemView;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
public class ShortCutUtil {
/**
*
*/
private static byte[] headFile = {0x4c, 0x00, 0x00, 0x00,
0x01, 0x14, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
(byte) 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46
};
/**
*
*/
private static byte[] fileAttributes = {(byte) 0x93, 0x00, 0x08, 0x00,//可选文件属性
0x20, 0x00, 0x00, 0x00,//目标文件属性
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//文件创建时间
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//文件修改时间
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//文件最后一次访问时间
0x00, 0x00, 0x00, 0x00,//文件长度
0x00, 0x00, 0x00, 0x00,//自定义图标个数
0x01, 0x00, 0x00, 0x00,//打开时窗口状态
0x00, 0x00, 0x00, 0x00,//热键
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00//未知
};
/**
* 1
*/
static byte[] fixedValueOne = {
(byte) 0x83, 0x00, 0x14, 0x00
, 0x1F, 0x50, (byte) 0xE0, 0x4F
, (byte) 0xD0, 0x20, (byte) 0xEA
, 0x3A, 0x69, 0x10, (byte) 0xA2
, (byte) 0xD8, 0x08, 0x00, 0x2B
, 0x30, 0x30, (byte) 0x9D, 0x19, 0x00, 0x2f
};
/**
* 2
*/
static byte[] fixedValueTwo = {
0x3A, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
, 0x00, 0x54, 0x00, 0x32, 0x00, 0x04
, 0x00, 0x00, 0x00, 0x67, 0x50, (byte) 0x91, 0x3C, 0x20, 0x00
};
/**
*
*
* @param source
* @param dest
* @throws IOException
*/
private static void copyFileUsingFileChannels(File source, File dest) throws IOException {
FileChannel inputChannel = null;
FileChannel outputChannel = null;
try {
inputChannel = new FileInputStream(source).getChannel();
outputChannel = new FileOutputStream(dest).getChannel();
outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
} finally {
inputChannel.close();
outputChannel.close();
}
}
/**
*
*
* @param lnk
* @param target (exe,path,bat...)
*/
public static void createShortCut(File lnk, File target) {
if (!SystemUtil.getOsInfo().isWindows()) {
System.out.println("当前系统不是window系统,无法创建快捷方式!!");
return;
}
try {
File touch = FileUtil.touch(lnk);
BufferedOutputStream stream = FileUtil.getOutputStream(touch);
stream.write(headFile);
stream.write(fileAttributes);
stream.write(fixedValueOne);
stream.write((target.getAbsolutePath().toCharArray()[0] + "").getBytes());
stream.write(fixedValueTwo);
stream.write(target.getAbsolutePath().substring(3).getBytes("gbk"));
stream.flush();
IoUtil.close(stream);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
*
* @param target
*/
public static File createShortCut(File target) {
File lnk = new File(target.getParentFile(), FileUtil.mainName(target) + ".lnk");
createShortCut(lnk, target);
return lnk;
}
/**
*
*
* @param target
*/
public static File createShortCutForDesktop(File target) {
File lnk = new File(FileSystemView.getFileSystemView().getHomeDirectory(), FileUtil.mainName(target) + ".lnk");
createShortCut(lnk, target);
return lnk;
}
/**
*
*
* @param targetFile
* @return
*/
public static boolean setStartup(File targetFile, boolean forAllUser) {
File shortCut = createShortCut(targetFile);
// 用户启动目录
String userStartup = System.getProperty("user.home") + "\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\";
// 系统启动目录
String sysStartup = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
String startup = forAllUser ? sysStartup : userStartup;
// 快捷方式复制到启动目录
FileUtil.copy(shortCut, new File(startup, shortCut.getName()), true);
return true;
}
public static boolean delStartup(File targetFile, boolean forAllUser) {
File shortCut = createShortCut(targetFile);
// 用户启动目录
String userStartup = System.getProperty("user.home") + "\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\";
// 系统启动目录
String sysStartup = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
String startup = forAllUser ? sysStartup : userStartup;
FileUtil.del(new File(startup, shortCut.getName()));
return true;
}
/**
*
*
* @param targetFile
* @return
*/
public static boolean setStartup(File targetFile) {
return setStartup(targetFile, false);
}
/**
*
*
* @param targetFile
* @return
*/
public static boolean delStartup(File targetFile) {
return delStartup(targetFile, false);
}
}

@ -0,0 +1,268 @@
package xyz.wbsite.screen.client;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.log.StaticLog;
import com.melloware.jintellitype.HotkeyListener;
import com.melloware.jintellitype.JIntellitype;
import me.friwi.jcefmaven.CefAppBuilder;
import me.friwi.jcefmaven.CefBuildInfo;
import me.friwi.jcefmaven.CefInitializationException;
import me.friwi.jcefmaven.MavenCefAppHandlerAdapter;
import me.friwi.jcefmaven.UnsupportedPlatformException;
import org.cef.CefApp;
import org.cef.CefClient;
import org.cef.browser.CefBrowser;
import javax.swing.*;
import java.awt.*;
import java.awt.event.FocusListener;
import java.awt.event.KeyListener;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
public class WebClient extends JFrame {
// 退出
private final int KEY_MARK_ESC = 1;
// 最小化
private final int KEY_MARK_SWITCH = 2;
// 刷新
private final int KEY_MARK_RELOAD = 3;
// 添加自启
private final int KEY_MARK_SET_START = 4;
// 移除自启
private final int KEY_MARK_DEL_START = 5;
private CefClient cefClient;
private CefApp cefApp;
private CefBrowser cefBrowser;
private String lastUrl = "about:blank";
private Properties config;
private final HotkeyListener hotkeyListener = new HotkeyListener() {
@Override
public void onHotKey(int i) {
switch (i) {
case KEY_MARK_ESC: {
StaticLog.info("exit.");
JIntellitype.getInstance().unregisterHotKey(KEY_MARK_ESC);
JIntellitype.getInstance().removeHotKeyListener(hotkeyListener);
close();
}
break;
case KEY_MARK_SWITCH: {
StaticLog.info("screen switch.");
if (getExtendedState() == Frame.NORMAL) {
removeNotify();
setUndecorated(true);
setExtendedState(JFrame.MAXIMIZED_BOTH);
} else {
setExtendedState(Frame.NORMAL);
removeNotify();
setUndecorated(false);
}
setVisible(true);
}
break;
case KEY_MARK_RELOAD: {
StaticLog.info("screen reload.");
reload();
}
break;
case KEY_MARK_SET_START: {
StaticLog.info("screen setStartup.");
setStartup();
}
break;
case KEY_MARK_DEL_START: {
StaticLog.info("screen delStartup.");
delStartup();
}
break;
}
}
};
public WebClient(Properties config) {
this.config = config;
try {
initCef(new String[]{});
initClient();
} catch (Exception e) {
StaticLog.error(e);
}
}
private void initClient() {
setTitle(getProp("title", "ScreenClient"));
getContentPane().add(cefBrowser.getUIComponent(), BorderLayout.CENTER);
setSize(800, 600);//初始大小
setLocation(0, 0);//位置
// 设置全屏模式
if ("full".equals(getProp("size", "full"))) {
setExtendedState(JFrame.MAXIMIZED_BOTH);
setUndecorated(true);
setAlwaysOnTop(true);
}
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// 关闭应用时要释放资源
CefApp.getInstance().dispose();
dispose();
System.exit(0);//0正常退出1非正常退出
}
});
// 添加热键
JIntellitype.getInstance().registerHotKey(KEY_MARK_ESC, 0, KeyEnum.ESC.value());
JIntellitype.getInstance().registerHotKey(KEY_MARK_SET_START, 0, KeyEnum.F1.value());
JIntellitype.getInstance().registerHotKey(KEY_MARK_DEL_START, 0, KeyEnum.F2.value());
JIntellitype.getInstance().registerHotKey(KEY_MARK_RELOAD, 0, KeyEnum.F5.value());
JIntellitype.getInstance().registerHotKey(KEY_MARK_SWITCH, 0, KeyEnum.F11.value());
JIntellitype.getInstance().addHotKeyListener(hotkeyListener);
//设置图标
URL resource = ResourceUtil.getResource("ScreenClient.png");
BufferedImage read = ImgUtil.read(resource);
setIconImage(read);
// 显示
setVisible(true);
}
/**
* CefBrowser
*
* @param args
*/
private void initCef(String[] args) throws InterruptedException, UnsupportedPlatformException, CefInitializationException, IOException {
CefAppBuilder builder = new CefAppBuilder();
// window下不需要OSR
boolean useOSR = false;
builder.getCefSettings().windowless_rendering_enabled = useOSR;
builder.setAppHandler(new MavenCefAppHandlerAdapter() {
@Override
public void stateHasChanged(org.cef.CefApp.CefAppState state) {
// 关闭应用时退出jvm运行
if (state == CefApp.CefAppState.TERMINATED) System.exit(0);
}
});
// 设置cef运行参数这里为空
builder.addJcefArgs(args);
// 这边不设置,程序会自动解压
// 设置 cef chrome实例的目录关键若不设置他会默认从网络中下载国外网络可能下载不稳定导致失败
// 我的 cef chrome 位于项目的chrome目录下 C:\Users\Administrator\Desktop\project\java\demo-desktop\chrome
// builder.setInstallDir(new File(System.getProperty("user.dir") + File.separator + "chrome"));
// 由于是手动设置cef的chrome我们要跳过ins检查防止版本不一致导致从镜像站下载
// builder.setSkipInstallation(true);
// 全局的 CefApp 每个程序只能有一个,线程安全
cefApp = builder.build();
// 显示一些版本信息
CefBuildInfo buildInfo = CefBuildInfo.fromClasspath();
StaticLog.info(buildInfo.toString());
CefApp.CefVersion cefVersion = cefApp.getVersion();
StaticLog.info(cefVersion.toString());
// 创建一个浏览器客户端实例
cefClient = cefApp.createClient();
// 创建一个浏览器实例
lastUrl = getProp("url", "html/index.html");
// 处理非http时的相对路径
if (!lastUrl.startsWith("http")) {
lastUrl = new File(lastUrl).getAbsolutePath();
}
cefBrowser = cefClient.createBrowser(lastUrl, useOSR, true);
}
/**
*
*
* @param url
* @throws InterruptedException
*/
public void loadUrl(String url) throws InterruptedException {
// 必须延迟,否则可能因为切换太快无法加载成功
Thread.sleep(300);
lastUrl = url;
// 处理非http时的相对路径
if (!lastUrl.startsWith("http")) {
lastUrl = new File(lastUrl).getAbsolutePath();
}
cefBrowser.loadURL(url);
}
/**
*
*/
public void reload() {
// 创建一个浏览器实例
cefBrowser = cefClient.createBrowser(lastUrl, false, true);
getContentPane().remove(0);
getContentPane().add(cefBrowser.getUIComponent(), BorderLayout.CENTER);
setVisible(true);
}
/**
*
*/
public void setStartup() {
if (ShortCutUtil.setStartup(new File("ScreenClient.exe"))) {
executeJavaScript("alert('set startup success')");
} else {
executeJavaScript("alert('set startup failed')");
}
}
/**
*
*/
public void delStartup() {
if (ShortCutUtil.delStartup(new File("ScreenClient.exe"))) {
executeJavaScript("alert('del startup success')");
} else {
executeJavaScript("alert('del startup failed')");
}
}
private String getProp(String key, String defaultValue) {
return Convert.toStr(config.getProperty(key), defaultValue);
}
public void addFocusListener(FocusListener listener) {
cefBrowser.getUIComponent().addFocusListener(listener);
}
public void addMouseListener(MouseListener listener) {
cefBrowser.getUIComponent().addMouseListener(listener);
}
public void addKeyListener(KeyListener listener) {
cefBrowser.getUIComponent().addKeyListener(listener);
}
public void executeJavaScript(String javascript) {
cefBrowser.executeJavaScript(javascript, null, 1);
}
public void close() {
// 关闭应用时要释放资源
CefApp.getInstance().dispose();
dispose();
System.exit(0);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,34 @@
#-----------------------------------------------------------------------------------------------------------
# == JDK Logging 配置文件 ==
#Level的五个等级
# SEVERE
# WARNING
# INFO
# CONFIG
# FINE
# FINER
# FINEST
#
#-----------------------------------------------------------------------------------------------------------
# 日志格式
#java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n
#指定Root Logger级别
.level=ALL
#为 Handler 指定默认的级别(默认为 Level.INFO
java.util.logging.ConsoleHandler.level=ALL
# 指定要使用的 Formatter 类的名称(默认为 java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.formatter=logging.formatter.MySimpleFormatter
# 为 Handler 指定默认的级别(默认为 Level.ALL
java.util.logging.FileHandler.level=INFO
# 指定要使用的 Formatter 类的名称(默认为 java.util.logging.XMLFormatter
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
# 指定要写入到任意文件的近似最大量(以字节为单位)。如果该数为 0则没有限制默认为无限制
java.util.logging.FileHandler.limit=1024000
# 指定有多少输出文件参与循环(默认为 1
java.util.logging.FileHandler.count=1
# 为生成的输出文件名称指定一个模式。有关细节请参见以下内容(默认为 "%h/java%u.log")。
java.util.logging.FileHandler.pattern=log/info.log
# 指定是否应该将 FileHandler 追加到任何现有文件上(默认为 false
java.util.logging.FileHandler.append=true
# 执行的LogHandler使用逗号隔开
handlers=java.util.logging.ConsoleHandler,java.util.logging.FileHandler
Loading…
Cancel
Save

Powered by TurnKey Linux.