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);
    }

}

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

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

 

 

 

 

 

 

 

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

修改组件的宽度》

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632