4import java.awt.event.*;
6import javax.swing.event.ChangeEvent;
7import javax.swing.event.ChangeListener;
56 if (
Sys.
env(
"AUD_TIMEOUT")!=
null) {
59 }
catch (NumberFormatException e) {}
64 this(
new JFrame(caption!=
null ? caption :
"aud.util.SingleStepper"));
73 f.addWindowListener(
new WindowAdapter() {
74 public void windowClosing(WindowEvent e) {
85 final JSpinner spinner=
new JSpinner();
88 final JPanel panel=
new JPanel(
new BorderLayout());
91 history.setFont(
new Font(
"",Font.BOLD,(
int) spinner.getValue()));
95 final JScrollPane historyPane =
new JScrollPane(
history);
96 historyPane.setPreferredSize(
new Dimension(400, 300));
98 next=
new JButton(
"continue");
100 next.addActionListener(
new ActionListener() {
101 public void actionPerformed(ActionEvent ae) {
106 spinner.addChangeListener(
new ChangeListener(){
108 public void stateChanged(ChangeEvent arg0) {
110 if ((
int) spinner.getValue()<10)
111 spinner.setValue(10);
112 if ((
int) spinner.getValue()>40)
113 spinner.setValue(40);
115 history.setFont(
new Font(
"",Font.BOLD,(
int)spinner.getValue()));
119 panel.add(
"North",spinner);
120 panel.add(
"Center", historyPane);
121 panel.add(
"South",
next);
131 }
catch (IllegalMonitorStateException e) {
132 System.err.println(
"ERROR: "+e);
146 }
catch (InterruptedException e) {
147 System.err.println(e);
148 history.append(
"--- interrupted ---\n");
149 }
catch (IllegalMonitorStateException e) {
150 System.err.println(
"ERROR: "+e);
158 System.out.println(text);
183 public void halt(String text) {
190 public static void main(String[] args) {
193 for (
int i=0;i<4;++i) {
194 System.out.println(i);
195 s.
halt(
"some message "+i);
Simple framework for single stepping code.
static void main(String[] args)
JFrame parent()
get parent widget
SingleStepper(JFrame parent)
create new instance
void setTimeout(int timeout)
Set global timeout.
SingleStepper whereAmI()
print location of calling code
void onNext()
call on button pressed
SingleStepper showSource()
jmp to caller's location in editor (emacs only)
SingleStepper(String caption)
create new instance
void halt(String text)
display text and wait for user (or global timeout)
void halt(String text, int timeout)
display text and wait for user or timeout
void println(String text)
print to both, text area and stdout
JComponent createComponents()
System related utilities.
static synchronized String env(String varname)
Get environment variable varname.
static String whereAmI(int depth)
get code location (like __FILE__,__LINE__
static void openCallersSourceInEmacs(int depth)
open emacs whereAmI (Un*x only)