public void testYourselfProgress() { // Goes through the list from the last unmemorized word in the word list, testing a character on // characters, // pinyin and definition. if (choice == correct) { JOptionPane.showMessageDialog(null, "Correct!"); if (current < wordIndex) { // Error check to see whether the quiz has reached the final word. // Goes through each word, testing the pinyin, character and the definition. if (progress % 3 == 0) { pinyinLoad(); progress++; } else if (progress % 3 == 1) { characterLoad(); progress++; } else if (progress % 3 == 2) { definitionLoad(); progress++; // User has memorized the word words[current].setMemorized(true); current++; // Increments up to test the user on the new word. } } else { // If the test has gone on to the final word, closes the form and goes back to the main // form. saveWords(); MainWindow start = new MainWindow(); start.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); start.setVisible(true); this.dispose(); } } else { JOptionPane.showMessageDialog(null, "Sorry, you got it wrong."); } }
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed // Closes this window and restarts the main window. MainWindow start = new MainWindow(); start.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); start.setVisible(true); saveWords(); this.dispose(); } // GEN-LAST:event_jButton1ActionPerformed
/** @param args the command line arguments */ public void memorizeListProgress() { // Tests users on a character based on either characters, definition or pinyin. current++; if (choice == correct) { JOptionPane.showMessageDialog(null, "Correct!"); if (current < wordIndex) { // Error check to see whether the quiz has reached the final word. loadLists(); // Random process, tests based on characters definition or pinyin. } else { MainWindow start = new MainWindow(); start.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); start.setVisible(true); this.dispose(); } } else { JOptionPane.showMessageDialog(null, "Sorry, you got it wrong."); } }
public static void main(String[] args) { if (args.length != 1) { System.out.println("Usage: java Msp <filename>"); System.exit(2); } Graph g = new Graph(); loadFile(g, args[0]); // Calculate locations of nodes g.prepareNodes(); // Perform kruskal algorithm g.kruskal(); // Show results in JFrame MainWindow f = new MainWindow(g); f.setSize(800, 600); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
/** Adds the listeners for the window allowing to change the map's properties */ public void addMapPropertiesWindowListeners() { // Called when clicking on the "apply" button win.getMapPropertiesWindow() .getApplyButton() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { win.getEditorPan() .getLayer1() .setMapDim( win.getMapPropertiesWindow().getMapWidth(), win.getMapPropertiesWindow().getMapHeight()); win.getEditorPan() .getLayer2() .setMapDim( win.getMapPropertiesWindow().getMapWidth(), win.getMapPropertiesWindow().getMapHeight()); win.getEditorPan() .getItemsLayer() .setMapDim( win.getMapPropertiesWindow().getMapWidth(), win.getMapPropertiesWindow().getMapHeight()); win.getEditorPan() .getStartFinishLayer() .setMapDim( win.getMapPropertiesWindow().getMapWidth(), win.getMapPropertiesWindow().getMapHeight()); } }); // Called when clicking on the "close" button win.getMapPropertiesWindow() .getCloseButton() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { win.getMapPropertiesWindow().dispose(); win.setMapPropertiesWindow(null); } }); }
/** Adds the listeners for the "how to" window */ public void addHowToWindowListeners() { // Called when clicking on the "close" button win.getHowToWindow() .getCloseButton() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { win.getHowToWindow().dispose(); win.setHowToWindow(null); } }); }
public static ScoreMenu[] loadFile() { MainWindow.initDataFile(SCORE_MENU_FILE); DataInputStream input; Course course; Class tempClass; Student student; int[] testTime; long[] id; float[] score; ScoreMenu[] scoreMenu = new ScoreMenu[20]; int count = 0; try { input = new DataInputStream(new FileInputStream(SCORE_MENU_FILE)); while (input.available() > 0) { if (count >= scoreMenu.length) { ScoreMenu[] temp = new ScoreMenu[scoreMenu.length * 2]; for (int i = 0; i < scoreMenu.length; i++) temp[i] = scoreMenu[i]; scoreMenu = temp; } tempClass = new Class(); tempClass.setGrade(input.readInt()); tempClass.setMajor(input.readUTF()); tempClass.setClassNumber(input.readInt()); tempClass.setStudentNumber(0); int num = input.readInt(); for (int i = 0; i < num; i++) { student = new Student(); student.setId(input.readLong()); student.setName(input.readUTF()); tempClass.addStudent(student); } course = new Course(); course.setId(input.readUTF()); course.setName(input.readUTF()); course.setCredit(input.readFloat()); course.setPeriod(input.readInt()); testTime = new int[5]; for (int i = 0; i < 5; i++) testTime[i] = input.readInt(); num = input.readInt(); id = new long[num]; score = new float[num]; for (int i = 0; i < num; i++) id[i] = input.readLong(); for (int i = 0; i < num; i++) score[i] = input.readFloat(); scoreMenu[count] = new ScoreMenu(tempClass, course, testTime, num, id, score); count++; } input.close(); return scoreMenu; } catch (Exception e) { return null; } }
public void handle(String msg) { System.out.println("Idem handleat ovaj msg: " + msg); if (msg.equals("REGISTEROK")) { /* otvori onaj dialog koji kaze successful registration */ SuccessRegister dialog = new SuccessRegister(); dialog.setVisible(true); if (reg != null) reg.dispose(); } else if (msg.equals("OKADMIN")) { AdminWindow window = new AdminWindow(socket, UsernameLogin.getText()); loginThread.setStopper(true); /* kada je uspjesan login, zaustavi loginThread koji slusa odgovor od servera (ali socket ostaje otvoren!) */ dispose(); // rjesi se ovog prozora window.setVisible(true); } else if (msg.equals("OK")) { MainWindow window = new MainWindow(socket, UsernameLogin.getText()); loginThread.setStopper(true); /* kada je uspjesan login, zaustavi loginThread koji slusa odgovor od servera (ali socket ostaje otvoren!) */ dispose(); // rjesi se ovog prozora window.setVisible(true); } else if (msg.equals("REGISTERFAIL")) { try { /* provjera za slucaj lose definiranog puta za sliku */ WarningRegister warnReg = new WarningRegister(new javax.swing.JFrame(), true); warnReg.setVisible(true); } catch (Exception e) { } } else { try { /* provjera za slucaj lose definiranog puta za sliku */ WarningLogin warnLog = new WarningLogin(new javax.swing.JFrame(), true); warnLog.setVisible(true); } catch (Exception e) { } } }
public static ScoreMenu queryFromFile(Class classes, Course courses) { MainWindow.initDataFile(SCORE_MENU_FILE); DataInputStream input; Class tempClass = new Class(); Student student; Course course = new Course(); int[] testTime = new int[5]; int numberOfAttendTestStudent; long idOfStudents[]; float scoreOfTest[]; try { input = new DataInputStream(new FileInputStream(SCORE_MENU_FILE)); while (input.available() > 0) { tempClass.setGrade(input.readInt()); tempClass.setMajor(input.readUTF()); tempClass.setClassNumber(input.readInt()); int studentNumber = input.readInt(); tempClass.setStudentNumber(0); for (int i = 0; i < studentNumber; i++) { student = new Student(); student.setId(input.readLong()); student.setName(input.readUTF()); tempClass.addStudent(student); } course.setId(input.readUTF()); course.setName(input.readUTF()); course.setCredit(input.readFloat()); course.setPeriod(input.readInt()); for (int i = 0; i < 5; i++) testTime[i] = input.readInt(); numberOfAttendTestStudent = input.readInt(); idOfStudents = new long[numberOfAttendTestStudent]; scoreOfTest = new float[numberOfAttendTestStudent]; for (int i = 0; i < numberOfAttendTestStudent; i++) idOfStudents[i] = input.readLong(); for (int i = 0; i < numberOfAttendTestStudent; i++) scoreOfTest[i] = input.readFloat(); if ((classes.equals(tempClass)) && (courses.equals(course))) { input.close(); return new ScoreMenu( tempClass, course, testTime, numberOfAttendTestStudent, idOfStudents, scoreOfTest); } } input.close(); return null; } catch (Exception e) { return null; } }
ControlBar(MainWindow creator) { parent = creator; super.setPreferredSize(new Dimension(720, 172)); setLayout(new BorderLayout()); // add timer, save, and heatmap controls to the bar tc = new TimerControls(this); sc = new SaveControls(parent.getGrid(), this); hc = new HeatMapControls(this); add(tc, BorderLayout.WEST); add(hc, BorderLayout.CENTER); add(sc, BorderLayout.EAST); super.repaint(); super.setVisible(true); System.out.println("Done Constucting"); }
public static void main(String[] argv) { MainWindow win; DbgOutput.toStdout(); win = new MainWindow(); // process cmd line arguments int i; for (i = 0; i < argv.length; i++) { if (argv[i].equals("-D")) { i++; // try to interpret the next argument as the debug level int dbgLvl = 1; // basic debug level if (i >= argv.length) { // no more arguments, we stick with debug level 1 break; } try { dbgLvl = Integer.parseInt(argv[i]); } catch (NumberFormatException e) { dbgLvl = 1; // didn't work, this is probably a filename win.open(argv[i]); } DbgOutput.setDbgLevel(dbgLvl); Libgist.setDbgLevel(dbgLvl); } else if (argv[i].equals("-h")) { // print help message and exit System.out.println("Usage: amdb [-D <dbglevel> | -h] [index]"); System.exit(0); } else { // this is a name of an index, open it // System.out.println("open " + argv[i]); win.open(argv[i]); } } win.setTitle("amdb"); win.setSize(800, 600); win.setLocation(50, 50); win.setVisible(true); }
void replaceOldTrace() { boolean success = owner.replaceOldTrace(); if (success) setVisible(false); }
void saveNewToFile() { owner.saveDialog(new File("./untitiled.jst")); setVisible(false); }
public boolean saveToFile() { MainWindow.initDataFile(SCORE_MENU_FILE); DataInputStream input; DataOutputStream output; Class tempClass = new Class(); Student student = new Student(); Course course = new Course(); int[] testTime = new int[5]; int numberOfAttendTestStudent; long idOfStudents[]; float scoreOfTest[]; try { input = new DataInputStream(new FileInputStream(SCORE_MENU_FILE)); while (input.available() > 0) { tempClass.setGrade(input.readInt()); tempClass.setMajor(input.readUTF()); tempClass.setClassNumber(input.readInt()); int studentNumber = input.readInt(); tempClass.setStudentNumber(0); for (int i = 0; i < studentNumber; i++) { student.setId(input.readLong()); student.setName(input.readUTF()); } course.setId(input.readUTF()); course.setName(input.readUTF()); course.setCredit(input.readFloat()); course.setPeriod(input.readInt()); for (int i = 0; i < 5; i++) testTime[i] = input.readInt(); numberOfAttendTestStudent = input.readInt(); idOfStudents = new long[numberOfAttendTestStudent]; scoreOfTest = new float[numberOfAttendTestStudent]; for (int i = 0; i < numberOfAttendTestStudent; i++) idOfStudents[i] = input.readLong(); for (int i = 0; i < numberOfAttendTestStudent; i++) scoreOfTest[i] = input.readFloat(); if ((this.classOfScoreMenu.equals(tempClass)) && (this.course.equals(course))) { input.close(); return false; } } input.close(); output = new DataOutputStream(new FileOutputStream(SCORE_MENU_FILE, true)); output.writeInt(this.classOfScoreMenu.getGrade()); output.writeUTF(this.classOfScoreMenu.getMajor()); output.writeInt(this.classOfScoreMenu.getClassNumber()); int num = this.classOfScoreMenu.getStudentNumber(); output.writeInt(num); Student[] students = this.classOfScoreMenu.getStudents(); for (int i = 0; i < num; i++) { output.writeLong(students[i].getId()); output.writeUTF(students[i].getName()); } output.writeUTF(this.course.getId()); output.writeUTF(this.course.getName()); output.writeFloat(this.course.getCredit()); output.writeInt(this.course.getPeriod()); for (int i = 0; i < 5; i++) output.writeInt(this.testTime[i]); output.writeInt(this.numberOfAttendTestStudent); for (int i = 0; i < this.numberOfAttendTestStudent; i++) output.writeLong(this.idOfStudents[i]); for (int i = 0; i < this.numberOfAttendTestStudent; i++) output.writeFloat(this.scoreOfTest[i]); output.close(); return true; } catch (Exception e) { return false; } }