一只风里 2021-06-20 14:58 采纳率: 42.9%
浏览 335
已采纳

Swing 在JFrame下添加JLabel出现乱码问题

窗口类:

public class Index_JFrame extends JFrame{
    private String title = "学生管理系统1.0";
    private final int width = 600;
    private final int height = 700;
    Container container;
//    private Component component;

    {
        //设置窗口标题
        this.setTitle(title);
        //定位窗口
        this.setBounds(400,200,width,height);
        this.setLayout(null);

        //获取Component对象,
        this.container = this.getContentPane();



        //设置标签
        JLabel userName = new JLabel("用户名");
        userName.setBounds(80,80,10,20);
        JLabel password = new JLabel("密码");
        password.setBounds(80,100,10,20);
        JLabel Verification_code = new JLabel("验证码");
        Verification_code.setBounds(80,120,10,20);

        //添加组件
        this.container.add(userName);
        this.container.add(password);
        this.container.add(Verification_code);

        //设置可见性
        this.setVisible(true);
        //设置是否可调整窗口大小
        this.setResizable(false);
        //设置窗口关闭监听事件
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

}

在启动类中创建窗口类对象后,运行发生这样的事情

不知道这个点点是乱码还是怎么回事

 

 

 

 

 

 

 

  • 写回答

2条回答 默认 最新

  • CSDN专家-sinJack 2021-06-20 14:59
    关注

    不是乱码,是你设置的组件显示大小有点问题

    修改组件的宽度》

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装