import java.awt.*; import java.awt.event.*; public class Analyst extends Frame implements ActionListener { Storage store = new Storage(); IO io = new IO(); Canvas canvas = new Canvas(); public Analyst () { setSize(600,600); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); MenuBar menuBar = new MenuBar(); Menu fileMenu = new Menu("File"); menuBar.add(fileMenu); MenuItem openMenuItem = new MenuItem("Open..."); fileMenu.add(openMenuItem); setMenuBar(menuBar); openMenuItem.addActionListener(this); add(canvas); setVisible(true); } public void actionPerformed(ActionEvent e) { MenuItem clickedMenuItem = (MenuItem)e.getSource(); if (clickedMenuItem.getLabel().equals("Open...")) { store.setData(io.readData()); } repaint(); } public void paint (Graphics gc) { double[][] data = store.getData(); Graphics g = canvas.getGraphics(); if (data != null) { for (int i = 0; i < data.length - 2; i++) { g.drawLine((int)data[i][0], (int)data[i][1], (int)data[i+1][0], (int)data[i+1][1]); } } g.finalize(); } public static void main (String args[]) { new Analyst(); } }