Class TerminalFrameTitle doesn't work
Edilmar
edilista at intersite.com.br
Mon Oct 31 23:21:28 MET 2005
Hi,
I use MindTerm 2.4.2 + JDK 1.5.0.
When I try to setup title of the frame using TerminalFrameTitle class,
it doesn't work.
It sets up the title before the prompt to appear. After this, it changes
the title I made and put "title = <myuser>@<myhost>:~ [80x24]".
Here is the code, something like BasicClient.java from MindTerm examples:
public class jinternalssh extends JFrame implements
TerminalMenuListener, Runnable {
private TerminalWin terminal;
private SSH2Transport transport;
private SSH2SimpleClient client;
private SSH2ConsoleRemote console;
private Properties props;
private LineReaderTerminal lineReader;
private int port, exitStatus;
private String host, user, passwd, title;
public jinternalssh(String host, String user, String passwd) {
title = "Host: " + host + " - Usuario: " + user;
this.setTitle(title);
this.exitStatus = 1;
this.host = host;
this.user = user;
this.passwd = passwd;
this.port = 22;
}
public void run() {
try {
props = new Properties();
terminal = new TerminalWin(this, new TerminalXTerm(), props);
RandomSeed seed = new RandomSeed();
seed.addEntropyGenerator(terminal);
setLayout(new BorderLayout());
add(terminal.getPanelWithScrollbar(), BorderLayout.CENTER);
TerminalFrameTitle frameTitle = new TerminalFrameTitle(this, title);
frameTitle.attach(terminal);
TerminalMenuHandler tmenus = null;
terminal.setClipboard(GlobalClipboard.getClipboardHandler());
pack();
show();
lineReader = new LineReaderTerminal(terminal);
terminal.write("jssh - Aplicacao Cliente de SSH - carregando
terminal...\n\r");
terminal.write(title + "\n\r");
terminal.write("========================================================\n\r\n\r");
SSH2Preferences prefs = new SSH2Preferences(props);
// It is important that the random number generator here is good!
SecureRandomAndPad secureRandom = new SecureRandomAndPad(
new SecureRandom(seed.getBytesBlocking(20, false)));
/*
* Open the TCP connection to the server and create the
* SSH2Transort object. No traffic will be sent yet.
*/
transport = new SSH2Transport(new Socket(host, port), prefs,
secureRandom);
/*
* Prepare for host fingerprint verification.
* This implementation check fingerprints agains properties of
* the form: fingerprint.HOSTNAME.PORT
*/
String fingerprint = props.getProperty("fingerprint." + host + "."
+ port);
/*
* If we found a fingerprint property for this host:port then
* create a key verifier which checks that the fingerprint of the
* actual host matches.
*/
if(fingerprint != null) {
transport.setEventHandler(new SSH2HostKeyVerifier(fingerprint));
}
client = new SSH2SimpleClient(transport, user, passwd);
// This class will not interact with the user anymore.
lineReader.detach();
/*
* Create the remote console to use for command execution.
*/
console = new SSH2ConsoleRemote(client.getConnection());
SSH2TerminalAdapterImpl termAdapter = new
SSH2TerminalAdapterImpl(terminal);
if(!console.terminal(termAdapter)) {
throw new Exception("Nao foi possivel abrir terminal!");
}
exitStatus = console.waitForExitStatus();
} catch (LineReaderTerminal.ExternalMessageException e) {
// ignore
} catch (Exception e) {
System.out.println("Erro ocorrido: " + e.getMessage());
} finally {
dispose();
}
}
public void windowClosing(WindowEvent e) {
doClose();
}
public void close(TerminalMenuHandler originMenu) {
doClose();
}
public void doClose() {
if(lineReader != null) {
lineReader.breakPromptLine("");
}
if(console != null) {
console.close();
}
if(transport != null) {
transport.normalDisconnect("Usuario desconectado.");
}
}
public void update() {
}
}
!DSPAM:43662ffd1090666975890!
More information about the Mindterm-users
mailing list