Setting up
You will first need to import the terminal-awt module in your maven project.
<dependencies> <dependency> <groupId>com.sshtools</groupId> <artifactId>terminal-awt</artifactId> <version>3.0.0-SNAPSHOT</version> </dependency> </dependencies> <repositories> <repository> <id>sshtools</id> <name>sshtools</name> <url>http://artifactory.javassh.com/opensource-releases</url> </repository> </repositories>
Creating the Terminal Display
import com.sshtools.terminal.vt.awt.AWTTerminalPanel;
import com.sshtools.terminal.vt.awt.AWTScrollBar;
import java.awt.Frame;
import java.awt.BorderLayout;
First off you'll need the actual AWT component. This can be added to your UI as any other component would be.
Frame frame = new Frame("Terminal");
frame.setLayout(new BorderLayout());
AWTTerminalPanel display = new AWTTerminalPanel();
frame.add(display, BorderLayout.CENTER);
You probably want a scrollbar to allow scrolling back through previous output:
frame.add(new AWTScrollBar(display), BorderLayout.EAST);
Now pack and display your frame:
frame.pack();
frame.setVisible(true);
You will next need to obtain a reference to the terminal and connect the terminal to a remote host. Return to the article Integrating a Terminal Into Your Application to complete this.