Double JscrollPane (JPanel + JTextArea)
Bonjour,
Dans mon interface j'ai un JScrollPane qui contient un JPanel (jpConfig) qui lui même contient un ensemble de JScrollPane contenant chacun un JTextArea (field).
Je dis variable car mon application génère automatiquement un formulaire à partir de données enregistrée et définit des labels et des champs dans le JPanel.
Mon soucis est que je ne parviens pas a afficher des JScrollPane sur les JTextArea car ceux-ci se trouvent dans un JPanel déjà avec un JScrollPane.
Est-ce normal ?
Comment pourrais-je faire?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
// JScrollPane OK
this.add(new JScrollPane(jpConfig));
//...
for (String sParam : lParams) {
sParam = sParam.trim();
String sType = sParam.substring(0, 3);
String sFieldName = sParam.substring(3, sParam.length());
JTextComponent field = null;
if (sType.equals("jtf")) {
field = new JTextField();
} else if (sType.equals("jpa")) {
field = new JPasswordField();
} else if (sType.equals("jta")) {
field = new JTextArea();
((JTextArea)field).setRows(8);
} else {
continue;
}
String sLabel = tool.getParameters().get("l" + sFieldName);
JLabel jlabel = new JLabel("<html>" + sLabel + "</html>");
field.setText(tool.getParameters().get(sParam));
JPanel jp = new JPanel(new BorderLayout());
jp.add(jlabel, BorderLayout.WEST);
jp.setBackground(Design.CLR_BCKGRD);
int x = jpConfig.getWidth() / 2;
field.setPreferredSize(new Dimension(x, 25));
if (field instanceof JTextArea) {
((JTextArea)field).setRows(6);
// TODO JScrollPane qui n'apparait pas
jp.add(new JScrollPane((JTextArea)field), BorderLayout.EAST);
} else {
jp.add(field, BorderLayout.EAST);
}
jpConfig.add(jp);
if (configTool.get(tool).containsKey(sParam)) {
configTool.get(tool).remove(sParam);
}
configTool.get(tool).put(sParam, field);
} |