Using the AWT Component

Lee Painter

Setting up

You will first need to import the terminal-awt module in your maven project.


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:


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.