Code to set up a Dockable Window with a scrollbar


Details

Shows how to set up a Dockable Window with a scrollbar.


Original author/s: Olly Burdekin
Original location/s:
Adapted by:
License: none


Imports and instance variables

	import javax.swing.*;
	
	TextArea textArea = new TextArea();

Code

	@Override
	public Component createUI() {
		JPanel jPanel = new JPanel();
		JScrollPane scrollPane = new JScrollPane(jPanel);

		jPanel.setLayout(new BorderLayout());
		jPanel.add(textArea, BorderLayout.NORTH);

		return scrollPane;
	}

	public void setText(String text) {
		textArea.replaceSelection(text);
	}