-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathjconsole.html
157 lines (134 loc) · 4.52 KB
/
jconsole.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<title>Using JConsole</title>
</head>
<body bgcolor="ffffff">
<table cellspacing="10">
<tr>
<td align="center"><a href="http://www.beanshell.org/"><img src="images/homebutton.png" /><br />Home</a>
</td>
<td><a href="parser.html#The_BeanShell_Parser"><img src="images/backbutton.png" /><br />Back
</a></td>
<td align="center"><a href="contents.html"><img src="images/upbutton.png" /><br />Contents</a></td>
<td align="center"><a href="reflectivestyle.html#Reflective_Style_Access_to_Scripted_Methods"><img
src="images/forwardbutton.png" /><br />Next
</a></td>
</tr>
</table>
<h1>Using JConsole</h1>
<img src="images/colorconsole.jpg" />
<p CLEAR="ALL" />
The bsh.util.JConsole is a light weight graphical shell console window,
with simple command editing and history capabilities. BeanShell uses
the JConsole for the GUI desktop mode again in the JRemoteApplet
for the remote server mode.
<p CLEAR="ALL" />
You can use the JConsole to provide an interactive BeanShell prompt in
your own applications.
You are free to use the JConsole for your own purposes outside of BeanShell
as well! It is a fairly generic shell window easily attached to any kind of
streams or through the simple console interface.
<p CLEAR="ALL" />
JConsole is a Swing component. Embed it in your application as you would
any other swing component. For example:
<p />
<center>
<table border="1" cellpadding="5" width="100%">
<tr>
<td bgcolor="#dfdfdc">
<pre>
JConsole console = new JConsole();
myPanel.add(console);
</pre>
</td>
</tr>
</table>
</center>
<p />
You can connect an Interpreter to the console by specifying it in the
Interpreter constructor, like so:
<p />
<center>
<table border="1" cellpadding="5" width="100%">
<tr>
<td bgcolor="#dfdfdc">
<pre>
Interpreter interpreter = new Interpreter( console );
new Thread( interpreter ).start(); // start a thread to call the run() method
</pre>
</td>
</tr>
</table>
</center>
<p />
Or you can connect the JConsole to the Interpreter directly with
Interpreter setConsole().
<p CLEAR="ALL" />
For external use, JConsole can supply a PrintWriter through its getOut()
method and has a full suite of direct print() methods.
<p />
<center>
<table cellpadding="5" border="1" width="100%">
<tr>
<td><strong>Tip:</strong><br CLEAR="ALL" />
When interacting with any Swing component from outside the Java event handling
thread, use the Swing thread safety facilities: SwingUtilities.invokeNow()
and invokeLater().
</td>
</tr>
</table>
</center>
<p />
<h2><a name="ConsoleInterface">ConsoleInterface</a></h2>
JConsole implements the bsh.ConsoleInterface interface, which defines how
the Interpreter interacts with a console object. To the interpreter a console
is simply a set of I/O streams with some optimized print methods:
<table border="1" cellpadding="5">
<tr>
<td>Reader getIn();</td>
</tr>
<tr>
<td>PrintStream getOut();</td>
</tr>
<tr>
<td>PrintStream getErr();</td>
</tr>
<tr>
<td>void println( String s );</td>
</tr>
<tr>
<td>void print( String s );</td>
</tr>
<tr>
<td>void error( String s );</td>
</tr>
</table>
Any object that implements this interface can be attached to the Interpreter
as a GUI console.
<p CLEAR="ALL" />
The bsh.util.GUIConsoleInterface extends the ConsoleInterface and adds
methods for printing a string with a color attribute, supplying wait
feedback (the wait cursor) and name completion support. JConsole implements
this interface and it is used indirectly via BeanShell commands when it
is detected.
<p CLEAR="ALL" />
<h3>AWTConsole</h3>
The bsh.util.AWTConsole is a legacy implementation of the GUI Console using
AWT instead of Swing. This console does work, but it is not as slick or
pretty as the JConsole. The primary reason it is still here is to support
remote access from generic web browsers using only Java 1.1.
<table cellspacing="10">
<tr>
<td align="center"><a href="http://www.beanshell.org/"><img src="images/homebutton.png" /><br />Home</a>
</td>
<td><a href="parser.html#The_BeanShell_Parser"><img src="images/backbutton.png" /><br />Back
</a></td>
<td align="center"><a href="contents.html"><img src="images/upbutton.png" /><br />Contents</a></td>
<td align="center"><a href="reflectivestyle.html#Reflective_Style_Access_to_Scripted_Methods"><img
src="images/forwardbutton.png" /><br />Next
</a></td>
</tr>
</table>
</body>
</html>