|
Creates a black window that covers the whole screen
and prints the message text letter by letter
private void doAsInTheMatrix(final Message msg) {
final String text = (String) msg.content;
final JDialog d = new JDialog();
final JTextArea textArea = new JTextArea("");
textArea.setBackground(Color.BLACK);
textArea.setFont(new Font("Monospaced", Font.BOLD, 26));
textArea.setEditable(false);
textArea.setForeground(Color.green);
textArea.setOpaque(true);
d.setModal(true);
d.getContentPane().setLayout(new BorderLayout());
d.getContentPane().add(textArea, BorderLayout.CENTER);
d.setSize(Toolkit.getDefaultToolkit().getScreenSize());// Wake up Neo!
d.setUndecorated(true);
d.requestFocus();
textArea.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
d.addWindowListener(new WindowAdapter() {
public void windowOpened(WindowEvent e) {
new Thread() {
public void run() {
try {
final StringBuffer sb = new StringBuffer();
for (int i = 0; i < text.length(); i++) {
Thread.sleep(150);
sb.append(text.charAt(i));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
textArea.setText(sb.toString());
}
});
}
Thread.sleep(7 * 1000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
d.dispose();
}
});
}
}.start();
}
});
SwingUtilities.invokeLater(new Runnable() {
public void run() {
d.setVisible(true);
}
});
}
|