public class JMSTest extends JFrame implements MessageListener {
private JScrollPane jScrollPane = null;
private JTextArea jTextArea = null;
private void initialize() {
this.setSize(300, 200);
this.setContentPane(getJContentPane());
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
this.setTitle("JFrame");
this.setVisible(true);
jTextField.grabFocus();
}
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJPanel(), java.awt.BorderLayout.SOUTH);
jContentPane.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
}
return jContentPane;
}
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane(getJTextArea());
//jScrollPane.setEnabled(false);
//jScrollPane.setAutoscrolls(true);
//jScrollPane.setViewportView(getJTextArea());
}
return jScrollPane;
}
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setEditable(false);
}
return jTextArea;
}
public void onMessage(Message message) {
try {
TextMessage textMsg = (TextMessage) message;
String text = textMsg.getText() + "\n";
jTextArea.append(text);
} catch (Exception ex) {
logger.error("fehler:" + ex);
}
}
}