JavaSwing
相对路径获取图标
public class ZsxqForm {
private Image icon;
public ZsxqForm() {
icon = Toolkit.getDefaultToolkit().getImage(ZsxqForm.class.getResource("/com/xinzhang0618/icon/cat.png"));
...
public class ZsxqMain {
public static void main(String[] args) {
FlatLightLaf.setup();
JFrame frame = new JFrame("知识星球下载器v1.0");
ZsxqForm zsxqForm = new ZsxqForm();
frame.setContentPane(zsxqForm.getJPanelRoot());
frame.setIconImage(zsxqForm.getIcon());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
Java Swing+Ui designer项目打包
前言
- idea设置不需要变, ui-designer什么依赖也不需要引
- 真的不能直接maven clean package, 因为核心是要把ui-designer生成的代码以及intellij的class打进去
- 注意!!! 每次变更依赖后,整个”新增制品...“的流程都要重新操作一次!
操作步骤
只改我标的红框的部分, 其余不变
Project Structure新增制品
就已经ok了, 其余不动
进行构建