设计图标

This commit is contained in:
yang 2022-10-09 16:07:48 +08:00
parent 9350c7f699
commit 56b69cb95c
6 changed files with 14 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import javafx.scene.paint.Paint;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.StageStyle; import javafx.stage.StageStyle;
import org.rococy.roomit.config.ConfigurationManager; import org.rococy.roomit.config.ConfigurationManager;
import org.rococy.roomit.constant.GlobalConsts;
import org.rococy.roomit.constant.KeyBoardConsts; import org.rococy.roomit.constant.KeyBoardConsts;
import org.rococy.roomit.domain.KeyBoardConfiguration; import org.rococy.roomit.domain.KeyBoardConfiguration;
import org.rococy.roomit.listener.TrayIconMouseListener; import org.rococy.roomit.listener.TrayIconMouseListener;
@ -97,7 +98,7 @@ public class MainWindow extends Application {
// 获取系统托盘 // 获取系统托盘
SystemTray systemTray = SystemTray.getSystemTray(); SystemTray systemTray = SystemTray.getSystemTray();
// 加载托盘图片 16*16的png图片 // 加载托盘图片 16*16的png图片
URL imageUrl = Objects.requireNonNull(MainWindow.class.getResource("/org/rococy/roomit/img/a.png")); URL imageUrl = Objects.requireNonNull(MainWindow.class.getResource(GlobalConsts.LOGO_PATH));
TrayIcon trayIcon = new TrayIcon(ImageIO.read(imageUrl), "RoomIt"); TrayIcon trayIcon = new TrayIcon(ImageIO.read(imageUrl), "RoomIt");
// 托盘图片自适应大小 // 托盘图片自适应大小
trayIcon.setImageAutoSize(true); trayIcon.setImageAutoSize(true);

View File

@ -3,9 +3,11 @@ package org.rococy.roomit;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.paint.Paint; import javafx.scene.paint.Paint;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.rococy.roomit.constant.GlobalConsts;
import java.io.IOException; import java.io.IOException;
@ -38,6 +40,8 @@ public class SettingWindow extends Application {
scene.setFill(Paint.valueOf("#00000000")); scene.setFill(Paint.valueOf("#00000000"));
// 设置场景 // 设置场景
stage.setScene(scene); stage.setScene(scene);
// 设置图标
stage.getIcons().add(new Image(GlobalConsts.LOGO_PATH));
// 将窗口显示出来 // 将窗口显示出来
stage.show(); stage.show();
} }

View File

@ -4,10 +4,12 @@ import javafx.application.Application;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.paint.Paint; import javafx.scene.paint.Paint;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.WindowEvent; import javafx.stage.WindowEvent;
import org.rococy.roomit.constant.GlobalConsts;
import java.io.IOException; import java.io.IOException;
@ -46,6 +48,8 @@ public class ToolsWindow extends Application {
// 只有一个x的任务栏 // 只有一个x的任务栏
stage.setResizable(false); stage.setResizable(false);
stage.initModality(Modality.APPLICATION_MODAL); stage.initModality(Modality.APPLICATION_MODAL);
// 设置图标
stage.getIcons().add(new Image(GlobalConsts.LOGO_PATH));
// 置顶 // 置顶
stage.setAlwaysOnTop(true); stage.setAlwaysOnTop(true);
} catch (IOException e) { } catch (IOException e) {

View File

@ -11,5 +11,9 @@ public class GlobalConsts {
*/ */
public static final String THEME_COLOR = "linear-gradient(to bottom, #f64f59, #c471ed, #12c2e9)"; public static final String THEME_COLOR = "linear-gradient(to bottom, #f64f59, #c471ed, #12c2e9)";
/**
* logo图标路径
*/
public static final String LOGO_PATH = "/org/rococy/roomit/img/logo24x24.png";
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B