コード例 #1
0
  // adds the action listeners for our menu items
  public void control() {

    aLUpload =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            updateSoccerData();
            SoccerView.setPicture();
          }
        };
    view.getMenuItemUpload().addActionListener(aLUpload);

    aLExit =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            System.exit(0);
          }
        };
    view.getMenuItemExit().addActionListener(aLExit);

    aLVersion =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            view.createVersionPane();
          }
        };
    view.getMenuItemVersion().addActionListener(aLVersion);
  }
コード例 #2
0
  public static void createData(File f) {

    List<LatLonData> point = new ArrayList<>();
    LatLonData tempObj;

    try {
      // ***To be replaced with "selectedFile" - now reading too early
      BufferedReader br = new BufferedReader(new FileReader(f));

      String fileRead = br.readLine();

      while (fileRead != null) {

        // split file by commas
        String[] token = fileRead.split(",");

        double tempLat = Double.parseDouble(token[0]);
        double tempLon = Double.parseDouble(token[1]);
        double tempSpeed = Double.parseDouble(token[2]);

        tempObj = new LatLonData(tempLat, tempLon, tempSpeed);
        point.add(tempObj);

        fileRead = br.readLine();
      }
      // close file
      br.close();
    } catch (FileNotFoundException fnfe) {
      System.out.println("File not found");
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
    // put points in text area on main frame
    SoccerView.printGPSToPanel(point);
  }