/** @param args the command line arguments */ public static void main(String[] args) { Grid g = Grid.getInstance(); System.out.println(g.toString()); MainWindow mainWindow = new MainWindow(); mainWindow.setVisible(true); mainWindow.drawGrid(g); System.out.println(g); mainWindow.setSpeed(Agent.getSpeed()); g.startAgents(); long start = System.currentTimeMillis(); while (true) { if (System.currentTimeMillis() - start > 10) { int car = g.nbCarriedItem(); int ongrid = g.nbItemsOnGrid(); MainWindow.getInstance().drawGrid(g); mainWindow.setCarried(car); mainWindow.setOngrid(ongrid); mainWindow.setTotal(car + ongrid); start = System.currentTimeMillis(); } } }
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 okActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_okActionPerformed try { if (txtuser.getText().equals("") || txtpassword.getText().equals("")) { JOptionPane.showMessageDialog(this, "Please Enter Username & Password", "Message", WIDTH); } else { // connect Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/student_information", "root", "123"); Statement stm = conn.createStatement(); String qry = "select password from login where username = '******' ;"; ResultSet rst = stm.executeQuery(qry); Statement stm2 = conn.createStatement(); String qry2 = "select state from login where username = '******'; "; ResultSet rst2 = stm2.executeQuery(qry2); if (!rst.next()) { // validate username JOptionPane.showMessageDialog(this, "Invalid Username", "Error", WIDTH); } else if (rst.getString("password").equals(txtpassword.getText())) { // check password MainWindow m = new MainWindow(); // open main m.setVisible(true); m.lbluser.setText(txtuser.getText()); if (rst2.next() && rst2.getInt("State") == 1) { // block lecturer m.lblState.setText("Admin"); } else { m.lblState.setText("Lecturer"); /* MainWindow mw1 = new MainWindow(); mw1.btnStudentm.setVisible(false); mw1.btnCoursem.setVisible(false); mw1.btnLecturerm.setVisible(false); mw1.btnAdmin.setVisible(false); mw1.lbllec.setVisible(false);*/ } this.setVisible(false); txtuser.setText(""); txtpassword.setText(""); } else { JOptionPane.showMessageDialog(this, "Invalid Password", "Error", WIDTH); } } } catch (Exception e) { JOptionPane.showMessageDialog(this, "Error in Excecution " + e, "Error", WIDTH); } } // GEN-LAST:event_okActionPerformed
@Override public void actionPerformed(ActionEvent event) { if (event.getSource() == boutonJouer) { String s = (String) JOptionPane.showInputDialog( this, "Veuillez entrer votre nom", "Nouvelle partie", JOptionPane.PLAIN_MESSAGE, null, null, "Dupont"); // If a string was returned, say so. if ((s != null) && (s.length() > 0)) { Joueur.getInstance().setUsername(s); } else return; this.setVisible(false); mainWindow.setVisible(true); } else if (event.getSource() == boutonAbout) { textWindow.setVisible(true); } }
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."); } }
/** * Initializes the new task window with selected directory that contains the edf files and the * output log file name * * @param edf_dir source edf file directory * @param output output file name */ public NewTask_for_ValidityCommandLine(String edf_dir, String output) { // TODO super(new JFrame(), false); MainWindow.log = output; File afile = new File(edf_dir); if (afile.exists()) { // (1) search for the edf files contained in chosen folder. sourceFiles = new ArrayList<File>(); Collection<File> fileCollection = FileUtils.listFiles( afile, new String[] {"edf", "Edf", "eDf", "edF", "EDf", "EdF", "eDF", "EDF"}, true); if (fileCollection != null) { int i = 0; for (File file : fileCollection) { addElementIntoLog(" + " + (++i) + ": " + file.getAbsolutePath(), true, output); sourceFiles.add(file); } } // (2) simulate GUI operation on an invisible GUI. MainWindow mainWindow = new MainWindow(); MainWindow.wkEdfFiles = sourceFiles; mainWindow.setVisible(false); initUI(); setVisible(false); ValidateFinishButtonListener validateFinishButtonListener = new ValidateFinishButtonListener(); validateFinishButtonListener.createWorkingDirectory(); // Using current loaded EDF file array to generate EDF file header arrays yieldNewEDFHeaders(); validateFinishButtonListener.yieldEiaTable(); // Generate ESATable using global defined sourceFiles(of type EDF) validateFinishButtonListener.yieldEsaTables(); // (3) validate the chosen EDF files. (new MainWindow.VerifyHeaderListener()).verifyHeaders(); ArrayList<Incompliance> aggregateIncompliances = MainWindow.aggregateIncompliances(); generateInvalidReport(aggregateIncompliances); } }
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); }
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); }
public static void main(String[] args) { String osName = System.getProperty("os.name"); if (osName != null && !osName.equals("")) { if (osName.toLowerCase().contains("windows")) { try { UIManager.setLookAndFeel(new WindowsLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } } } MainWindow mainWindow = new MainWindow(); mainWindow.setTitle("Jar Class Finder"); URL url = Launcher.class.getClassLoader().getResource("cn/jun/image/JarClassFinderLogo.png"); ImageIcon imageIcon = new ImageIcon(url); Image image = imageIcon.getImage(); mainWindow.setIconImage(image); mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainWindow.setVisible(true); }
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 void main(String[] args) { // parse cmdline Options.parseCmdline(args); // create contact list contactList = new ContactList(); // display main window mainWindow = new MainWindow(contactList); mainWindow.setVisible(true); // start sending beacons try { beaconSendThread = new BeaconSendThread(); } catch (IOException e) { errExit("Error starting beaconSendThread: " + e.getMessage()); } beaconSendThread.start(); // start listening for beacons try { beaconListenThread = new BeaconListenThread(contactList); } catch (IOException e) { errExit("Error starting beaconListenThread: " + e.getMessage()); } beaconListenThread.start(); // start listening for incoming transfers try { transferListenThread = new TransferListenThread(); } catch (IOException e) { errExit("Error starting transferListenThread: " + e.getMessage()); } transferListenThread.start(); }
public void openGUI() { pad = new MainWindow(); pad.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pad.setVisible(true); }