为了账号安全,请及时绑定邮箱和手机立即绑定

限制每个 JTextArea 行上的字符数

限制每个 JTextArea 行上的字符数

12345678_0001 2021-05-31 12:53:19
我有JTextArea一个JDialog. JDialog使用一个GridLayout.我想在每行上有 7 位数字JTextArea(每行将是 7 个int注册号)。出于用户体验的原因,我希望在JTextArea一行达到 7 个字符时添加新行或停止扩展。不起作用的事情: - 在JTextArea构造函数中指定列数-matriculesText.setLineWrap(true);和matriculesText.setWrapStyleWord(true);我担心uploadDialogManager.setHgap(20);可能会破坏密码。我想知道是否JDialog应该有一个固定的大小。这就是我构建我的方式JDialog:// initialization    Dialog uploadParent = null;    JDialog uploadDialog = new JDialog(uploadParent);    GridLayout uploadDialogManager = new GridLayout(UPLOAD_DIALOG_ROWS, UPLOAD_DIALOG_COLUMNS);    // uploadDialog properties    uploadDialog.setSize(new Dimension(UPLOAD_DIALOG_WIDTH, UPLOAD_DIALOG_HEIGHT));    uploadDialog.setLayout(uploadDialogManager);    uploadDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);    //Set up the horizontal gap value    uploadDialogManager.setHgap(20);    //Set up the vertical gap value    uploadDialogManager.setVgap(20);    //Set up the layout of the buttons    //uploadDialogManager.layoutContainer();    // components initialization    JLabel exerciceLabel = new JLabel("exercice number : ");    JComboBox<Integer> exerciceNumbers = new JComboBox<Integer>   (EXERCICE_NUMBERS);    JLabel matriculeLabel = new JLabel("please enter your matricules, one per   line : ");    JTextArea matriculesText = new JTextArea(1, 1);    JButton confirm = new JButton("confirm");    JButton cancel = new JButton("cancel");    matriculesText.setLineWrap(true);    matriculesText.setWrapStyleWord(true);
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 307 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信