【发布时间】:2017-04-30 05:38:24
【问题描述】:
public void NewMessage(){
JPanel panel = new JPanel();
JLabel label = new JLabel("Enter message:");
JTextArea msgBodyContainer = new JTextArea(10,20);
msgBodyContainer.setAutoscrolls(true);
panel.add(label);
panel.add(msgBodyContainer);
String[] options = new String[]{"OK", "Cancel"};
int option = JOptionPane.showOptionDialog(null, panel, "Message "+searchedProfileFirstName,
JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE,
null, options, options[1]);
if(option == 0) // pressing OK button
{
}
}
这是我在定义的方法 NewMessage() 中使用的代码。 我的问题是我想防止这种情况发生: Picture of problem
1-可见,文本区域自动放大,超出面板边界不可见 2-标签“输入消息”向下移动到垂直居中与文本区域对齐
【问题讨论】:
-
将
JTextArea放入JScrollPane -
我试过这样做,然后说 panel.addScrollpane 和 scrollpane.addtextarea 东西滚动窗格本身最终没有显示
标签: java netbeans textarea panel jdialog