Example usage for javax.swing JOptionPane INFORMATION_MESSAGE

List of usage examples for javax.swing JOptionPane INFORMATION_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane INFORMATION_MESSAGE.

Prototype

int INFORMATION_MESSAGE

To view the source code for javax.swing JOptionPane INFORMATION_MESSAGE.

Click Source Link

Document

Used for information messages.

Usage

From source file:userInteface.Patient.ManageVitalSignsJPanel.java

private void editVitalSignsJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editVitalSignsJButtonActionPerformed
    // TODO add your handling code here:
    int selectedRow = viewVitalSignsJTable.getSelectedRow();
    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(this, "Please select a row from table.", "Error",
                JOptionPane.INFORMATION_MESSAGE);
        return;// w  w  w .  j  a  v a 2s .c  o  m
    }
    VitalSign vitalSign = (VitalSign) viewVitalSignsJTable.getValueAt(selectedRow, 0);

    ViewUpdateVitalSignsJPanel vuvsJPanel = new ViewUpdateVitalSignsJPanel(userProcessContainer, vitalSign,
            Boolean.TRUE);
    userProcessContainer.add("vuvsJPanel", vuvsJPanel);
    CardLayout layout = (CardLayout) userProcessContainer.getLayout();
    layout.next(userProcessContainer);
}

From source file:Main.Interface_Main.java

/**
 * Creates new form Interface_Main//from w w w .j a  v a  2  s. c  om
 * Populates the com port combo box
 * Init the graphs for Current, Voltage, and Wattage
 */
public Interface_Main() {
    initComponents();
    btnStop.setEnabled(false);
    btnStart.setEnabled(false);
    btnThreshold.setEnabled(false);
    sldScreen.setEnabled(false);
    btnReset.setEnabled(false);
    spnRefSpd.setEnabled(false);

    Image im = null;

    try {
        im = ImageIO.read(getClass().getResource("/faviconbot2edit.png"));
        setIconImage(im);
    } catch (IOException ex) {

    }

    //Version check to notify user and update title bar. 
    Double newVer = checkVersion('A');
    if (newVer > appVersion) {
        JOptionPane.showMessageDialog(this, "Update available! Visit: http://github.com/friedcircuits",
                "Update", JOptionPane.INFORMATION_MESSAGE);
        jlblVer.setVisible(false);
        appTitle = appTitle + " - New Version: " + newVer.toString();
        jlblVer.setText(appTitle);
    } else {
        jlblVer.setText(appTitle);
    }

    cmbPort.removeAllItems();
    ArrayList portNames = listPorts();

    for (int i = 0; i < portNames.size(); i++) {
        cmbPort.addItem(portNames.get(i));
    }

    cmbBaud.setSelectedIndex(7);

    this.seriesCurrent = new TimeSeries("Time1", Millisecond.class);
    this.seriesCurrentMax = new TimeSeries("Time", Millisecond.class);
    this.seriesCurrentMin = new TimeSeries("Time", Millisecond.class);
    final TimeSeriesCollection dataset = new TimeSeriesCollection(this.seriesCurrent);
    dataset.addSeries(seriesCurrentMax);
    dataset.addSeries(seriesCurrentMin);
    JFreeChart chart = createChartCurrent(dataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    //chartPanel.setPreferredSize(new Dimension(100, 260)); //size according to my window
    chartPanel.setMouseWheelEnabled(true);
    plCurrent.add(chartPanel, BorderLayout.CENTER);
    plCurrent.validate();

    this.seriesVolt = new TimeSeries("Time", Millisecond.class);
    this.seriesVoltMax = new TimeSeries("Time", Millisecond.class);
    this.seriesVoltMin = new TimeSeries("Time", Millisecond.class);
    final TimeSeriesCollection datasetVolt = new TimeSeriesCollection(this.seriesVolt);
    datasetVolt.addSeries(seriesVoltMax);
    datasetVolt.addSeries(seriesVoltMin);
    JFreeChart chartVolt = createChartVolt(datasetVolt);
    ChartPanel chartPanelVolt = new ChartPanel(chartVolt);
    //chartPanelVolt.setPreferredSize(new Dimension(400, 260)); //size according to my window
    chartPanelVolt.setMouseWheelEnabled(true);
    plVoltage.add(chartPanelVolt, BorderLayout.CENTER);
    plVoltage.validate();

    this.seriesWatt = new TimeSeries("Time", Millisecond.class);
    final TimeSeriesCollection datasetWatt = new TimeSeriesCollection(this.seriesWatt);
    JFreeChart chartWatt = createChartWatt(datasetWatt);
    ChartPanel chartPanelWatt = new ChartPanel(chartWatt);
    //chartPanelWatt.setPreferredSize(new Dimension(400, 260)); //size according to my window
    chartPanelWatt.setMouseWheelEnabled(true);
    plWattage.add(chartPanelWatt, BorderLayout.CENTER);
    plWattage.validate();

    this.seriesDm = new TimeSeries("Time", Millisecond.class);
    final TimeSeriesCollection datasetDm = new TimeSeriesCollection(this.seriesDm);
    JFreeChart chartDm = createChartDm(datasetDm);
    ChartPanel chartPanelDm = new ChartPanel(chartDm);
    //chartPanelWatt.setPreferredSize(new Dimension(400, 260)); //size according to my window
    chartPanelDm.setMouseWheelEnabled(true);
    plmWh.add(chartPanelDm, BorderLayout.CENTER);
    plmWh.validate();

    this.seriesDp = new TimeSeries("Time", Millisecond.class);
    final TimeSeriesCollection datasetDp = new TimeSeriesCollection(this.seriesDp);
    JFreeChart chartDp = createChartDp(datasetDp);
    ChartPanel chartPanelDp = new ChartPanel(chartDp);
    //chartPanelWatt.setPreferredSize(new Dimension(400, 260)); //size according to my window
    chartPanelDp.setMouseWheelEnabled(true);
    plmAh.add(chartPanelDp, BorderLayout.CENTER);
    plmAh.validate();

    if (cmbPort.getItemCount() > 0) {
        btnStart.setEnabled(true);
        lblStatus.setText("Select COM Port and Baud Rate.");
    } else
        lblStatus.setText("No serial port found.");

    System.out.println(cmbPort.getItemCount());

    File f = new File(logTmpFile);
    if (f.exists()) {
        int reply = JOptionPane.showConfirmDialog(this, "Data temp file exists, resume? (No deletes file)",
                "Resume?", JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.NO_OPTION) {
            try {
                f.delete();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(this, "Unable to delete");
                JOptionPane.showMessageDialog(this, e);
            }
        }
    } else {
        JOptionPane.showMessageDialog(this, "New session", "Session", JOptionPane.INFORMATION_MESSAGE);
    }
    System.out.println(f.getAbsolutePath());

}

From source file:serial.ChartFromSerial.java

private void pause_jBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pause_jBtnActionPerformed
    if ("Play".equals(pause_jBtn.getText())) {
        while (!chosenPort.openPort()) {
            if (JOptionPane.showConfirmDialog(rootPane,
                    "Error at " + portList_jCombo.getSelectedItem().toString() + "\nWould you like to refresh?",
                    "Trouble connecting to " + portList_jCombo.getSelectedItem().toString(),
                    JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.NO_OPTION) {
                buttonsOff();//from w  ww.j av a 2 s  . c om
                return;
            } else {
                portNames = SerialPort.getCommPorts();
                if (portNames.length > 0) {
                    if (portNames.length >= 1) {
                        Object[] possibilities = new Object[portNames.length];
                        for (int i = 0; i < portNames.length; i++) {
                            possibilities[i] = portNames[i].getSystemPortName();
                        }
                        String s = (String) JOptionPane.showInputDialog(rootPane,
                                "Other ports are available.\nSelect one to continue on that port or cancel to disconnect.",
                                "Another port is available", JOptionPane.PLAIN_MESSAGE, null, possibilities,
                                null);
                        chosenPort.closePort();
                        if (s != null) {
                            chosenPort = SerialPort.getCommPort(s);
                            chosenPort.setComPortTimeouts(SerialPort.TIMEOUT_SCANNER, 0, 0);
                            chosenPort.setBaudRate(
                                    Integer.parseInt(baudRate_jCombo.getSelectedItem().toString()));
                            softRefresh();
                            portList_jCombo.setSelectedItem(s);
                            if (chosenPort.openPort()) {
                                createSerialThread(chosenPort);
                                pause_jBtn.setText("Pause");
                                connect_jBtn.setEnabled(true);
                                return;
                            }
                        } else {
                            buttonsOff();
                            return;
                        }
                    } else {
                        if (JOptionPane.showConfirmDialog(rootPane,
                                portNames[0].getSystemPortName()
                                        + " is available. Would you like to use it instead?",
                                "Another port is available",
                                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                            chosenPort.closePort();
                            chosenPort = SerialPort.getCommPort(portNames[0].getSystemPortName());
                            chosenPort.setComPortTimeouts(SerialPort.TIMEOUT_SCANNER, 0, 0);
                            chosenPort.setBaudRate(
                                    Integer.parseInt(baudRate_jCombo.getSelectedItem().toString()));
                            softRefresh();
                            portList_jCombo.setSelectedItem(portNames[0].getSystemPortName());
                            if (chosenPort.openPort()) {
                                createSerialThread(chosenPort);
                                pause_jBtn.setText("Pause");
                                connect_jBtn.setEnabled(true);
                                return;
                            }
                        } else {
                            buttonsOff();
                            return;
                        }
                    }
                } else {
                    JOptionPane.showMessageDialog(rootPane, "You are currently not connected to any devices.",
                            "No devices found", JOptionPane.INFORMATION_MESSAGE);
                    softRefresh();
                    buttonsOff();
                    return;
                }
            }

        }
        createSerialThread(chosenPort);
        pause_jBtn.setText("Pause");
    } else {
        chosenPort.closePort();
        pause_jBtn.setText("Play");
    }
}

From source file:com.proyecto.vista.MantenimientoAmbiente.java

private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed
    // TODO add your handling code here:
    accion = Controlador.ELIMINAR;//from w w  w  . j  a v  a2s. c  o  m
    if (tblambientes.getSelectedRow() != -1) {

        Integer codigo = tblambientes.getSelectedRow();

        Ambiente ambiente = ambienteControlador.buscarPorId(lista.get(codigo).getCodigo());

        if (ambiente != null) {
            if (JOptionPane.showConfirmDialog(null, "Desea Eliminar la Ambiente?", "Mensaje del Sistema",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                int[] filas = tblambientes.getSelectedRows();
                for (int i = 0; i < filas.length; i++) {
                    Ambiente ambiente2 = lista.get(filas[0]);
                    lista.remove(ambiente2);
                    ambienteControlador.setSeleccionado(ambiente2);
                    ambienteControlador.accion(accion);
                }
                if (ambienteControlador.accion(accion) == 3) {
                    JOptionPane.showMessageDialog(null, "Ambiente eliminada correctamente",
                            "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);

                } else {
                    JOptionPane.showMessageDialog(null, "Ambiente no eliminada", "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(null, "Ambiente no eliminado", "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    } else {
        JOptionPane.showMessageDialog(null, "Debe seleccionar un Ambiente", "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.firmansyah.imam.sewa.kendaraan.FormUser.java

private void btnAktifActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAktifActionPerformed
    String status = btnAktif.getText();
    String id = inputIdUser.getText();

    System.out.println("Memilih ID : " + id);

    if (status.equals("Aktifkan")) {
        status = "1";
    } else {/*from ww  w .j a v  a 2  s . c o m*/
        status = "0";
    }

    int dialogButton = JOptionPane.YES_NO_OPTION;
    int dialogResult;
    dialogResult = JOptionPane.showConfirmDialog(this, "Anda yakin Ingin Mengubah Status User ini? ",
            "Konfirmasi", dialogButton);

    if (dialogResult == 0) {
        String url = Path.serverURL + "/user/status/" + id + "/" + status;

        getDataURL dataurl = new getDataURL();

        try {
            String data = dataurl.getData(url);
            System.out.println(data);

            if (data.equals("1")) {
                JOptionPane.showMessageDialog(this, "Status Berhasil diubah", "Informasi",
                        JOptionPane.INFORMATION_MESSAGE);

                System.out.println("Mengubah Status Data ID : " + id);
            } else {
                JOptionPane.showMessageDialog(this, "Status Tidak Berhasil diubah", "Informasi",
                        JOptionPane.ERROR_MESSAGE);
            }

        } catch (IOException ex) {
            Logger.getLogger(FormUser.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        System.out.println("Tidak Mengubah Status dari ID : " + id);
    }

    // refresh form
    refreshForm();

}

From source file:cellularAutomata.analysis.PricingDistributionAnalysis.java

/**
 * This uses a handy file writing utility to create a file writer.
 *//*w  ww .j  av  a 2 s .co m*/
private void createFileWriter() {
    try {
        // This will prompt the user to enter a file. (The SAVE_DATA_PATH
        // parameter is just the default folder where the file chooser will
        // open.)
        fileWriter = new FileWriter(CurrentProperties.getInstance().getSaveDataFilePath());

        // data delimiters (what string will be used to separate data in the
        // file)
        delimiter = CurrentProperties.getInstance().getDataDelimiters();

        // save a header
        String[] header = new String[data.length];
        header[0] = "Distribution";
        for (int i = 1; i < header.length; i++) {
            header[i] = "Number with state " + i + ":";
        }

        fileWriter.writeData(header, delimiter);

        // save the initial data (at the generation when the user requested
        // that the data be saved)
        if (data != null) {
            fileWriter.writeData(data, delimiter);
        }
    } catch (IOException e) {
        // This happens if the user did not select a valid file. (For
        // example, the user canceled and did not choose any file when
        // prompted.) So uncheck the "file save" box
        if (saveDataCheckBox != null) {
            saveDataCheckBox.setSelected(false);
        }

        // tell the user that they really should have selected a file
        String message = "A valid file was not selected, so the data \n" + "will not be saved.";
        JOptionPane.showMessageDialog(CAController.getCAFrame().getFrame(), message, "Valid file not selected",
                JOptionPane.INFORMATION_MESSAGE);
    }
}

From source file:ru.develgame.jflickrorganizer.MainForm.java

private void jButtonBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBackupActionPerformed
    if (jTextFieldBackupFolder.getText().isEmpty()) {
        JOptionPane.showMessageDialog(this, LocaleMessages.getMessage("MainForm.Warning.BackupFolderEmpty"),
                LocaleMessages.getMessage("WarningTitle"), JOptionPane.WARNING_MESSAGE);

        return;//  w w  w  . j ava  2 s. c o  m
    }

    File backupFolder = new File(jTextFieldBackupFolder.getText());
    if (!backupFolder.exists()) {
        JOptionPane.showMessageDialog(this, LocaleMessages.getMessage("MainForm.Warning.BackupFolderNotExists"),
                LocaleMessages.getMessage("WarningTitle"), JOptionPane.WARNING_MESSAGE);

        return;
    }

    if (!backupFolder.isDirectory()) {
        JOptionPane.showMessageDialog(this,
                LocaleMessages.getMessage("MainForm.Warning.BackupFolderNotDirectory"),
                LocaleMessages.getMessage("WarningTitle"), JOptionPane.WARNING_MESSAGE);

        return;
    }

    try {
        // === Get photo list ===
        GetPhotoListRunnable photoListRunnable = getGetPhotoListRunnable();

        ProgressForm indeterminateProgressForm = new ProgressForm(this, true,
                LocaleMessages.getMessage("ProgressForm.GetPhotosList"), photoListRunnable, true);
        indeterminateProgressForm.setVisible(true);
        indeterminateProgressForm.dispose();

        if (photoListRunnable.getStatus() != Status.STATUS_OK) {
            if (photoListRunnable.getStatus() == Status.STATUS_CANCELED)
                return;

            JOptionPane.showMessageDialog(this,
                    LocaleMessages.getMessage("MainForm.Error.GetPhotoList", photoListRunnable.getError()),
                    LocaleMessages.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);

            return;
        }

        // === Backup photos ===
        BackupRunnable backupRunnable = getBackupRunnable(photoListRunnable.getPhotos(), backupFolder);

        ProgressForm progressForm = new ProgressForm(this, true,
                LocaleMessages.getMessage("ProgressForm.BackupPhotos"), backupRunnable, false);
        progressForm.setVisible(true);
        progressForm.dispose();

        if (backupRunnable.getStatus() != Status.STATUS_OK) {
            if (backupRunnable.getStatus() == Status.STATUS_CANCELED) {
                tablePhotosDataModel.loadData();
                return;
            }

            JOptionPane.showMessageDialog(this,
                    LocaleMessages.getMessage("MainForm.Error.BackupPhotos", backupRunnable.getError()),
                    LocaleMessages.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);

            return;
        }

        // === Backup sets ===            
        BackupSetsRunnable backupSetsRunnable = getBackupSetsRunnable();

        ProgressForm indeterminateProgressFormBackupSets = new ProgressForm(this, true,
                LocaleMessages.getMessage("ProgressForm.BackupSets"), backupSetsRunnable, true);
        indeterminateProgressFormBackupSets.setVisible(true);
        indeterminateProgressFormBackupSets.dispose();

        if (backupSetsRunnable.getStatus() != Status.STATUS_OK) {
            if (backupSetsRunnable.getStatus() == Status.STATUS_CANCELED) {
                treeAlbumsDataModel.loadData();
                jTreeAlbums.setSelectionRow(0);
                tablePhotosDataModel.loadData();
                return;
            }

            JOptionPane.showMessageDialog(this,
                    LocaleMessages.getMessage("MainForm.Error.BackupPhotos", backupSetsRunnable.getError()),
                    LocaleMessages.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);

            return;
        }

        JOptionPane.showMessageDialog(this, LocaleMessages.getMessage("MainForm.Info.BackupPhotos"),
                LocaleMessages.getMessage("InformationTitle"), JOptionPane.INFORMATION_MESSAGE);

        authorizer.getUser().setSyncFolder(jTextFieldBackupFolder.getText());
        userRepository.save(authorizer.getUser());

        treeAlbumsDataModel.loadData();
        jTreeAlbums.setSelectionRow(0);
        tablePhotosDataModel.loadData();
    } catch (InvalidAttributesException ex) {
        JOptionPane.showMessageDialog(this,
                LocaleMessages.getMessage("MainForm.Error.BackupPhotos", ex.getMessage()),
                LocaleMessages.getMessage("ErrorTitle"), JOptionPane.ERROR_MESSAGE);

        return;
    }
}

From source file:com.biosis.biosislite.vistas.inventario.MantenimientoProveedor.java

private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed
    // TODO add your handling code here:
    List<Integer> array = new ArrayList();

    array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.LETRA, this.telefonoField, "telefono"));
    array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.LETRA, this.rucField, "ruc"));
    //        array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.NUMERO, this.direccionField, "direccion"));
    array.add(// w w w  .j ava  2 s . c  o  m
            FormularioUtil.Validar(FormularioUtil.TipoValidacion.NUMERO, this.nombreField, "nombreProveedor"));

    FormularioUtil.validar2(array);

    if (FormularioUtil.error) {
        JOptionPane.showMessageDialog(null, FormularioUtil.mensaje, "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
        FormularioUtil.mensaje = "";
        FormularioUtil.error = false;
    } else {
        String palabra = "";
        String palabra2 = "";
        if (accion == 1) {
            palabra = "registrar";
            palabra2 = "registrado";

            if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Proveedor?",
                    "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                //                    proveedorControlador.getSeleccionado().setDni(idField.getText().toUpperCase());
                proveedorControlador.getSeleccionado().setNombreProveedor(nombreField.getText().toUpperCase());
                proveedorControlador.getSeleccionado().setDireccion(direccionField.getText().toUpperCase());
                proveedorControlador.getSeleccionado().setRuc(rucField.getText().toUpperCase());
                proveedorControlador.getSeleccionado().setTelefono(telefonoField.getText().toUpperCase());

                proveedorControlador.accion(accion);
                lista.add(proveedorControlador.getSeleccionado());

                if (accion == 1) {
                    JOptionPane.showMessageDialog(null, "Proveedor " + palabra2 + " correctamente",
                            "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);
                    FormularioUtil.limpiarComponente(panelDatos);
                } else {
                    JOptionPane.showMessageDialog(null, "Proveedor no " + palabra2, "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                FormularioUtil.limpiarComponente(panelDatos);
                JOptionPane.showMessageDialog(null, "Proveedor no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        } else if (accion == 2) {
            palabra = "modificar";
            palabra2 = "modificado";

            if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Proveedor?",
                    "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                if (accion == 2) {
                    JOptionPane.showMessageDialog(null, "Proveedor " + palabra2 + " correctamente",
                            "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);

                    lista.clear();
                    proveedorControlador.getSeleccionado()
                            .setNombreProveedor(nombreField.getText().toUpperCase());
                    proveedorControlador.getSeleccionado().setDireccion(direccionField.getText().toUpperCase());
                    proveedorControlador.getSeleccionado().setRuc(rucField.getText().toUpperCase());
                    proveedorControlador.getSeleccionado().setTelefono(telefonoField.getText().toUpperCase());

                    proveedorControlador.accion(accion);
                    listar();

                    FormularioUtil.limpiarComponente(panelDatos);

                } else {
                    JOptionPane.showMessageDialog(null, "Proveedor no " + palabra2, "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }
            } else {
                FormularioUtil.limpiarComponente(panelDatos);
                JOptionPane.showMessageDialog(null, "Proveedor no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

        FormularioUtil.limpiarComponente(panelDatos);
        FormularioUtil.activarComponente(panelOpciones, true);
        FormularioUtil.activarComponente(panelGuardar, false);
        FormularioUtil.activarComponente(panelDatos, false);
    }
}

From source file:UserInterface.TMAnalystRole.TMAnaylstWorkAreaJPanel.java

private void btnSimulateDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSimulateDataActionPerformed
    // TODO add your handling code here:
    int days = (int) spnrDays.getValue();

    objSimulation = new SimulationClass();
    Date today = new Date();
    Date olderThanToday = new Date();
    olderThanToday.setTime(today.getTime() + (long) (-days) * 1000 * 60 * 60 * 24);

    for (Train t : enterprise.getTrainCatalog().getTrainsList()) {
        if (t.getLineOnTrain().isIsActive() && t.getLineOnTrain().isHasStarted()) {
            for (int i = 1; i <= days; i++) {
                Date thistoday = new Date();
                thistoday.setTime(olderThanToday.getTime());
                TrainOffered selectedTrainOffered = enterprise.getTrainsOfferedHistory().fetchOrAddTrain(t,
                        thistoday);/*from   www  . j  a va  2s.  co  m*/

                objSimulation.generatePreviousCrowdedData(selectedTrainOffered);

                olderThanToday.setTime(olderThanToday.getTime() + (long) (1) * 1000 * 60 * 60 * 24);
            }
            olderThanToday.setTime(today.getTime() + (long) (-days) * 1000 * 60 * 60 * 24);
        }
    }

    JOptionPane.showMessageDialog(this, "Data generated successfully.", "Simulation",
            JOptionPane.INFORMATION_MESSAGE);
    spnrDays.setValue(1);
}

From source file:com.biosis.biosislite.vistas.inventario.MantenimientoClase.java

private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed
    // TODO add your handling code here:
    accion = AbstractControlador.ELIMINAR;
    if (tblclase.getSelectedRow() != -1) {

        Integer id = tblclase.getSelectedRow();

        //            Clase clase = claseControlador.buscarPorId(lista.get(id).getId());

        if (tblclase.getSelectedRow() != -1) {
            if (JOptionPane.showConfirmDialog(null, "Desea Eliminar la Clase?", "Mensaje del Sistema",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                //                    int[] filas = tblclase.getSelectedRows();
                //                    for (int i = 0; i < filas.length; i++) {
                //                        Clase clase2 = lista.get(filas[0]);
                claseControlador.setSeleccionado(lista.get(id));
                lista.remove(lista.get(id));
                claseControlador.accion(accion);
                //                    }
                if (claseControlador.accion(accion) == 3) {
                    JOptionPane.showMessageDialog(null, "Clase eliminada correctamente", "Mensaje del Sistema",
                            JOptionPane.INFORMATION_MESSAGE);

                } else {
                    JOptionPane.showMessageDialog(null, "Clase no eliminada", "Mensaje del Sistema",
                            JOptionPane.ERROR_MESSAGE);
                }/*from w  ww .  j a va2  s.  c o m*/
            } else {
                JOptionPane.showMessageDialog(null, "Clase no eliminada", "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    } else {
        JOptionPane.showMessageDialog(null, "Debe seleccionar una clase", "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
    }
}