public static boolean openPortSettingsDialog(
     SerialPortConnection port, String title, String message) {
   port.closeConnection();
   JOptionPane optionPane = new JOptionPane();
   PanelSerialConfig configPanel = new PanelSerialConfig(port);
   Object msg[] = {message, configPanel};
   optionPane.setMessage(msg);
   optionPane.setMessageType(JOptionPane.QUESTION_MESSAGE);
   optionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
   JDialog dialog = optionPane.createDialog(null, title);
   dialog.setVisible(true);
   Object value = optionPane.getValue();
   if (value == null || !(value instanceof Integer)) {
     System.out.println("Closed");
   } else {
     int i = ((Integer) value).intValue();
     if (i == JOptionPane.OK_OPTION) {
       try {
         port.getParameters().save();
         // setCommPort(getPort().getParameters().getPortName());
       } catch (Exception ex) {
         ex.printStackTrace();
       }
       // re-open the port
       port.reOpenConnection();
       // System.out.println("OKAY - value is: " + optionPane.getInputValue());
     } else {
       return false;
     }
   }
   return true;
 }
    private String showTextEditDialog(
        final String dialogTitle,
        JTable table,
        final int row,
        final int width,
        final int height,
        final String textToEdit) {

      // This panel holds the only edit control
      BuscadorProductosController controller = new BuscadorProductosController();
      BuscadorProductosView panel = controller.getView();

      // Use JOptionPane for a pane-less (ha!) way to create a
      // dialog in just a few lines. Also get system L&F.
      JOptionPane optPane = new JOptionPane();
      optPane.setMessage(panel);
      optPane.setMessageType(JOptionPane.PLAIN_MESSAGE);
      optPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
      JDialog dialog = optPane.createDialog(fc.getView(), dialogTitle);
      // This resizable setting is critical;
      // by default the dialog is quite small
      dialog.setResizable(true);

      // Show it already!
      dialog.setVisible(true);

      // Get the value and decide if it was "OK"
      Object selectedValue = optPane.getValue();
      int n = -1;
      if (selectedValue != null && selectedValue instanceof Integer)
        n = ((Integer) selectedValue).intValue();
      String result = null;
      if (n == JOptionPane.OK_OPTION) {
        result = controller.getCodigoSeleccionado();
        table.setValueAt(controller.getDescripcionSeleccionado(), row, 2);
        table.setValueAt(controller.getPrecioUnitario(), row, 4);
      }

      // Might be good text, might be null
      return result;
    }