我在JDialog中有一个JTextArea。JDialog使用GridLayout。
我想在JTextArea的每一行上有7位数字(每一行将是一个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);https://stackoverflow.com/questions/51390982
复制相似问题