Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- import java.io.*;
- public class AlexanderWU3A1Q1 {
- public static void main(String[] args) { // main method
- JFrame frame = new JFrame(); // makes new frame object
- frame.setTitle("Drawing Tool"); // sets title
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // closes application when exit button clicked
- frame.setPreferredSize(new Dimension(840, 840)); // sets dimensions for frame
- frame.setResizable(false); // not resizable
- JPanel panel = new JPanel();
- frame.pack();
- frame.setVisible(true); // sets frame visible
- ArrayList<ArrayList<String> > array = new ArrayList<>();
- try (Scanner scanner = new Scanner(new File("eng-climate-summaries-All-4,2018.csv"));) {
- while (scanner.hasNext()) {
- array.add(parseThings(scanner.nextLine()));
- }
- } catch (Exception FileNotFoundException) {
- }
- ArrayList<String> stationNames = new ArrayList<>();
- Vector<String> stationNamesArray = new Vector<>(stationNames);
- for (int i = 32; i < 1114; i++) {
- String e = array.get(i).get(0);
- stationNames.add(e);
- }
- JComboBox chooseLocation = new JComboBox(stationNamesArray);
- chooseLocation.setEditable(false);
- panel.add(chooseLocation);
- frame.add(panel); // add JPanel to frame
- }
- private static ArrayList<String> parseThings(String Line) {
- ArrayList<String> lines = new ArrayList<>();
- try (Scanner scanRows = new Scanner(Line)) {
- scanRows.useDelimiter(",");
- while (scanRows.hasNext()) {
- String temp = scanRows.next();
- try {
- temp = temp.substring(1, temp.length() - 1);
- lines.add(temp);
- } catch (Exception e) {}
- }
- }
- return lines;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement