Mercurial > hg > jslab
comparison src/samer/core_/util/heavy/CommandField.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 /* | |
2 * CommandField.java | |
3 * | |
4 * Copyright (c) 2000, Samer Abdallah, King's College London. | |
5 * All rights reserved. | |
6 * | |
7 * This software is provided AS iS and WITHOUT ANY WARRANTY; | |
8 * without even the implied warranty of MERCHANTABILITY or | |
9 * FITNESS FOR A PARTICULAR PURPOSE. | |
10 */ | |
11 | |
12 package samer.core.util.heavy; | |
13 import samer.core.*; | |
14 import java.awt.*; | |
15 import java.awt.event.*; | |
16 import java.io.*; | |
17 | |
18 public class CommandField extends TextField | |
19 { | |
20 public CommandField(int w) | |
21 { | |
22 super(w); | |
23 | |
24 setBackground( Shell.getColor("awt.input.console.background", Color.black)); | |
25 setForeground( Shell.getColor("awt.input.console.foreground", Color.orange)); | |
26 try { setFont(X.font(Shell.datum("awt.input.console.font"),null)); } | |
27 catch (Exception ex) { /* ok if no font specified */ } | |
28 addActionListener(h); | |
29 addKeyListener(h); | |
30 } | |
31 | |
32 static Handler h = new Handler(); | |
33 static class Handler extends KeyAdapter implements ActionListener, java.io.Serializable | |
34 { | |
35 String last; | |
36 | |
37 public void actionPerformed(ActionEvent e) { | |
38 Object o = e.getSource(); | |
39 TextComponent tc = ((TextComponent)o); | |
40 last=tc.getText(); | |
41 Shell.print("> "+last); | |
42 Shell.interpret(new StringReader(last)); | |
43 tc.setText(""); | |
44 } | |
45 | |
46 public void keyPressed(KeyEvent e) { | |
47 if (e.getKeyCode()==KeyEvent.VK_UP) { | |
48 Object o = e.getSource(); | |
49 TextComponent tc = ((TextComponent)o); | |
50 tc.setText(last); | |
51 } | |
52 } | |
53 } | |
54 } | |
55 |