Ejemplo n.º 1
0
 public void actionPerformed(ActionEvent e) {
   int index = list.getSelectedIndex();
   if ("Move".equals(e.getActionCommand())) {
     copy = false;
     directoryList.getDirectory(index).copy = false;
   }
   if ("Copy".equals(e.getActionCommand())) {
     copy = true;
     directoryList.getDirectory(index).copy = true;
   }
 }
Ejemplo n.º 2
0
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("New Game")) {
      newGame();
    }

    if (e.getActionCommand().equals("Exit Game")) {
      exit();
    }
    if (e.getActionCommand().equals("About")) {
      JDialog f = new JDialog();
      f.add(new JLabel(new ImageIcon("splash_applet.jpg")));
      f.setSize(660, 520);
      f.setLocationRelativeTo(this);
      f.setVisible(true);
    }
  }
Ejemplo n.º 3
0
 /**
  * Handle ui actions.
  *
  * @param event The action event
  */
 public void actionPerformed(ActionEvent event) {
   String action = event.getActionCommand();
   if (action.equals(GuiUtils.CMD_SAVE)) {
     doSave();
   } else if (action.equals(GuiUtils.CMD_SAVEAS)) {
     doSaveAs();
   } else if (action.equals(GuiUtils.CMD_RENAME)) {
     doRename();
   } else if (action.equals(GuiUtils.CMD_NEW)) {
     doNew();
   } else if (action.equals(GuiUtils.CMD_IMPORT)) {
     doImport();
   } else if (action.equals(GuiUtils.CMD_EXPORT)) {
     doExport();
   } else if (action.equals(GuiUtils.CMD_REMOVE)) {
     doRemove();
   } else if (action.equals(GuiUtils.CMD_CLOSE)) {
     doClose();
   } else if (action.equals(CMD_BLACKBG)) {
     setCanvasBackground(Color.BLACK);
   } else if (action.equals(CMD_WHITEBG)) {
     setCanvasBackground(Color.WHITE);
   } else {
     super.actionPerformed(event);
   }
 }
Ejemplo n.º 4
0
 /**
  * Handle the event
  *
  * @param ae The event
  */
 public void actionPerformed(ActionEvent ae) {
   String cmd = ae.getActionCommand();
   if (cmd.equals(CMD_CONNECT)) {
     doConnect();
   } else {
     super.actionPerformed(ae);
   }
 }
Ejemplo n.º 5
0
    // implemented for ActionListener event handling
    public void actionPerformed(ActionEvent e) {
      String actionCmd = e.getActionCommand();
      Stack locStack = parentBrowserFrame.locationStack;
      Stack fwdStack = parentBrowserFrame.forwardStack;

      if (actionCmd.equals(homeCmd)) // event from home button
      {
        fwdStack.removeAllElements();
        parentBrowserFrame.setBrowserLocation(mainBrowserURL);
      } else if (actionCmd.equals(backCmd)) // event from back button
      {
        if (!locStack.isEmpty()) {
          String myLocale = (String) (locStack.pop());

          // push current location on forward stack
          fwdStack.push(location);
          getForwardButton().setEnabled(true);

          // do *not* cache the last location in the stack
          parentBrowserFrame.setBrowserLocation(myLocale, false);
        }
      } else if (actionCmd.equals(forwardCmd)) // event from forward button
      {
        if (!fwdStack.isEmpty()) {
          // remove location from forward stack
          String newLoc = (String) (fwdStack.pop());

          // DO add the current location to the back stack
          parentBrowserFrame.setBrowserLocation(newLoc);
        }
      } else if (actionCmd.equals(comboCmd)) // event from URL combo box!
      {
        if (e.getSource() instanceof JComboBox) // just to be sure
        {
          JComboBox thisBox = (JComboBox) e.getSource();

          String newLoc = thisBox.getSelectedItem().toString();
          if (newLoc != null && !newLoc.equals("")) // ignore empty selections
          {
            if (thisBox.getSelectedIndex() == -1) {
              thisBox.insertItemAt(newLoc, 0);
            }
            fwdStack.removeAllElements();
            parentBrowserFrame.setBrowserLocation(newLoc);
          }
        }
      }

      // disable the back button if we find the location stack is empty
      if (locStack.isEmpty()) {
        getBackButton().setEnabled(false);
      }

      // disable forward button if forward stack is empty
      if (fwdStack.isEmpty()) {
        getForwardButton().setEnabled(false);
      }
    }
Ejemplo n.º 6
0
    public void actionPerformed(ActionEvent a) {
      String command = a.getActionCommand();
      if (command.equals("e")) {
        // Log toggle.
        if (consoleDisplayed = !consoleDisplayed) {
          splitter.add(outputScroll);
          splitter.setDividerLocation(.8);
        } else {
          splitter.remove(outputScroll);
        }
      } else if (command.equals("k")) {
        if (text.getText().contains("class")) {
          // This means we should try to compile this as normal.

          // Pulls out class name
          String code = text.getText();
          int firstPos = code.indexOf("class");
          int secondPos = code.indexOf("{");
          String name = code.substring(firstPos + "class".length() + 1, secondPos).trim();

          compileAndRun(name, text.getText());
        } else {
          // This means we should compile this as a playground.
          String code = text.getText();

          // Common import statements built-in
          String importDump = new String();
          importDump +=
              ("import java.util.*;\n"
                  + "import javax.swing.*;\n"
                  + "import javax.swing.event.*;\n"
                  + "import java.awt.*;\n"
                  + "import java.awt.event.*;\n"
                  + "import java.io.*;\n");

          // Pulls out any "import" statements and appends them to the import dump.
          int i = code.indexOf("import");
          while (i >= 0) {
            String s = code.substring(i, code.indexOf(";", i) + 1);
            code = code.replaceFirst(s, "");
            importDump += s + "\n";
            i = code.indexOf("import", i + 1);
          }

          // Inject the class header and main method
          code =
              "//User and auto-imports pre-defined\n"
                  + importDump
                  + "//Autogenerated class\npublic class Main {\npublic static void main(String[] args) {\n"
                  + code
                  + "\n}\n}";

          compileAndRun("Main", code);
        }
      }
    }
Ejemplo n.º 7
0
    public void actionPerformed(ActionEvent event) {

      JMenuItem mi;
      String label = "";

      if (warningPopup == null) {
        warningPopup = new WarningDialog(textViewerFrame);
      }
      if ((editor1 == null) || (editor1.getDocument() == null)) {
        String errstr = "TextViewer:editor1 or document is null";
        warningPopup.display(errstr);
        return;
      }
      String actionStr = event.getActionCommand(); // is not makeing anysense
      // when keystrokes typed
      if ((event.getSource() instanceof JMenuItem)) {
        mi = (JMenuItem) event.getSource();
        label = mi.getText();
      } else if ((event.getSource() instanceof JTextArea)) { // keystroke
        label = "FindAgain"; // just set it to findagain
      } else {
        System.err.println("Debug:TextViewer:" + actionStr);
        System.err.println("Debug:TextViewer:" + event.getSource().toString());
        String errstr =
            "TextViewer:FindAction: "
                + event.getSource().toString()
                + " not an instance of JMenuItem or JTextArea";
        warningPopup.display(errstr);
        return;
      }

      if (label.equals("FindAgain")) {
        isFindAgain = true;
        lastFindStr = lastFindStr;
      } else {
        isFindAgain = false;
        lastFindStr = "";
      }
      StringBoolean content = new StringBoolean(lastFindStr, forwardFindDirection);

      boolean okPressed = mySearchDialog.display(content);
      if (!okPressed) {
        return;
      }
      lastFindStr = content.mystring;
      forwardFindDirection = content.myboolean;

      if (forwardFindDirection) {
        lastFindIndex = searchForward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);

      } else {
        lastFindIndex = searchBackward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);
      }
    }
Ejemplo n.º 8
0
    public void actionPerformed(ActionEvent e) {
      String command = e.getActionCommand();
      if (command.equals("standard")) setColorModelWRBB();
      else if (command.equals("invert")) invertCM();
      else if (command.equals("rainbow")) setColorModelRainbow();
      else if (command.equals("grey")) setColorModelGrey();
      else if (command.equals("swapBackground")) swapBackground();

      updateColors();
    }
Ejemplo n.º 9
0
  public void actionPerformed(ActionEvent evt) {

    // if start is pressed, activate run method
    if (evt.getActionCommand().equals("Start")) {

      start();
    }
    // if stop is pressed, stop all of the balls
    // and change color.
    if (evt.getActionCommand().equals("Stop")) {

      stop();
      changeColor();
    }
    // if clear all is pressed, clear all of the balls
    // from the canvas.
    if (evt.getActionCommand().equals("Clear All")) {

      ball.removeFromCanvas();
    }
  }
Ejemplo n.º 10
0
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().equals("No coloring")) {
     ((TreeWindow) parent).removeColor();
   } else if (e.getActionCommand().equals("Majority coloring")) {
     ((TreeWindow) parent).tree.setMajorityColoring(majorityColoringMenuItem.isSelected());
     ((TreeWindow) parent).tree.getTree().updateBranchColorFromChildren();
     // frame.recolorBranches();
   } else if (e.getActionCommand().equals("Number of OTUs")) {
     tree.getTree().sortByNumberOfOtus();
     tree.setYOffsets(tree.getTree(), 0);
     tree.setTOffsets(tree.getTree(), 0);
     tree.setROffsets(tree.getTree(), 0);
     tree.setRadialOffsets(tree.getTree());
   } else if (e.getActionCommand().equals("Number of immediate children")) {
     tree.getTree().sortByNumberOfChildren();
     tree.setYOffsets(tree.getTree(), 0);
     tree.setTOffsets(tree.getTree(), 0);
     tree.setROffsets(tree.getTree(), 0);
     tree.setRadialOffsets(tree.getTree());
   }
 }
Ejemplo n.º 11
0
 public void actionPerformed(ActionEvent e) {
   if (editor == null) return;
   String command = e.getActionCommand();
   if (command.equals("Add instance")) {
     String word = (String) wordList.getSelectedValue();
     editor.addInstanceOf(word, chooser);
   } else if (command.equals("Add word or PHRASE TYPE")) editor.addWord(chooser);
   else if (command.equals("Delete word")) {
     String word = (String) wordList.getSelectedValue();
     editor.deleteWord(word);
   }
 }
Ejemplo n.º 12
0
 /**
  * Handle action events
  *
  * @param event event to handle
  */
 public void actionPerformed(ActionEvent event) {
   String cmd = event.getActionCommand();
   if (cmd.equals(GuiUtils.CMD_OK) || cmd.equals(GuiUtils.CMD_APPLY)) {
     accept();
   }
   if (cmd.equals(GuiUtils.CMD_OK) || cmd.equals(GuiUtils.CMD_CANCEL)) {
     close();
   }
   if (cmd.equals(GuiUtils.CMD_HELP)) {
     ucar.unidata.ui.Help.getDefaultHelp().gotoTarget(helpId);
   }
 }
Ejemplo n.º 13
0
 public void actionPerformed(ActionEvent e) {
   ASDEditor editor = eNode.getEditor();
   if (editor == null) return;
   String command = e.getActionCommand();
   if (command.equals("Edit semantic action")) editor.editAction(eNode);
   else if (command.equals("Edit semantic value")) editor.editValue(eNode);
   else if (command.equals("Toggle Initial node")) editor.toggleInitial(eNode);
   else if (command.equals("Toggle Final node")) {
     editor.toggleFinal(eNode);
     eNode.changePopupMenu();
   } else if (command.equals("Delete node")) editor.deleteNode(eNode);
 }
Ejemplo n.º 14
0
    public void actionPerformed(ActionEvent e) {
      if (!this.isEnabled()) {
        return;
      }

      if (NEW_AIRSPACE.equals(e.getActionCommand())) {
        this.createNewEntry(this.getView().getSelectedFactory());
      } else if (CLEAR_SELECTION.equals(e.getActionCommand())) {
        this.selectEntry(null, true);
      } else if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals(e.getActionCommand())) {
        if (e.getSource() instanceof AbstractButton) {
          boolean selected = ((AbstractButton) e.getSource()).isSelected();
          this.setResizeNewShapesToViewport(selected);
        }
      } else if (ENABLE_EDIT.equals(e.getActionCommand())) {
        if (e.getSource() instanceof AbstractButton) {
          boolean selected = ((AbstractButton) e.getSource()).isSelected();
          this.setEnableEdit(selected);
        }
      } else if (OPEN.equals(e.getActionCommand())) {
        this.openFromFile();
      } else if (OPEN_URL.equals(e.getActionCommand())) {
        this.openFromURL();
      } else if (OPEN_DEMO_AIRSPACES.equals(e.getActionCommand())) {
        this.openFromPath(DEMO_AIRSPACES_PATH);
        this.zoomTo(
            LatLon.fromDegrees(47.6584074779224, -122.3059199579634),
            Angle.fromDegrees(-152),
            Angle.fromDegrees(75),
            750);
      } else if (REMOVE_SELECTED.equals(e.getActionCommand())) {
        this.removeEntries(Arrays.asList(this.getSelectedEntries()));
      } else if (SAVE.equals(e.getActionCommand())) {
        this.saveToFile();
      } else if (SELECTION_CHANGED.equals(e.getActionCommand())) {
        this.viewSelectionChanged();
      }
    }
Ejemplo n.º 15
0
  public void actionPerformed(ActionEvent ae) {
    String actionString = ae.getActionCommand();
    Searcher whichSearch = null;
    if (actionString.startsWith(Constants.NO_CONTEXT)) {
      actionString = actionString.substring(Constants.NO_CONTEXT.length());
    } else {
      if (_inTable != null) {
        int rowPoint = _inTable.rowAtPoint(new Point(getPopupX(), getPopupY()));
        whichSearch = (Searcher) _inTable.getValueAt(rowPoint, -1);
      }
    }

    DoAction(actionString, whichSearch);
  }
Ejemplo n.º 16
0
 /**
  * Handle any Gui actions.
  *
  * @param ae The <code>ActionEvent</code>.
  */
 public void actionPerformed(ActionEvent ae) {
   String cmd = ae.getActionCommand();
   if (cmd.equals(CMD_BROWSE)) {
     String filename = FileManager.getReadFile(FILTER_XML);
     if (filename == null) {
       return;
     }
     urlBox.setSelectedItem(filename);
   } else if (cmd.equals(GuiUtils.CMD_OK)) {
     doLoad();
   } else {
     // Here, the base class ChooserPanel will check if this command
     // is the load or cancel command.
     super.actionPerformed(ae);
   }
 }
Ejemplo n.º 17
0
 public void actionPerformed(ActionEvent e) {
   if (editor == null) return;
   String command = e.getActionCommand();
   String word = (String) wordList.getSelectedValue();
   if (command.equals("Add instance")) {
     editor.addInstanceOf(word, chooser);
     return;
   }
   String instance = (String) instanceList.getSelectedValue();
   if (command.equals("Edit semantic action")) editor.editAction(word, instance);
   else if (command.equals("Edit semantic value")) editor.editValue(word, instance);
   else if (command.equals("Toggle Initial instance"))
     editor.toggleInitial(word, instance, chooser);
   else if (command.equals("Toggle Final instance")) editor.toggleFinal(word, instance, chooser);
   else if (command.equals("Delete instance")) {
     editor.deleteInstance(word, instance, chooser);
   }
 }
Ejemplo n.º 18
0
  public void actionPerformed(ActionEvent e) {
    String cmd = (e.getActionCommand());

    if (cmd.equals(aboutItem.getText()))
      JOptionPane.showMessageDialog(
          this,
          "Simple Image Program for DB2004\nversion 0.1\nThanks to BvS",
          "About imageLab",
          JOptionPane.INFORMATION_MESSAGE);
    else if (cmd.equals(quitItem.getText())) System.exit(0);
    else if (cmd.equals(openItem.getText())) {
      int returnVal = chooser.showOpenDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2 = new Picture(chooser.getSelectedFile().getName());
          pic1 = new Picture(pic2.width(), pic2.height());
          lab.setIcon(pic2.getJLabel().getIcon());
          sliderPanel.setVisible(false);
          pack();
          repaint();
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not open " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Open Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }

    } else if (cmd.equals(saveItem.getText())) {
      int returnVal = chooser.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2.save(chooser.getSelectedFile().getName());
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not write " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Save Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }
    }
  }
Ejemplo n.º 19
0
 /**
  * Handle the CLOSEANCEL, OK, HELP, events.
  *
  * @param event The event
  */
 public void actionPerformed(ActionEvent event) {
   String cmd = event.getActionCommand();
   if (cmd.equals(GuiUtils.CMD_CLOSE)) {
     doClose();
   } else if (cmd.equals(GuiUtils.CMD_NEW)) {
     if (myTables.size() > 0) {
       ((ParamDefaultsTable) myTables.get(0)).addNewRow();
     }
   } else if (cmd.equals(GuiUtils.CMD_OK)) {
     saveData();
     doClose();
   } else if (cmd.equals(GuiUtils.CMD_HELP)) {
     showHelp();
   } else if (cmd.equals(GuiUtils.CMD_SAVEAS)) {
     doSaveAs(getCurrentTable().getParamInfoList());
   } else if (cmd.equals(GuiUtils.CMD_OPEN)) {
     doOpen();
   } else if (cmd.equals(GuiUtils.CMD_IMPORT)) {
     doImport();
   }
 }
Ejemplo n.º 20
0
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("cancel")) {
      this.dispose();
      timer.cancel();
    } else if (cmd.equals("ok")) {
      StnPlotSpecification spec = createPlotSpec();
      try {
        spec.writeToLog("New Station Value Plot (" + mFileViewer.getTitle() + "):");
      } catch (Exception ex) {
      }

      JOAStnValPlotWindow plotWind = new JOAStnValPlotWindow(spec, mFileViewer);
      plotWind.pack();
      plotWind.setVisible(true);
      mFileViewer.addOpenWindow(plotWind);
      timer.cancel();
      this.dispose();
    }
  }
Ejemplo n.º 21
0
 public void actionPerformed(ActionEvent e) {
   // When a toolbar button or menu item is
   // clicked on this function will be called
   String cmd = e.getActionCommand();
   if (cmd.equals("New")) {
     newFile();
   } else if (cmd.equals("Open")) {
     openFile();
   } else if (cmd.equals("Save")) {
     saveFile();
   } else if (cmd.equals("Save As")) {
     saveFileAs();
   } else if (cmd.equals("Exit")) {
     exit();
   } else if (cmd.equals("Run")) {
     evaluate();
   } else if (cmd.equals("Stop")) {
     stopEvaluate();
   } else if (cmd.equals("Pretty")) {
     prettyPrint();
   }
 }
 public void actionPerformed(ActionEvent e) {
   if (ACTION_COMMAND_BUTTON1.equalsIgnoreCase(e.getActionCommand())) {
     this.doActionOnButton1();
   } else if (ACTION_COMMAND_BUTTON2.equalsIgnoreCase(e.getActionCommand())) {
     this.doActionOnButton2();
   } else if (ACTION_COMMAND_BUTTON3.equalsIgnoreCase(e.getActionCommand())) {
     this.doActionOnButton3();
   } else if (ACTION_COMMAND_BUTTON4.equalsIgnoreCase(e.getActionCommand())) {
     this.doActionOnButton4();
   } else if (ACTION_COMMAND_BUTTON5.equalsIgnoreCase(e.getActionCommand())) {
     this.doActionOnButton5();
   } else if (ACTION_COMMAND_VERTICAL_EXAGGERATION.equalsIgnoreCase(e.getActionCommand())) {
     Double ve = (Double) e.getSource();
     this.doSetVerticalExaggeration(ve);
     this.wwd.redraw();
   }
 }
 /** Reaction to buttons and combo boxes. */
 public void actionPerformed(ActionEvent e) {
   String cmd = e.getActionCommand();
   if (cmdCtrlProp.equals(cmd)) {
     try {
       Class c =
           Class.forName("aurora.hwc.control.Panel" + myController.getClass().getSimpleName());
       AbstractPanelController cp = (AbstractPanelController) c.newInstance();
       cp.initialize(myController, null);
     } catch (Exception ex) {
     }
   }
   if (cmdCtrlList.equals(cmd)) {
     JComboBox cb = (JComboBox) e.getSource();
     if (cb.getSelectedIndex() > 0) {
       myController = (AbstractControllerComplex) listCControllers.getSelectedItem();
       buttonProp.setEnabled(true);
     } else {
       buttonProp.setEnabled(false);
       myController = null;
     }
     myMonitor.setMyController(myController);
   }
   return;
 }
Ejemplo n.º 24
0
    public void actionPerformed(ActionEvent e) {
      // This method can be called only when
      // there's a valid selection,
      // so go ahead and move the list item.
      int moveMe = list.getSelectedIndex();

      if (e.getActionCommand().equals(upString)) {
        // UP ARROW BUTTON
        if (moveMe != 0) {
          // not already at top
          swap(moveMe, moveMe - 1);
          list.setSelectedIndex(moveMe - 1);
          list.ensureIndexIsVisible(moveMe - 1);
        }
      } else {
        // DOWN ARROW BUTTON
        if (moveMe != listModel.getSize() - 1) {
          // not already at bottom
          swap(moveMe, moveMe + 1);
          list.setSelectedIndex(moveMe + 1);
          list.ensureIndexIsVisible(moveMe + 1);
        }
      }
    }
Ejemplo n.º 25
0
  public void actionPerformed(ActionEvent e) {
    String actionCommand = e.getActionCommand();

    if (actionCommand == "Low-pass") filter.setLowpass(true);
    else if (actionCommand == "High-pass") filter.setLowpass(false);
  }
Ejemplo n.º 26
0
 @Override
 public void actionPerformed(ActionEvent e) {
   processCommand(MenuCmds.valueOf(e.getActionCommand()));
 }
Ejemplo n.º 27
0
 /**
  * action performed
  *
  * @param evt event
  */
 public void actionPerformed(ActionEvent evt) {
   popButton.popNotify(evt.getActionCommand());
 } // actionPerformed()
Ejemplo n.º 28
0
  public void actionPerformed(ActionEvent a) {

    int code = 0;
    String roomtypeCompare_arr = null;
    String roomtypeCompare_dep = null;
    if ("book".equals(a.getActionCommand())) {
      try {
        Class.forName("com.mysql.jdbc.Driver");

        // Database connection information. Please note that when porting the code, you must have
        // the jdbc Driver installed where the code is running.
        Connection con =
            DriverManager.getConnection(
                "jdbc:mysql://67.20.111.85:3306/jeehtove_caliking?relaxAutoCommit=true",
                "jeehtove_ck",
                "Z_^PBBZT+kcy");

        // The SELECT query
        String query_arr =
            "SELECT * from reservations WHERE checkin BETWEEN '"
                + checkindateField.getText()
                + "' AND '"
                + checkoutdateField.getText()
                + "'";
        String query_dep =
            "SELECT * from reservations WHERE checkout BETWEEN '"
                + checkindateField.getText()
                + "' AND '"
                + checkoutdateField.getText()
                + "'";

        Statement stmt_arr = con.createStatement();
        Statement stmt_dep = con.createStatement();
        Statement stmt_insert = con.createStatement();
        ResultSet result_arr = stmt_arr.executeQuery(query_arr);
        ResultSet result_dep = stmt_dep.executeQuery(query_dep);

        // Get room type from radio buttons
        String room_type;
        if (standardRoom.isSelected()) {
          room_type = "Standard";
          code = 1;
        } else if (familyRoom.isSelected()) {
          room_type = "Family";
          code = 2;
        } else {
          room_type = "Suite";
          code = 3;
        }

        bookRoom();
        // ResultSet rs=stmt.executeQuery("select * from emp");
        /*if (!result_arr.next() && !result_dep.next()){

        	bookRoom();

        	//Query Prep for checking for open rooms
        	/*String query_checkrooms = "SELECT * FROM makereservation_rooms WHERE type = '" + code + "' AND booked = '0';";
        	Statement stmt_checkrooms = con.createStatement();
        	ResultSet checkrooms = stmt_checkrooms.executeQuery(query_checkrooms);

        	if (checkrooms.next()){
        	String getroomnumber = checkrooms.getString("room");
        	String insert = "INSERT INTO `reservations` VALUES ('" + getroomnumber + "', '" +  checkindateField.getText() + "', '" +  checkoutdateField.getText() + "',  '" + room_type + "',  '" + nameField.getText() + "');";
        	String bookroom = "UPDATE `makereservation_rooms` SET booked = '1' WHERE room = '" + getroomnumber + "';";
        	//System.out.println(insert);
        	int rs=stmt_insert.executeUpdate(insert);
        	int cr=stmt_checkrooms.executeUpdate(bookroom);
        	con.commit();
        	System.out.println("Room Booked!");
        }

        	else System.out.println("All " + room_type + " rooms are booked for the time requested.");
        }

        else {
        	if (result_arr.next()){
        		roomtypeCompare_arr = result_arr.getString("type");
        		System.out.println("(arrival) Does " + roomtypeCompare_arr + " equal " + room_type + "?");
        		if (roomtypeCompare_arr.equals(room_type)){
        			String  checkindateDB_arr = result_arr.getString("checkin");
        			String  checkoutdateDB_arr = result_arr.getString("checkout");
        			System.out.println("There is a room booked on " +  checkindateDB_arr + " that checks out on " +  checkoutdateDB_arr + ". Please select another date.");
        		}

        		else {

        			System.out.println("Room Booked!");
        		}
        	}
        }
        	//System.out.println(query_dep);
        	if (result_dep.next()){
        		roomtypeCompare_dep = result_dep.getString("type");
        		System.out.println("(departure) Does " + roomtypeCompare_dep + " equal " + room_type + "?");
        		if (roomtypeCompare_dep.equals(room_type)){
        			String  checkindateDB_dep = result_dep.getString("checkin");
        			String  checkoutdateDB_dep = result_dep.getString("checkout");
        			System.out.println("There is a room booked on " +  checkindateDB_dep + " that checks out on " +  checkoutdateDB_dep + ". Please select another date.");
        		}

        		else {
        			System.out.println("Room Booked!");
        		}
        	}*/
        con.close();

      } catch (Exception e) {
        System.out.println(e);
      }
    }
  }
 // ActionListener interface (for menus)
 public void actionPerformed(ActionEvent newEvent) {
   if (newEvent.getActionCommand().equals(miOpen.getActionCommand())) doOpen();
   else if (newEvent.getActionCommand().equals(miSave.getActionCommand())) doSave();
   else if (newEvent.getActionCommand().equals(miSaveAll.getActionCommand())) doSaveAll();
 }
Ejemplo n.º 30
0
 /**
  * Handle the action
  *
  * @param ae The action
  */
 public void actionPerformed(ActionEvent ae) {
   String cmd = ae.getActionCommand();
   if (cmd.equals(GuiUtils.CMD_CLOSE)) {
     close();
   }
 }