import java.awt.*; // references to Java packages we use import java.applet.Applet; import BarChart; // references to our classes import NumericSet; // // the ruling class // public class ChartTool extends Applet { // member data NumericSet _set; BarChart _barChart; TextField _textField; GraphItButton _button; final static int _width=200, _height=225; // only works in appletviewer public void init(){ _set=new NumericSet(); // initialize member data resize(_width, _height); // size the app window setLayout(new BorderLayout()); // create a layout mgr _textField=new TextField(); // input fld _textField.setText("12 24 15 76 54 15");// sample data for starters add("North", _textField); _barChart=new BarChart(_set, _width, 150); add("Center", _barChart); _button=new GraphItButton(this, "Graph It"); add("South", _button); graphIt(); // show sample data } // called to update graph public void graphIt(){ String s=_textField.getText(); // get user input _set.setFromString(s); // reinitialize NumericSet obj _barChart.numericSet(_set); // update the BarChart's NumericSet } } // end class ChartTool // // button to perform graphing // class GraphItButton extends Button { ChartTool _app; // constructor public GraphItButton(ChartTool app_, String label_){ setLabel(label_); _app=app_; } // this member function is called when the button is pressed public boolean action(Event e_, Object arg_){ _app.graphIt(); return true; } } // end class GraphItButton