views:

130

answers:

1

I was try several opinion but neither of them it seams to work.

This method returns JTextArea

    private static JTextArea getJArea() {
 if (jArea == null) {
  jArea = new JTextArea();
  jArea.setBounds(new Rectangle(16, 153, 468, 139));
  jArea.setVisible(true);
     jArea.setLineWrap(true);
  jArea.setWrapStyleWord(true);
  jArea.setEditable(false);
  jsp.getViewport().add(jArea);

 }
 return jArea;
}

and i JDesktopPane i add this area with this code snippet

jDesktopPane.add(getJArea(), null);

And this not work, I was try to create a JScrollPane and assign JTextArea to him and add that to the JDesktopPane, but that also doesn't work.

+1  A: 

You need to use JInternalFrame too. JDesktopPane is supposed to be parent container for JInternalFrame objects.

JInternalFrame iframe = new JInternalFrame("Title", true, true, true, true);
iframe.setSize(180, 150);
iframe.setVisible(true);
iframe.getContentPane().add(new JScrollPane(new JTextArea("TestText",20,20)));
JDesktopPane desktop = new JDesktopPane();
desktop.add(iframe);

Then add the JDesktopPane to e.g. JFrame and you are done.

jitter
Yes, basically that's it. Thank you.
vaske
Just have to add ((javax.swing.plaf.basic.BasicInternalFrameUI) iframe.getUI()).setNorthPane(null);to remove the nort title bar, and thats it.
vaske