// --------------------------------actionConnect------------------------------ private void actionConnect() { if (oParty == null) { JOptionPane.showMessageDialog(frame, "Make a party before trying to connect."); return; } String[] oResults = (String[]) DialogManager.show(DialogManager.CONNECT, frame); if (oResults[DialogManager.RETURN_IP].equals("cancel")) return; lblStatus3.setText("Connecting..."); try { oConn.connect( oResults[DialogManager.RETURN_IP], Integer.parseInt(oResults[DialogManager.RETURN_PORT])); } catch (UnknownHostException e) { JOptionPane.showMessageDialog( frame, "The IP of the host cannot be determined.", "Unknown Host Exception", JOptionPane.ERROR_MESSAGE); frame.repaint(); return; } catch (IOException e) { JOptionPane.showMessageDialog( frame, e.getMessage(), "Input/Output Exception", JOptionPane.ERROR_MESSAGE); frame.repaint(); return; } echo("Connected to opponent!"); tConn = new Thread(oConn, "conn"); tConn.start(); tMain = new Thread(this, "main"); tMain.start(); }
public void actionPerformed(ActionEvent ev) { try { // stok String query = "DELETE FROM stok_produk WHERE id_produk=" + idProduk; int hasil1 = stm.executeUpdate(query); // pemasukkan query = "DELETE FROM pemasukan WHERE id_produk=" + idProduk; int hasil2 = stm.executeUpdate(query); // pengeluaran query = "DELETE FROM pengeluaran WHERE id_produk=" + idProduk; int hasil3 = stm.executeUpdate(query); // produk query = "DELETE FROM produk WHERE id_produk=" + idProduk; int hasil4 = stm.executeUpdate(query); if (hasil1 == 1 || hasil2 == 1 || hasil3 == 1 && hasil4 == 1) { setDataTabel(); JOptionPane.showMessageDialog(null, "berhasil hapus"); } else { JOptionPane.showMessageDialog(null, "gagal"); } } catch (SQLException SQLerr) { SQLerr.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
@FXML public void handleDrawBox(ActionEvent e) { if (drawBox_row.getText().isEmpty() || drawBox_column.getText().isEmpty() || drawBox_height.getText().isEmpty() || drawBox_width.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "Every Field should have a value!"); } else { try { ((RemoteOrderDisplay) service) .drawBox( RemoteOrderDisplayConstantMapper.getConstantNumberFromString( drawBox_units.getSelectionModel().getSelectedItem()), Integer.parseInt(drawBox_row.getText()), Integer.parseInt(drawBox_column.getText()), Integer.parseInt(drawBox_height.getText()), Integer.parseInt(drawBox_width.getText()), Integer.parseInt(drawBox_attribute.getText()), RemoteOrderDisplayConstantMapper.getConstantNumberFromString( drawBox_borderType.getSelectionModel().getSelectedItem())); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(null, e1.getMessage()); e1.printStackTrace(); } catch (JposException e1) { JOptionPane.showMessageDialog(null, e1.getMessage()); e1.printStackTrace(); } } }
private void jButton3ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed // libera a exclusao apenas se o ArrayList não estiver vazio if (RepositorioProdutos.listaProdutos.size() > 0) { Produto p = produtosTableModel.getProduto(jTableProduto.getSelectedRow()); if (p != null) { // teste System.out.print(p); int opcao = JOptionPane.showConfirmDialog( this, p.getNome(), "Excluir produto?", JOptionPane.YES_NO_OPTION); if (opcao == JOptionPane.YES_OPTION) { RepositorioProdutos.removerProdutos(p); produtosTableModel.atualizarTabela(); } else if (opcao == JOptionPane.NO_OPTION) { System.out.print("exclusão abortada"); } } else if (p == null) { // getSelectedRow retorna -1 quando não esta selecionado System.out.print(jTableProduto.getSelectedRow()); JOptionPane.showMessageDialog(this, "Selecione ou pesquise um produto para excluir"); } } else { JOptionPane.showMessageDialog(this, "O sistema não possui produtos cadastrados!"); } } // GEN-LAST:event_jButton3ActionPerformed
private void testlength() { String testlen = "How has your day been?"; JOptionPane.showMessageDialog(null, "The Length Test"); JOptionPane.showMessageDialog(null, "Let see how long this sentance is."); JOptionPane.showMessageDialog(null, "The sentance is:" + testlen); JOptionPane.showMessageDialog(null, testlen.length()); }
public void actionPerformed(ActionEvent e) { if (e.getSource() == btnPractice) { if (NewWord.size() == 0) { JOptionPane.showMessageDialog(null, "单词本现在无生词,请加入生词后再做练习"); } else { dictionary.setVisible(false); PracticeFrame practiceFrame = new PracticeFrame(1); practiceFrame.setLocationRelativeTo(NewWordNotePane.this); btnSpellWord.setEnabled(false); btnPractice.setEnabled(false); } } else if (e.getSource() == btnSpellWord) { if (NewWord.size() == 0) { JOptionPane.showMessageDialog(null, "单词本现在无生词,请加入生词后再做练习"); } else { dictionary.setVisible(false); PracticeFrame practiceFrame = new PracticeFrame(2); practiceFrame.setLocationRelativeTo(NewWordNotePane.this); btnSpellWord.setEnabled(false); btnPractice.setEnabled(false); } } else if (e.getSource() == deleteWord) { DeleteNewWord(); } }
/** Delete an employee */ private void deleteEmp() { parent.doBlur(); int sure = JOptionPane.showConfirmDialog( parent.getView(), Messages.getString("EmployeeController.7"), Messages.getString("EmployeeController.8"), // $NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); if (sure == JOptionPane.OK_OPTION) { // Get Id employee selected String empID = view.getTblEmp().getValueAt(view.getTblEmp().getSelectedRow(), 0).toString(); if (!AccessEmp.getInstance().deleteEmp(Integer.parseInt(empID))) { JOptionPane.showMessageDialog( parent.getView(), Messages.getString("EmployeeController.9") // $NON-NLS-1$ + Messages.getString("EmployeeController.10"), // $NON-NLS-1$ Messages.getString("EmployeeController.11"), JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog( parent.getView(), Messages.getString("EmployeeController.12"), Messages.getString("EmployeeController.13"), // $NON-NLS-1$ JOptionPane.INFORMATION_MESSAGE); empModel.removeRow(view.getTblEmp().getSelectedRow()); } } tableFocus(); parent.doBlur(); }
public void validerFactures() { Factures factures = (Factures) classe; if (factures .getDonnees() .exist("factures", "NumFacture", "numfacture = " + factures.getjNumFacture().getText())) { String[] re = factures.getValeurDevises().get(factures.getDevises().getSelectedItem()); String[] valeursInit = factures .getDonnees() .fiche( "Round(f.montanttaxe, 2), f.valeur, f.modepaiement, f.preclettre, f.dateEmission, f.dateEcheance, f.anneeValeur, f.CodeDevise", "factures as f", "f.numfacture = " + factures.getjNumFacture().getText()); String[] valeursModifie = new String[8]; // System.out.println(factures.getRecupTVA() + " - " + valeursInit[0]); valeursModifie[0] = factures.getRecupTVA() + ""; valeursModifie[1] = factures.getjValeur().getText(); System.out.println( factures.getModespaiements().get(factures.getBoxModePaiement().getSelectedItem()).length); valeursModifie[2] = factures.getModespaiements().get(factures.getBoxModePaiement().getSelectedItem())[0]; valeursModifie[3] = factures.getjPrecision().getText(); valeursModifie[4] = new SimpleDateFormat("yyyy-MM-dd").format(factures.getjDateEmission().getDate()); valeursModifie[5] = new SimpleDateFormat("yyyy-MM-dd").format(factures.getjDateEcheance().getDate()); valeursModifie[6] = factures.getjAnneeValeur().getText(); valeursModifie[7] = re[0]; if (!ModifieOuIdentique(valeursInit, valeursModifie)) { factures .getBase() .update( "factures", "MontantTaxe = " + valeursModifie[0] + " , valeur = " + factures.getjValeur().getText() + ", ModePaiement = " + factures.getModespaiements() .get(factures.getBoxModePaiement().getSelectedItem())[0] + ", PrecLettre = '" + apostrophe(factures.getjPrecision().getText()) + "', DateEmission = '" + new SimpleDateFormat("yyyy/MM/dd") .format(factures.getjDateEmission().getDate()) + "', DateEcheance = '" + new SimpleDateFormat("yyyy/MM/dd") .format(factures.getjDateEcheance().getDate()) + "', AnneeValeur = " + factures.getjAnneeValeur().getText() + ", CodeDevise = " + re[0], "numFacture = " + factures.getjNumFacture().getText()); JOptionPane.showMessageDialog(null, "Facture modifié !"); } } else { JOptionPane.showMessageDialog( null, "Numéro de Facture inexistant", "ATTENTION", JOptionPane.WARNING_MESSAGE); } }
public boolean checkFields() { if (name.getText().length() <= 2) { JOptionPane.showMessageDialog( null, name.getText() + " is not a valid name! (it should contain at least three letters)", "Error", JOptionPane.ERROR_MESSAGE); return false; } if (SocketHelper.checkIP(ipAddr.getText()) == false) { JOptionPane.showMessageDialog( null, ipAddr.getText() + " is not a valid ip!", "Error", JOptionPane.ERROR_MESSAGE); return false; } int Port; try { Port = Integer.parseInt(port.getText()); } catch (NumberFormatException nfe) { Port = 0; } if (Port < 90) { JOptionPane.showMessageDialog( null, port.getText() + " is not a valid port!", "Error", JOptionPane.ERROR_MESSAGE); return false; } if (contacts.exists(ipAddr.getText(), Port)) { JOptionPane.showMessageDialog( null, "contact with this ip and port already exists", "Error", JOptionPane.ERROR_MESSAGE); return false; } return true; }
public boolean addCustomBiome(Window parent, CustomBiome customBiome) { if (isBiomePresent(customBiome.getId())) { JOptionPane.showMessageDialog( parent, "The specified ID (" + customBiome.getId() + ") is already a regular biome (named " + Minecraft1_7Biomes.BIOME_NAMES[customBiome.getId()] + ")", "ID Already In Use", JOptionPane.ERROR_MESSAGE); return false; } if (customBiomes == null) { customBiomes = new ArrayList<>(); } for (CustomBiome existingCustomBiome : customBiomes) { if (existingCustomBiome.getId() == customBiome.getId()) { JOptionPane.showMessageDialog( parent, "You already configured a custom biome with that ID (named " + existingCustomBiome.getName() + ")", "ID Already In Use", JOptionPane.ERROR_MESSAGE); return false; } } customBiomes.add(customBiome); for (CustomBiomeListener listener : listeners) { listener.customBiomeAdded(customBiome); } return true; }
public void actionForSpin() { // automatic collect actionForCollect(); if (credit - bet < 0) { JOptionPane.showMessageDialog( null, "Please select a smaller Bet", "Insufficient funds !", JOptionPane.WARNING_MESSAGE); } else if (credit - bet >= 0) { credit -= bet; CustomizedFrame.display.setVisible(false); TilesPanel.displayValues(); ButtonsPanel.newCredit(); CustomizedFrame.display.setVisible(true); winning = win.lookForWinnings(numberOfLines); ButtonsPanel.newWinning(); } if (credit == 0 && winning == 0) { Labels.creditLabel.setText("" + 0); JOptionPane.showMessageDialog( null, "Thanks for Playing", "Out of Credit !", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } }
@FXML public void handleVideoSound(ActionEvent e) { if (videoSound_frequency.getText().isEmpty() || videoSound_duration.getText().isEmpty() || videoSound_numberOfCycles.getText().isEmpty() || videoSound_interSoundWait.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "Every Field should have a value!"); } else { try { ((RemoteOrderDisplay) service) .videoSound( RemoteOrderDisplayConstantMapper.getConstantNumberFromString( videoSound_units.getSelectionModel().getSelectedItem()), Integer.parseInt(videoSound_frequency.getText()), Integer.parseInt(videoSound_duration.getText()), Integer.parseInt(videoSound_numberOfCycles.getText()), Integer.parseInt(videoSound_interSoundWait.getText())); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(null, e1.getMessage()); e1.printStackTrace(); } catch (JposException e1) { JOptionPane.showMessageDialog(null, e1.getMessage()); e1.printStackTrace(); } } }
@FXML public void handleUpdateVideoRegionAttribute(ActionEvent e) { if (updateVideoRegionAttribute_row.getText().isEmpty() || updateVideoRegionAttribute_col.getText().isEmpty() || updateVideoRegionAttribute_height.getText().isEmpty() || updateVideoRegionAttribute_width.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "Every Field should have a value!"); } else { try { ((RemoteOrderDisplay) service) .updateVideoRegionAttribute( RemoteOrderDisplayConstantMapper.getConstantNumberFromString( updateVideoRegionAttribute_units.getSelectionModel().getSelectedItem()), RemoteOrderDisplayConstantMapper.getConstantNumberFromString( updateVideoRegionAttribute_function.getSelectionModel().getSelectedItem()), Integer.parseInt(updateVideoRegionAttribute_row.getText()), Integer.parseInt(updateVideoRegionAttribute_col.getText()), Integer.parseInt(updateVideoRegionAttribute_height.getText()), Integer.parseInt(updateVideoRegionAttribute_width.getText()), Integer.parseInt(updateVideoRegionAttribute_attribute.getText())); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(null, e1.getMessage()); e1.printStackTrace(); } catch (JposException e1) { JOptionPane.showMessageDialog(null, e1.getMessage()); e1.printStackTrace(); } } }
@FXML public void handleSaveVideoRegion(ActionEvent e) { if (saveVideoRegion_row.getText().isEmpty() || saveVideoRegion_column.getText().isEmpty() || saveVideoRegion_height.getText().isEmpty() || saveVideoRegion_width.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "Every Field should have a value!"); } else { try { ((RemoteOrderDisplay) service) .saveVideoRegion( RemoteOrderDisplayConstantMapper.getConstantNumberFromString( saveVideoRegion_units.getSelectionModel().getSelectedItem()), Integer.parseInt(saveVideoRegion_row.getText()), Integer.parseInt(saveVideoRegion_column.getText()), Integer.parseInt(saveVideoRegion_height.getText()), Integer.parseInt(saveVideoRegion_height.getText()), saveVideoRegion_bufferID.getSelectionModel().getSelectedItem()); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(null, e1.getMessage()); e1.printStackTrace(); } catch (JposException e1) { JOptionPane.showMessageDialog(null, e1.getMessage()); e1.printStackTrace(); } } }
private void botaoInserirActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_botaoInserirActionPerformed try { String[] opcoes = {"sim", "não"}; String rg = JOptionPane.showInputDialog("Digite seu RG"); controllerCliente = new ClienteControllerUI(); if (controllerCliente.clienteExiste(Long.parseLong(rg))) { int op = JOptionPane.showOptionDialog( this, "Deseja alugar este livro?", "Cliente encontrado!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, opcoes, opcoes[0]); if (op == 0) { JOptionPane.showMessageDialog(this, "Processando Dados..."); controller.salvarAluguel(Long.parseLong(rg)); } else { JOptionPane.showMessageDialog(this, "Livro não pode ser alugado!"); } } else { JOptionPane.showMessageDialog(this, "Cliente não encontrado!"); } } catch (Exception e) { JOptionPane.showMessageDialog(this, "Campo inválido!"); } } // GEN-LAST:event_botaoInserirActionPerformed
public static Connection GetConnection() { try { Class.forName("com.mysql.jdbc.Driver"); String servidor = "jdbc:mysql://localhost/sugarcrm"; String usuarioDB = "root"; String passwordDB = ""; conexion = DriverManager.getConnection(servidor, usuarioDB, passwordDB); } catch (ClassNotFoundException ex) { JOptionPane.showMessageDialog( null, ex, "Error1 en la Conexión con la BD " + ex.getMessage(), JOptionPane.ERROR_MESSAGE); conexion = null; } catch (SQLException ex) { JOptionPane.showMessageDialog( null, ex, "Error2 en la Conexión con la BD " + ex.getMessage(), JOptionPane.ERROR_MESSAGE); conexion = null; } catch (Exception ex) { JOptionPane.showMessageDialog( null, ex, "Error3 en la Conexión con la BD " + ex.getMessage(), JOptionPane.ERROR_MESSAGE); conexion = null; } finally { return conexion; } }
/** Method add employee on database */ private void addEmp() { parent.doBlur(); // Display Add employee dialog addEmp = new AddEmployeeController(new AddEmployeeDialog(parent.getView())); addEmp.getView().setVisible(true); // invoked method add employee if (addEmp.getEmp() != null) { if (AccessEmp.getInstance().addEmp(addEmp.getEmp())) { JOptionPane.showMessageDialog( view, Messages.getString("EmployeeController.0"), // $NON-NLS-1$ Messages.getString("EmployeeController.1"), JOptionPane.INFORMATION_MESSAGE); // Move last page and show newest employee view.getTxtEmpID().setText(Messages.getString("EmptyText")); // $NON-NLS-1$ view.getTxtEmpName().setText(Messages.getString("EmptyText")); // $NON-NLS-1$ view.getBtnLast().doClick(); } else { JOptionPane.showMessageDialog( view, Messages.getString("EmployeeController.4") // $NON-NLS-1$ + Messages.getString("EmployeeController.5"), Messages.getString("EmployeeController.6"), // $NON-NLS-1$ JOptionPane.ERROR_MESSAGE); } } parent.doBlur(); // Set selection to new employee view.getTblEmp().changeSelection(view.getTblEmp().getRowCount() - 1, 0, false, false); }
private int inserir(Endereco e) { int status = -1; Connection con = null; PreparedStatement pstm = null; try { con = ConnectionFactory.getConnection(); pstm = con.prepareStatement(INSERT, Statement.RETURN_GENERATED_KEYS); pstm.setString(1, e.getRua()); pstm.execute(); try (ResultSet rs = pstm.getGeneratedKeys()) { rs.next(); status = rs.getInt(1); } } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Erro ao inserir um endereço: " + ex.getMessage()); } finally { } try { ConnectionFactory.closeConnection(con, pstm); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Erro ao fechar conexão: " + ex.getMessage()); } return status; }
/** Method edit employee on database and edit on employee table */ private void editEmp() { parent.doBlur(); // Get Id employee selected String empID = view.getTblEmp().getValueAt(view.getTblEmp().getSelectedRow(), 0).toString(); // Get employee from database Employee emp = AccessEmp.getInstance().getEmpInfo(new Integer(empID)); // Create instance of Employee edit dialog and display it editEmp = new EditEmployeeController(new EditEmployeeDialog(parent.getView()), emp); editEmp.getView().setVisible(true); // Update data on database if (editEmp.getEmp() != null) { if (AccessEmp.getInstance().editEmp(editEmp.getEmp())) { JOptionPane.showMessageDialog( view, Messages.getString("EmployeeController.14"), // $NON-NLS-1$ Messages.getString("EmployeeController.15"), JOptionPane.INFORMATION_MESSAGE); // Remove old data on table model empModel.removeRow(view.getTblEmp().getSelectedRow()); // Add new row empModel.addRow(emp.toVector()); } else { JOptionPane.showMessageDialog( view, Messages.getString("EmployeeController.16") // $NON-NLS-1$ + Messages.getString("EmployeeController.17"), Messages.getString("EmployeeController.18"), // $NON-NLS-1$ JOptionPane.ERROR_MESSAGE); } } parent.doBlur(); // Set selection to employee book view.getTblEmp().changeSelection(view.getTblEmp().getRowCount() - 1, 0, false, false); }
private void okMouseClicked(java.awt.event.MouseEvent evt) throws RemoteException { // GEN-FIRST:event_okMouseClicked // TODO add your handling code here: int type = 0; if (kuai.isSelected()) type = 1; else if (yingywy.isSelected()) type = 2; else if (zhongywy.isSelected()) type = 3; else if (zhongkc.isSelected()) type = 4; else if (yibancwy.isSelected()) type = 5; else if (gaojicwy.isSelected()) type = 6; else if (zongjl.isSelected()) type = 7; else if (guanly.isSelected()) type = 8; System.out.println(Id + " " + Password + " " + Name + " " + type); UserAuthorityManagervo o = new UserAuthorityManagervo(Id, Password, Name, 0); UserAuthorityManagervo n = new UserAuthorityManagervo(Id, Password, Name, type); boolean b = u.changeOrder(o, n); System.out.println("lalalalaalalalal"); if (b) { System.out.println("成功!"); JOptionPane.showMessageDialog(null, "修改成功", "成功", JOptionPane.INFORMATION_MESSAGE); this.dispose(); } else { JOptionPane.showMessageDialog(null, "修改失败", "可能不存在此ID!", JOptionPane.ERROR_MESSAGE); } // TODO add your handling code here: }
public void actionPerformed(ActionEvent e) { // Launch ModelCenter with the filename provided try { openModelInModelCenter(); } catch (ElementIsNotAModelCenterModel e1) { // Do nothing - this should not happen anyway } catch (UserCanceledOperation e1) { // Do nothing - user simply canceled when creating a new file } catch (ModelCenterException e1) { JOptionPane.showMessageDialog( MDDialogParentProvider.getProvider().getDialogParent(), "Error communicating with ModelCenter", "ModelCenter Plugin - Critical Error", JOptionPane.ERROR_MESSAGE); } catch (FailedToLaunchModelCenter e1) { JOptionPane.showMessageDialog( MDDialogParentProvider.getProvider().getDialogParent(), "Failed to launch ModelCenter - please ensure that ModelCenter is installed", "ModelCenter Plugin", JOptionPane.WARNING_MESSAGE); } catch (ModelCenterProfileNotLoaded e1) { JOptionPane.showMessageDialog( MDDialogParentProvider.getProvider().getDialogParent(), "The ModelCenter profile no longer seems to be loaded - failed to synchronize changes\nfrom ModelCenter model. Load the profile and synchronize manually", "ModelCenter Plugin - Critical Error", JOptionPane.ERROR_MESSAGE); } }
public void save() throws Exception { super.save(); try { comm.saveViewComponent(this.getViewComponent()); ActionHub.fireActionPerformed( new ActionEvent( this.getViewComponent(), ActionEvent.ACTION_PERFORMED, Constants.ACTION_TREE_ENTRY_NAME)); } catch (ViewComponentLinkNameAlreadyExisting vc) { JOptionPane.showMessageDialog( UIConstants.getMainFrame(), rb.getString("exception.ViewComponentLinkNameAlreadyExisting"), rb.getString("dialog.title"), JOptionPane.ERROR_MESSAGE); } catch (ViewComponentNotFound vn) { JOptionPane.showMessageDialog( UIConstants.getMainFrame(), rb.getString("exception.ViewComponentNotFound"), rb.getString("dialog.title"), JOptionPane.ERROR_MESSAGE); } catch (ViewComponentLinkNameIsEmptyException ve) { JOptionPane.showMessageDialog( UIConstants.getMainFrame(), rb.getString("exception.ViewComponentLinkNameIsEmpty"), rb.getString("dialog.title"), JOptionPane.ERROR_MESSAGE); } }
private void testcontains() { String testcont = "1, 2, 5, My lord three is what you meant to say."; JOptionPane.showMessageDialog(null, "The contains Test"); JOptionPane.showMessageDialog(null, "Lets check to see if this has the word (what) in it."); JOptionPane.showMessageDialog(null, "The sentance is:" + testcont); JOptionPane.showMessageDialog(null, testcont.contains("what")); }
public java.sql.Connection getDbConnection(java.lang.String userName, java.lang.String passWord) throws java.sql.SQLException { java.sql.Connection connection = null; try { java.lang.Class.forName("org.postgresql.Driver"); } catch (java.lang.ClassNotFoundException cnf) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), cnf.getMessage()); } try { connection = java.sql.DriverManager.getConnection( "jdbc:postgresql://" + this.dbServerIp + ":" + dbPort + "/" + activeDatabase, userName, passWord); } catch (java.sql.SQLException sqlExec) { javax.swing.JOptionPane.showMessageDialog( new javax.swing.JFrame(), "ERROR : Logon denied due to incorrect password!"); } return connection; }
@Override public void actionPerformed(ActionEvent actionEvent) { String serverName = panel.getServerNameField().getText(); String serverAddress = panel.getServerAddressField().getText(); if (serverName == null || "".equals(serverName)) { JOptionPane.showMessageDialog(panel, "服务器名称不能为空", "错误", JOptionPane.ERROR_MESSAGE); return; } if (serverAddress == null || "".equals(serverAddress)) { JOptionPane.showMessageDialog(panel, "服务器地址不能为空", "错误", JOptionPane.ERROR_MESSAGE); return; } Server server = new Server(); server.setName(serverName); server.setAddress(serverAddress); server.setLatency(Server.NO_LATENCY); server.setStatus(Server.UNKNOWN); try { app.getServerRepository().saveServer(server); dialog.setVisible(false); } catch (DuplicateServerDefinitionException e) { JOptionPane.showMessageDialog(panel, e.getMessage(), "错误", JOptionPane.ERROR_MESSAGE); } }
/** * Writes data out in XML format. * * @return A flag indicating the success of the operation. */ private boolean writeXMLFile() { File selectedFile = model.getFile(); try { FileOutputStream ow = new FileOutputStream(selectedFile); DriveTrainEncoder.encode(ow, model); ow.close(); model.reset(); return true; } catch (IOException iox) { JOptionPane.showMessageDialog( this, Messages.format("Main.15", iox.getLocalizedMessage()), // $NON-NLS-1$ Messages.getString("Main.16"), JOptionPane.ERROR_MESSAGE); // $NON-NLS-1$ return false; } catch (ParserConfigurationException iox) { JOptionPane.showMessageDialog( this, Messages.format("ParserConfigurationException", iox.getLocalizedMessage()), // $NON-NLS-1$ Messages.getString("Main.16"), JOptionPane.ERROR_MESSAGE); // $NON-NLS-1$ return false; } catch (TransformerException iox) { JOptionPane.showMessageDialog( this, Messages.format("TransformerException", iox.getLocalizedMessage()), // $NON-NLS-1$ Messages.getString("Main.16"), JOptionPane.ERROR_MESSAGE); // $NON-NLS-1$ return false; } }
private boolean validateModelName(String name) { // System.err.println("Validating: " + modelName); // check that the name is valid if (name.equals(parameter.getName())) { return true; } if (name.trim().length() == 0) { Toolkit.getDefaultToolkit().beep(); return false; } // check that a parameter with this name doesn't exist if (parameterExists(name)) { JOptionPane.showMessageDialog( frame, "A parameter with this name already exists.", "Linked parameter error", JOptionPane.WARNING_MESSAGE); return false; } // check that a model with this name doesn't exist if (modelExists(name)) { JOptionPane.showMessageDialog( frame, "A model with this name already exists.", "Linked parameter error", JOptionPane.WARNING_MESSAGE); return false; } return true; }
/** * Handles a click event. If the blocked user list is updated as a result the proxy will respond * with the new list asynchronously. * * @param actionCommand the action performed by the user */ private void clickHandler(Object actionCommand) { System.out.println( "Received command: " + actionCommand + "\tText = " + blockTextField.getText()); if (actionCommand.equals(CMD_BLOCK)) { String blocked = blockTextField.getText(); if (blocked == null || "".equals(blocked)) { JOptionPane.showMessageDialog( this, "You must provide the username of the user to be blocked."); return; } else if (!isAlphaNumeric(blocked)) { JOptionPane.showMessageDialog(this, "The username must be alphanumeric"); return; } try { blockingProcessing.processBlock(blocked); } catch (CommunicationsException e) { JOptionPane.showMessageDialog(this, "Unable to send the block request. (T__T)"); } } else if (actionCommand.equals(CMD_UNBLOCK)) { String unblocked = blockedList.getSelectedValue(); if (unblocked == null || "".equals(unblocked)) { JOptionPane.showMessageDialog(this, "Please select the user to be unblocked."); return; } try { blockingProcessing.processUnblock(unblocked); } catch (CommunicationsException e) { JOptionPane.showMessageDialog(this, "Unable to process block request. (T__T)"); } } }
private FilePlacement parsePlacement() { Object selectedProjection = this.projectionCombo.getSelectedItem(); if (!(selectedProjection instanceof Projection)) { JOptionPane.showMessageDialog(Main.parent, tr("Please set a projection.")); return null; } FilePlacement placement = new FilePlacement(); placement.projection = (Projection) this.projectionCombo.getSelectedItem(); try { placement.setPdfBounds( Double.parseDouble(this.minXField.getText()), Double.parseDouble(this.minYField.getText()), Double.parseDouble(this.maxXField.getText()), Double.parseDouble(this.maxYField.getText())); placement.setEastNorthBounds( Double.parseDouble(this.minEastField.getText()), Double.parseDouble(this.minNorthField.getText()), Double.parseDouble(this.maxEastField.getText()), Double.parseDouble(this.maxNorthField.getText())); } catch (Exception e) { JOptionPane.showMessageDialog(Main.parent, tr("Could not parse numbers. Please check.")); return null; } return placement; }
@FXML public void handleControlClock(ActionEvent e) { if (controlClock_hour.getText().isEmpty() || controlClock_min.getText().isEmpty() || controlClock_sec.getText().isEmpty() || controlClock_row.getText().isEmpty() || controlClock_column.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "Every Field should have a value!"); } else { try { ((RemoteOrderDisplay) service) .controlClock( RemoteOrderDisplayConstantMapper.getConstantNumberFromString( controlClock_units.getSelectionModel().getSelectedItem()), RemoteOrderDisplayConstantMapper.getConstantNumberFromString( controlClock_function.getSelectionModel().getSelectedItem()), controlClock_clockID.getSelectionModel().getSelectedItem(), Integer.parseInt(controlClock_hour.getText()), Integer.parseInt(controlClock_min.getText()), Integer.parseInt(controlClock_sec.getText()), Integer.parseInt(controlClock_row.getText()), Integer.parseInt(controlClock_column.getText()), Integer.parseInt(controlClock_attribute.getText()), RemoteOrderDisplayConstantMapper.getConstantNumberFromString( controlClock_mode.getSelectionModel().getSelectedItem())); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(null, e1.getMessage()); e1.printStackTrace(); } catch (JposException e1) { JOptionPane.showMessageDialog(null, e1.getMessage()); e1.printStackTrace(); } } }