List of usage examples for javax.swing JTable setValueAt
public void setValueAt(Object aValue, int row, int column)
row
and column
. From source file:Main.java
public static void main(String[] argv) throws Exception { int rows = 3; int cols = 3; JTable table = new JTable(rows, cols); table.setValueAt("New Value", 0, 0); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> rowOne = new Vector<String>(); rowOne.addElement("Row1-Column1"); rowOne.addElement("Row1-Column2"); rowOne.addElement("Row1-Column3"); Vector<String> rowTwo = new Vector<String>(); rowTwo.addElement("Row2-Column1"); rowTwo.addElement("Row2-Column2"); rowTwo.addElement("Row2-Column3"); Vector<Vector> rowData = new Vector<Vector>(); rowData.addElement(rowOne);/* w w w .jav a2 s . co m*/ rowData.addElement(rowTwo); Vector<String> columnNames = new Vector<String>(); columnNames.addElement("Column One"); columnNames.addElement("Column Two"); columnNames.addElement("Column Three"); JTable table = new JTable(rowData, columnNames); table.setValueAt("aa", 0, 0); JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:TableModelListenerDemo.java
public static void main(String args[]) { final Object rowData[][] = { { "1", "one", "I" }, { "2", "two", "II" }, { "3", "three", "III" } }; final String columnNames[] = { "#", "English", "Roman" }; final JTable table = new JTable(rowData, columnNames); JScrollPane scrollPane = new JScrollPane(table); table.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { System.out.println(e); }/*from w w w. j a v a 2 s . com*/ }); table.setValueAt("", 0, 0); JFrame frame = new JFrame("Resizing Table"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:OAT.ui.util.UiUtil.java
public static void updateTable(Object value, int rowId, int columnId, JTable table) { if (rowId > -1 && rowId < table.getRowCount() && columnId > -1 && columnId < table.getColumnCount()) { table.setValueAt(value, rowId, columnId); }// w w w .jav a 2 s.c om }
From source file:simulation.AureoZauleckAnsLab2.java
public static void DisplayTable(ArrayList<ArrayList> all, ArrayList percentages, String title) { JFrame frame = new JFrame(); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(); table.setModel(new DefaultTableModel((int) (all.size() + 2), 2)); table.setValueAt("VALUE LABELS", 0, 0); table.setValueAt("PERCENTAGE", 0, 1); table.setValueAt("TOTAL = 100%", (int) (all.size() + 1), 1); for (int i = 0; i < all.size(); i++) { table.setValueAt(all.get(i).get(0), i + 1, 0); table.setValueAt(new DecimalFormat("#.##").format(percentages.get(i)), i + 1, 1); }//from ww w. j a va 2 s . c o m JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBorder(BorderFactory.createTitledBorder(title)); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:simulation.AureoZauleckAnsLab2.java
public static void DisplayTables(double k, ArrayList<Double> cl, ArrayList<Double> cl2, ArrayList<Double> tlcl, ArrayList<Double> tucl, ArrayList<Double> midList, ArrayList<ArrayList<Double>> freq, ArrayList<Double> freqPercent, ArrayList<Double> cfs, ArrayList<Double> cps, String title) { JFrame frame = new JFrame(); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(); table.setModel(new DefaultTableModel((int) (k + 2), 7)); table.setValueAt("CLASS LIMITS", 0, 0); table.setValueAt("TRUE CLASS LIMITS", 0, 1); table.setValueAt("MIDPOINTS", 0, 2); table.setValueAt("FREQUENCY", 0, 3); table.setValueAt("%", 0, 4); table.setValueAt("CF", 0, 5); table.setValueAt("C%", 0, 6); table.setValueAt("n = " + N, (int) (k + 1), 3); table.setValueAt("TOTAL = 100%", (int) (k + 1), 4); for (int i = 0; i < k; i++) { table.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table.setValueAt(midList.get(i), i + 1, 2); table.setValueAt(freq.get(i).size(), i + 1, 3); table.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table.setValueAt(cfs.get(i), i + 1, 5); table.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); }//from ww w.j ava2s .co m JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBorder(BorderFactory.createTitledBorder(title)); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); Scanner sc = new Scanner(System.in); int type = 0, testT = 0; String typeTest = ""; do { System.out.println(); System.out.println("COLLAPSE CLASS LIMITS?"); System.out.println("[1] COLLAPSE LOWER CLASS LIMIT"); System.out.println("[2] COLLAPSE UPPPER CLASS LIMIT"); System.out.println("[3] COLLAPSE BOTH"); System.out.println("[4] DON'T COLLAPSE"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest = sc.next(); if (IsNumber(typeTest)) { testT = Convert(typeTest); } else { do { System.out.println("Please enter a number only."); typeTest = sc.next(); } while (!IsNumber(typeTest)); testT = Convert(typeTest); } type = testT; } while (type < 1 || type > 4); if (type == 1) { JFrame frame2 = new JFrame(); //frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table2 = new JTable(); table2.setModel(new DefaultTableModel((int) (k + 2), 7)); table2.setValueAt("CLASS LIMITS", 0, 0); table2.setValueAt("TRUE CLASS LIMITS", 0, 1); table2.setValueAt("MIDPOINTS", 0, 2); table2.setValueAt("FREQUENCY", 0, 3); table2.setValueAt("%", 0, 4); table2.setValueAt("CF", 0, 5); table2.setValueAt("C%", 0, 6); table2.setValueAt("n = " + N, (int) (k + 1), 3); table2.setValueAt("TOTAL = 100%", (int) (k + 1), 4); for (int i = 0; i < k; i++) { table2.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table2.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table2.setValueAt(midList.get(i), i + 1, 2); table2.setValueAt(freq.get(i).size(), i + 1, 3); table2.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table2.setValueAt(cfs.get(i), i + 1, 5); table2.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); } table2.setValueAt("below " + cl2.get(0), 1, 0); table2.setValueAt(" - ", 1, 1); table2.setValueAt(" - ", 1, 2); JScrollPane scrollPane2 = new JScrollPane(table2); scrollPane2.setBorder(BorderFactory.createTitledBorder(title)); frame2.add(scrollPane2, BorderLayout.CENTER); frame2.setSize(300, 150); frame2.setVisible(true); } else if (type == 2) { JFrame frame3 = new JFrame(); //frame3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table3 = new JTable(); table3.setModel(new DefaultTableModel((int) (k + 2), 7)); table3.setValueAt("CLASS LIMITS", 0, 0); table3.setValueAt("TRUE CLASS LIMITS", 0, 1); table3.setValueAt("MIDPOINTS", 0, 2); table3.setValueAt("FREQUENCY", 0, 3); table3.setValueAt("%", 0, 4); table3.setValueAt("CF", 0, 5); table3.setValueAt("C%", 0, 6); table3.setValueAt("n = " + N, (int) (k + 1), 3); table3.setValueAt("TOTAL = 100%", (int) (k + 1), 4); int a = (int) k; for (int i = 0; i < k; i++) { table3.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table3.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table3.setValueAt(midList.get(i), i + 1, 2); table3.setValueAt(freq.get(i).size(), i + 1, 3); table3.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table3.setValueAt(cfs.get(i), i + 1, 5); table3.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); } table3.setValueAt(cl.get(a - 1) + " above", a, 0); table3.setValueAt(" - ", a, 1); table3.setValueAt(" - ", a, 2); JScrollPane scrollPane3 = new JScrollPane(table3); scrollPane3.setBorder(BorderFactory.createTitledBorder(title)); frame3.add(scrollPane3, BorderLayout.CENTER); frame3.setSize(300, 150); frame3.setVisible(true); } else if (type == 3) { JFrame frame4 = new JFrame(); //frame4.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table4 = new JTable(); table4.setModel(new DefaultTableModel((int) (k + 2), 7)); table4.setValueAt("CLASS LIMITS", 0, 0); table4.setValueAt("TRUE CLASS LIMITS", 0, 1); table4.setValueAt("MIDPOINTS", 0, 2); table4.setValueAt("FREQUENCY", 0, 3); table4.setValueAt("%", 0, 4); table4.setValueAt("CF", 0, 5); table4.setValueAt("C%", 0, 6); table4.setValueAt("n = " + N, (int) (k + 1), 3); table4.setValueAt("TOTAL = 100%", (int) (k + 1), 4); int a = (int) k; for (int i = 0; i < k; i++) { table4.setValueAt(cl.get(i) + " - " + cl2.get(i), i + 1, 0); table4.setValueAt(tlcl.get(i) + " - " + tucl.get(i), i + 1, 1); table4.setValueAt(midList.get(i), i + 1, 2); table4.setValueAt(freq.get(i).size(), i + 1, 3); table4.setValueAt(new DecimalFormat("#.##").format(freqPercent.get(i)), i + 1, 4); table4.setValueAt(cfs.get(i), i + 1, 5); table4.setValueAt(new DecimalFormat("#.##").format(cps.get(i)), i + 1, 6); } table4.setValueAt("below " + cl2.get(0), 1, 0); table4.setValueAt(cl.get(a - 1) + " above", a, 0); table4.setValueAt(" - ", 1, 1); table4.setValueAt(" - ", 1, 2); table4.setValueAt(" - ", a, 1); table4.setValueAt(" - ", a, 2); JScrollPane scrollPane4 = new JScrollPane(table4); scrollPane4.setBorder(BorderFactory.createTitledBorder(title)); frame4.add(scrollPane4, BorderLayout.CENTER); frame4.setSize(300, 150); frame4.setVisible(true); } else { } }
From source file:medsavant.enrichment.app.RegionListAggregatePanel.java
private void resetCounts() { variantCounts.clear();/*from www . j a v a 2 s .co m*/ patientCounts.clear(); for (GenomicRegion r : currentRegions) { variantCounts.put(r, null); patientCounts.put(r, null); } JTable t = tablePanel.getTable(); for (int i = 0; i < t.getRowCount(); i++) { t.setValueAt("", i, VARIANT_COLUMN); t.setValueAt("", i, VARIANTPERKB_COLUMN); t.setValueAt("", i, PATIENT_COLUMN); } }
From source file:simulation.AureoZauleckAnsLab2.java
/** * *///from w ww. ja v a2s . co m public AureoZauleckAnsLab2() { // TODO code application logic here Scanner sc = new Scanner(System.in); String choice_s = ""; int choice = 0; do { DisplayMenu(); choice_s = sc.next(); String title = ""; Scanner s = new Scanner(System.in); //test input if (IsNumber(choice_s)) { choice = Convert(choice_s); } else { do { System.out.println("Please enter a number only."); choice_s = sc.next(); } while (!IsNumber(choice_s)); choice = Convert(choice_s); } if (choice == 1) { System.out.println("*** CATEGORICAL ***"); System.out.println(); System.out.println("TITLE(title of data set)"); //sc = new Scanner(System.in); title = s.nextLine(); System.out.println("this is the title: " + title); ArrayList a = new ArrayList<>(); ArrayList<Double> percentages = new ArrayList<>(); ArrayList<ArrayList> all; a = GetData(); Collections.sort(a); all = Stratified(a); System.out.println("GROUPED DATA: " + all); System.out.println("size " + all.size()); double percent = 0.0, sum = 0.0; for (int i = 0; i < all.size(); i++) { ArrayList inner = new ArrayList<>(); inner = all.get(i); //System.out.println(inner); int inner_n = inner.size(); percent = GetPercentage(N, inner_n); percentages.add(percent); sum += percent; System.out.println("" + inner.get(0) + "\t" + " " + percent); } System.out.println("\t" + "total " + Math.ceil(sum)); System.out.println("all = " + all); JFrame frame = new JFrame(); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(); table.setModel(new DefaultTableModel((int) (all.size() + 2), 2)); table.setValueAt("VALUE LABELS", 0, 0); table.setValueAt("PERCENTAGE", 0, 1); table.setValueAt("TOTAL = 100%", (int) (all.size() + 1), 1); for (int i = 0; i < all.size(); i++) { table.setValueAt(all.get(i).get(0), i + 1, 0); table.setValueAt(new DecimalFormat("#.##").format(percentages.get(i)), i + 1, 1); } JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBorder(BorderFactory.createTitledBorder(title)); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); int type = 0, testT = 0; String typeTest = ""; do { System.out.println("GENERATE GRAPH?"); System.out.println("[1] YES"); System.out.println("[2] NO"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest = sc.next(); if (IsNumber(typeTest)) { testT = Convert(typeTest); } else { do { System.out.println("Please enter a number only."); typeTest = sc.next(); } while (!IsNumber(typeTest)); testT = Convert(typeTest); } type = testT; } while (type < 1 || type > 2); if (type == 1) { DefaultPieDataset dataset = new DefaultPieDataset(); for (int i = 0; i < all.size(); i++) { dataset.setValue( all.get(i).get(0).toString() + " = " + new DecimalFormat("#.##").format(percentages.get(i)) + "%", percentages.get(i)); } JFreeChart chart = ChartFactory.createPieChart(title, // chart title dataset, // data true, // include legend true, false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); JFrame l = new JFrame(); l.setContentPane(chartPanel); l.setSize(400, 400); l.setVisible(true); } else { //do nothing? } int type2 = 0, testT2 = 0; String typeTest2 = ""; do { System.out.println("REDISPLAY TABLE?"); System.out.println("[1] YES"); System.out.println("[2] NO"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest2 = sc.next(); if (IsNumber(typeTest2)) { testT2 = Convert(typeTest2); } else { do { System.out.println("Please enter a number only."); typeTest2 = sc.next(); } while (!IsNumber(typeTest2)); testT2 = Convert(typeTest2); } type2 = testT2; } while (type2 < 1 || type2 > 2); if (type2 == 1) { DisplayTable(all, percentages, title); } else { //do nothing? } } else if (choice == 2) { System.out.println("*** NUMERICAL ***"); System.out.println(); System.out.println("TITLE(title of data set)"); title = s.nextLine(); System.out.println("this is the title " + title); ArrayList<Double> a = new ArrayList<>(); //ArrayList<ArrayList> all; //a = GetData2(); double[] arr = { 70, 36, 43, 69, 82, 48, 34, 62, 35, 15, 59, 139, 46, 37, 42, 30, 55, 56, 36, 82, 38, 89, 54, 25, 35, 24, 22, 9, 55, 19 }; /* double[] arr = {112, 100, 127,120,134,118,105,110,109,112, 110, 118, 117, 116, 118, 122, 114, 114, 105, 109, 107, 112, 114, 115, 118, 117, 118, 122, 106, 110, 116, 108, 110, 121, 113, 120, 119, 111, 104, 111, 120, 113, 120, 117, 105, 110, 118, 112, 114, 114}; */ N = arr.length; double t = 0.0; for (int i = 0; i < N; i++) { a.add(arr[i]); } Collections.sort(a); System.out.println("sorted a " + a); double min = (double) a.get(0); double max = (double) a.get(N - 1); System.out.println("Min" + min); System.out.println("Max" + max); double k = Math.ceil(1 + 3.322 * Math.log10(N)); System.out.println("K " + k); double range = GetRange(min, max); System.out.println("Range " + range); double width = Math.ceil(range / k); //todo, i ceiling sa 1st decimal point System.out.println("Width " + width); ArrayList<Double> cl = new ArrayList<>(); cl.add(min); double rest; for (int i = 1; i < k; i++) { cl.add(min += width); } ArrayList<Double> cl2 = new ArrayList<>(); double cl2min = cl.get(1) - 1; cl2.add(cl2min); for (int i = 1; i < k; i++) { cl2.add(cl2min += width); } System.out.println("cl 1 " + cl); System.out.println("cl 2 " + cl2); ArrayList<Double> tlcl = new ArrayList<>(); double tlclmin = cl.get(0) - Multiplier(cl.get(0)); tlcl.add(tlclmin); for (int i = 1; i < k; i++) { tlcl.add(tlclmin += width); } ArrayList<Double> tucl = new ArrayList<>(); double tuclmin = cl2.get(0) + Multiplier(cl2.get(0)); tucl.add(tuclmin); for (int i = 1; i < k; i++) { tucl.add(tuclmin += width); } System.out.println("tlcl 1 " + tlcl); System.out.println("tucl 2 " + tucl); System.out.println("N " + N); ArrayList<Double> midList = new ArrayList<>(); double mid = (cl.get(0) + cl2.get(0)) / 2; midList.add(mid); for (int i = 1; i < k; i++) { midList.add((tlcl.get(i) + tucl.get(i)) / 2); } for (int i = 0; i < k; i++) { System.out.println((tlcl.get(i) + tucl.get(i)) / 2); } System.out.println("mid" + midList); ArrayList<ArrayList<Double>> freq = new ArrayList<>(); double ctr = 0.0; for (int j = 0; j < k; j++) { for (int i = 0; i < N; i++) { if ((a.get(i) >= tlcl.get(j)) && (a.get(i) <= tucl.get(j))) { freq.add(new ArrayList<Double>()); freq.get(j).add(a.get(i)); } } } ArrayList<Double> freqSize = new ArrayList<>(); double size = 0.0; for (int i = 0; i < k; i++) { size = (double) freq.get(i).size(); freqSize.add(size); } ArrayList<Double> freqPercent = new ArrayList<>(); for (int i = 0; i < k; i++) { freqPercent.add(freqSize.get(i) / N * 100); } ArrayList<Double> cfs = new ArrayList<>(); double cf = freqSize.get(0); cfs.add(cf); for (int i = 1; i < k; i++) { cf = freqSize.get(i) + cfs.get(i - 1); cfs.add(cf); } double sum = 0.0; for (int i = 1; i < cfs.size(); i++) { sum += cfs.get(i); } ArrayList<Double> cps = new ArrayList<>(); double cp = 0.0; for (int i = 0; i < k; i++) { cp = (cfs.get(i) / N) * 100; cps.add(cp); } System.out.println("T o t a l: " + sum); System.out.println(cfs); System.out.println(cps); System.out.println("frequency list " + freq); System.out.println("frequency sizes " + freqSize); System.out.println("frequency percentages " + freqPercent); System.out.println(); System.out.println(title); System.out.println("CLASS LIMITS" + "\t" + "T CLASS LIMITS" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println(cl.get(i) + " - " + cl2.get(i) + "\t" + tlcl.get(i) + " - " + tucl.get(i) + "\t" + midList.get(i) + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } //2 System.out.println("CLASS LIMITS" + "\t" + "T C L" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println(">=" + cl.get(i) + "\t\t" + " - " + "\t" + " - " + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } //3 System.out.println("CLASS LIMITS" + "\t" + "T C L" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println("<=" + cl2.get(i) + "\t\t" + " - " + "\t" + " - " + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } System.out.println("CLASS LIMITS" + "\t" + "T CLASS LIMITS" + "\t" + "MID" + "\t" + "FREQ" + "\t" + "PERCENT" + "\t" + "CF" + "\t" + "CP"); for (int i = 0; i < k; i++) { System.out.println(">=" + cl.get(i) + " and <=" + cl2.get(i) + "\t" + " - " + "\t" + " - " + "\t" + freq.get(i).size() + "\t" + new DecimalFormat("#.##").format(freqPercent.get(i)) + "\t" + cfs.get(i) + "\t" + new DecimalFormat("#.##").format(cps.get(i))); } DisplayTables(k, cl, cl2, tlcl, tucl, midList, freq, freqPercent, cfs, cps, title); int type = 0, testT = 0; String typeTest = ""; do { do { System.out.println(); System.out.println("GENERATE GRAPH?"); System.out.println("[1] YES"); System.out.println("[2] NO"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest = sc.next(); if (IsNumber(typeTest)) { testT = Convert(typeTest); } else { do { System.out.println("Please enter a number only."); typeTest = sc.next(); } while (!IsNumber(typeTest)); testT = Convert(typeTest); } type = testT; } while (type < 1 || type > 2); if (type == 1) { int bins = (int) k; System.out.println(); System.out.println("You may input a label for your X axis:"); String x = ""; x = s.nextLine(); createHistogram(a, bins, title, x); int type2 = 0, testT2 = 0; String typeTest2 = ""; do { System.out.println(); System.out.println("REDISPLAY TABLE?"); System.out.println("[1] YES"); System.out.println("[2] NO"); System.out.println(); System.out.println("Please pick a number from the choices above."); typeTest2 = sc.next(); if (IsNumber(typeTest2)) { testT2 = Convert(typeTest2); } else { do { System.out.println("Please enter a number only."); typeTest2 = sc.next(); } while (!IsNumber(typeTest2)); testT2 = Convert(typeTest2); } type2 = testT2; } while ((type2 < 1 || type2 > 2) && type != 2); if (type2 == 1) { DisplayTables(k, cl, cl2, tlcl, tucl, midList, freq, freqPercent, cfs, cps, title); } else { //do nothing? } } } while (type != 2); } else if (choice == 3) { System.out.println("*** QUIT ***"); } } while (choice != 3); System.out.println("Thank you for your time."); s = new Simulation(); }
From source file:org.jas.gui.MainWindow.java
@EventMethod(Events.LOAD_METADATA) void onLoadMetadata(List<Metadata> metadatas) { JTable descriptionTable = getDescriptionTable(); DefaultTableModel model = (DefaultTableModel) descriptionTable.getModel(); for (Metadata metadata : metadatas) { int row = descriptionTable.getRowCount(); model.addRow(new Object[] { "", "", "", "", "", "", "", "" }); descriptionTable.setValueAt(metadata.getArtist(), row, ApplicationState.ARTIST_COLUMN); descriptionTable.setValueAt(metadata.getTitle(), row, ApplicationState.TITLE_COLUMN); descriptionTable.setValueAt(metadata.getAlbum(), row, ApplicationState.ALBUM_COLUMN); descriptionTable.setValueAt(metadata.getGenre(), row, ApplicationState.GENRE_COLUMN); descriptionTable.setValueAt(metadata.getYear(), row, ApplicationState.YEAR_COLUMN); descriptionTable.setValueAt(metadata.getTrackNumber(), row, ApplicationState.TRACK_NUMBER_COLUMN); descriptionTable.setValueAt(metadata.getTotalTracks(), row, ApplicationState.TOTAL_TRACKS_NUMBER_COLUMN); descriptionTable.setValueAt(metadata.getCdNumber(), row, ApplicationState.CD_NUMBER_COLUMN); descriptionTable.setValueAt(metadata.getTotalCds(), row, ApplicationState.TOTAL_CDS_NUMBER_COLUMN); if (metadata.isMetadataFromFile()) { descriptionTable.setValueAt(ApplicationState.NEW, row, ApplicationState.STATUS_COLUMN); metadataWithAlbum.add(metadata); getApplyButton().setEnabled(true); } else {/*from w ww .java 2s . c o m*/ descriptionTable.setValueAt(ApplicationState.READY, row, ApplicationState.STATUS_COLUMN); } } }
From source file:com.vgi.mafscaling.OpenLoop.java
public void loadData() { fileChooser.setMultiSelectionEnabled(false); if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this)) return;//from ww w. j ava 2 s . c om File file = fileChooser.getSelectedFile(); int i, j, k, l; setCursor(new Cursor(Cursor.WAIT_CURSOR)); BufferedReader br = null; try { br = new BufferedReader(new FileReader(file.getAbsoluteFile())); String line = br.readLine(); if (line == null || !line.equals(SaveDataFileHeader)) { JOptionPane.showMessageDialog(null, "Invalid saved data file!", "Error", JOptionPane.ERROR_MESSAGE); return; } line = br.readLine(); String[] elements; JTable table = null; i = k = l = 0; while (line != null) { elements = line.split(",", -1); switch (i) { case 0: Utils.ensureColumnCount(elements.length - 1, mafTable); for (j = 0; j < elements.length - 1; ++j) mafTable.setValueAt(elements[j], i, j); break; case 1: Utils.ensureColumnCount(elements.length - 1, mafTable); for (j = 0; j < elements.length - 1; ++j) mafTable.setValueAt(elements[j], i, j); break; default: int offset = runTables.length * 3 + mafTable.getRowCount(); if (i > 1 && i < offset) { if (l == 0) table = runTables[k++]; Utils.ensureRowCount(elements.length - 1, table); for (j = 0; j < elements.length - 1; ++j) table.setValueAt(elements[j], j, l); l += 1; if (l == 3) l = 0; } } i += 1; line = br.readLine(); } } catch (Exception e) { e.printStackTrace(); logger.error(e); } finally { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if (br != null) { try { br.close(); } catch (IOException e) { logger.error(e); } } } }