将图片路径都改成包名路径

This commit is contained in:
2025-02-06 20:54:58 +08:00
parent f3da2681f3
commit 81d7581531
5 changed files with 12 additions and 7 deletions
+2 -1
View File
@@ -61,7 +61,8 @@ public class LoginFrm extends javax.swing.JFrame {
// 初始化登录消息异常处理对象
loginMessangeExpection = new LoginMessangeExpection();
// 设置窗口图标
setIconImage(new ImageIcon("src/com/msksbr/images/mainicon.png").getImage());
setIconImage(new ImageIcon(LoginFrm.class.getResource("/com/msksbr/images/mainicon.png")).getImage());
try {
// 创建数据库连接器
connector = new Connector();
+4 -2
View File
@@ -36,7 +36,7 @@ public class MainFrm extends JFrame {
*/
public MainFrm() throws SQLException, ClassNotFoundException {
// 设置窗口图标
setIconImage(new ImageIcon("src/com/msksbr/images/mainicon.png").getImage());
setIconImage(new ImageIcon(MainFrm.class.getResource("/com/msksbr/images/mainicon.png")).getImage());
// 初始化数据库连接器
connector = new Connector();
// 设置窗口标题
@@ -61,7 +61,9 @@ public class MainFrm extends JFrame {
// 将统计信息标签添加到底部面板
bottomPanel.add(countMessage);
// 创建并设置背景图片
ImageIcon imageIcon = new ImageIcon("src/com/msksbr/images/backGround.png");
// 创建一个 ImageIcon 对象,用于加载背景图片
ImageIcon imageIcon = new ImageIcon(MainFrm.class.getResource("/com/msksbr/images/backGround.png"));
imageIcon.setImage(imageIcon.getImage().getScaledInstance(250, 250, 0));
// 设置背景标签的图标
backLabel.setIcon(imageIcon);
@@ -39,7 +39,9 @@ public class AcademyThanksDialog extends JDialog {
});
// 设置图片标签的图标
imageLabel.setIcon(new ImageIcon("src/com/msksbr/images/academy_logo.png"));
// 设置图片标签的图标为指定路径的图片
imageLabel.setIcon(new ImageIcon(AcademyThanksDialog.class.getResource("/com/msksbr/images/academy_logo.png")));
// 调整对话框大小以适应内容
pack();
// 设置对话框不可调整大小
@@ -32,7 +32,8 @@ public class AuthorDIalog extends JDialog {
// 创建作者标签并设置图标
JLabel authorLabel = new JLabel();
authorLabel.setIcon(new ImageIcon("src/com/msksbr/images/AuthorProfile.jpg"));
authorLabel.setIcon(new ImageIcon(AuthorDIalog.class.getResource("/com/msksbr/images/AuthorProfile.jpg")));
// 将作者标签添加到图标面板
iconPanel.add(authorLabel);
+1 -2
View File
@@ -30,8 +30,7 @@ public class EasterEgg extends JDialog {
// 设置默认按钮为 buttonOK
getRootPane().setDefaultButton(buttonOK);
// 设置 imageLable 的图标为指定路径的图像
imageLable.setIcon(new ImageIcon("src/com/msksbr/images/BuzzBeans.png"));
imageLable.setIcon(new ImageIcon(EasterEgg.class.getResource("/com/msksbr/images/BuzzBeans.png")));
// 为 buttonOK 添加动作监听器
buttonOK.addActionListener(new ActionListener() {
/**