一只风里 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条)

报告相同问题?

悬赏问题

  • ¥15 maixpy训练模型,模型训练好了以后,开发板通电会报错,不知道是什么问题
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容