Java问题集

1、IDEA 编译输出目录 Compiler Output的设置

1.1 idea 项目整体Project 编译输出目录设置

  • File ——> Project Structure ——> Project ——> Compiler Output
  • 填写内容: 项目路径\out

1.2 idea 项目模块Module 编译输出目录设置

  • File ——> Project Structure ——> Module ——> Path ——> Compiler Output ——> Use module compiler output path
  • 填写内容: 项目路径\target\classes

2、java.lang.IllegalArgumentException异常:无法无法添加到layout:约束必须是字符串

  • 问题:在编写多选框按钮布局时,使用容器添加按钮,流式布局时,运行出现问题

  • 问题:在编写多选框按钮布局时,使用容器添加按钮,流式布局时,运行出现问题

    container.add(jCheckBox,new FlowLayout());
    container.add(jCheckBox2,new FlowLayout());
    container.add(jCheckBox3,new FlowLayout());
    container.add(jCheckBox4,new FlowLayout());
    

  • 解决办法:

    // 在容器container创建前,设置主窗口的布局
            this.setLayout(new FlowLayout()); // this 表示主窗口frame或Jframe
            Container container = this.getContentPane();
    
posted @ 2023-03-26 18:22  Moon888  阅读(125)  评论(0)    收藏  举报