public void addGui(final DownloadDialog gui) {
    buildDownloadAreaInputFields();
    final JPanel dlg = new JPanel(new GridBagLayout());

    tfOsmUrl.getDocument().addDocumentListener(new OsmUrlRefresher());

    // select content on receiving focus. this seems to be the default in the
    // windows look+feel but not for others. needs invokeLater to avoid strange
    // side effects that will cancel out the newly made selection otherwise.
    tfOsmUrl.addFocusListener(new SelectAllOnFocusHandler(tfOsmUrl));
    tfOsmUrl.setLineWrap(true);
    tfOsmUrl.setBorder(latlon[0].getBorder());

    dlg.add(new JLabel(tr("min lat")), GBC.std().insets(10, 20, 5, 0));
    dlg.add(latlon[0], GBC.std().insets(0, 20, 0, 0));
    dlg.add(new JLabel(tr("min lon")), GBC.std().insets(10, 20, 5, 0));
    dlg.add(latlon[1], GBC.eol().insets(0, 20, 0, 0));
    dlg.add(new JLabel(tr("max lat")), GBC.std().insets(10, 0, 5, 0));
    dlg.add(latlon[2], GBC.std());
    dlg.add(new JLabel(tr("max lon")), GBC.std().insets(10, 0, 5, 0));
    dlg.add(latlon[3], GBC.eol());

    dlg.add(
        new JLabel(
            tr("URL from www.openstreetmap.org (you can paste an URL here to download the area)")),
        GBC.eol().insets(10, 20, 5, 0));
    dlg.add(tfOsmUrl, GBC.eop().insets(10, 0, 5, 0).fill());
    tfOsmUrl.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            checkPopup(e);
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            checkPopup(e);
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            checkPopup(e);
          }

          private void checkPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
              OsmUrlPopup popup = new OsmUrlPopup();
              popup.show(tfOsmUrl, e.getX(), e.getY());
            }
          }
        });
    dlg.add(showUrl, GBC.eop().insets(10, 0, 5, 5));
    showUrl.setEditable(false);
    showUrl.setBackground(dlg.getBackground());
    showUrl.addFocusListener(new SelectAllOnFocusHandler(showUrl));

    gui.addDownloadAreaSelector(dlg, tr("Bounding Box"));
    this.parent = gui;
  }
 public void install(JTextArea textArea) {
   textArea.addCaretListener(this);
   textArea.addComponentListener(this);
   textArea.addFocusListener(this);
   textArea.addKeyListener(this);
   textArea.addMouseListener(this);
   textArea.addMouseMotionListener(this);
 }
  @Override
  public void fijarControlador(EventListener controlador) {
    jTFDescripcion.addFocusListener((FocusListener) controlador);
    jTFNombrePersonaje.addFocusListener((FocusListener) controlador);

    jBAceptar.addActionListener((ActionListener) controlador);
    jBCancelar.addActionListener((ActionListener) controlador);
  }
Exemple #4
0
 private JComponent c() {
   JPanel var1 = new JPanel(new BorderLayout());
   JTextArea var2 = new JTextArea();
   a.addHandler(new OGuiLogOutputHandler(var2));
   JScrollPane var3 = new JScrollPane(var2, 22, 30);
   var2.setEditable(false);
   JTextField var4 = new JTextField();
   var4.addActionListener(new OServerGuiCommandListener(this, var4));
   var2.addFocusListener(new OServerGuiFocusAdapter(this));
   var1.add(var3, "Center");
   var1.add(var4, "South");
   var1.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat"));
   return var1;
 }
  private JComponent getLogComponent() throws Exception {
    JPanel jpanel = new JPanel(new BorderLayout());
    final JTextArea jtextarea = new JTextArea();
    final JScrollPane jscrollpane = new JScrollPane(jtextarea, 22, 30);
    jtextarea.setEditable(false);
    jtextarea.setFont(serverGuiFont);
    final JTextField jtextfield = new JTextField();
    jtextfield.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent p_actionPerformed_1_) {
            String s = jtextfield.getText().trim();

            if (s.length() > 0) {
              MinecraftServerGui.this.server.addPendingCommand(s, MinecraftServer.getServer());
            }

            jtextfield.setText("");
          }
        });
    jtextarea.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent p_focusGained_1_) {}
        });
    jpanel.add(jscrollpane, "Center");
    jpanel.add(jtextfield, "South");
    jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat"));
    Thread thread =
        new Thread(
            new Runnable() {
              public void run() {
                String s;

                while ((s = QueueLogAppender.getNextLogEvent("ServerGuiConsole")) != null) {
                  MinecraftServerGui.this.func_164247_a(jtextarea, jscrollpane, s);
                }
              }
            });
    thread.setDaemon(true);
    thread.start();
    return jpanel;
  }
  public prueba() {
    setTitle("Requerimientos");
    setBounds(100, 100, 898, 622);
    setLocationRelativeTo(null);
    getContentPane().setLayout(null);
    setIconImage(new ImageIcon("Imagenes\\Iconito.png").getImage());
    Val = new principalIController();
    DatosIncidentes = new Object[pc.obtenerFilasIncidentes(0, "")][6];

    fecha = new Date();
    formateador = new SimpleDateFormat("yyyy-MM-dd");
    fechaF = formateador.format(fecha);

    Icon crear = new ImageIcon("Imagenes\\paper.png");
    btnCrear = new JButton("Crear", crear);
    btnCrear.setBounds(20, 29, 120, 40);
    btnCrear.addActionListener(this);
    getContentPane().add(btnCrear);

    Icon find = new ImageIcon("Imagenes\\find.png");
    btnConsultar = new JButton("Consultar", find);
    btnConsultar.setBounds(20, 80, 120, 40);
    btnConsultar.addActionListener(this);
    getContentPane().add(btnConsultar);

    panelSostenedor = new JPanel();
    panelSostenedor.setBounds(163, 29, 689, 544);
    getContentPane().add(panelSostenedor);
    panelSostenedor.setLayout(null);

    JTabbedPane pestañas = new JTabbedPane(JTabbedPane.TOP);
    pestañas.setBounds(10, 11, 648, 526);
    panelSostenedor.add(pestañas);

    JPanel panelInfoBasica = new JPanel();
    panelInfoBasica.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    pestañas.addTab("Información básica", null, panelInfoBasica, null);
    panelInfoBasica.setLayout(null);

    JPanel infRequerimiento = new JPanel();
    infRequerimiento.setBorder(
        new TitledBorder(
            null,
            "INFORMACI\u00D3N REQUERIMIENTO",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    infRequerimiento.setBounds(10, 18, 623, 186);
    panelInfoBasica.add(infRequerimiento);
    infRequerimiento.setLayout(null);

    JLabel lblCodigoRequerimiento = new JLabel("C\u00F3digo requerimiento");
    lblCodigoRequerimiento.setBounds(21, 33, 140, 18);
    infRequerimiento.add(lblCodigoRequerimiento);

    txtCodigoRequerimiento = new JTextField();
    txtCodigoRequerimiento.setBounds(21, 58, 101, 25);
    txtCodigoRequerimiento.setEnabled(false);
    txtCodigoRequerimiento.setText(String.valueOf(Val.codigoConsecutivo()));
    infRequerimiento.add(txtCodigoRequerimiento);
    txtCodigoRequerimiento.setColumns(10);

    JLabel lblFechaRequerimiento = new JLabel("Fecha requerimiento");
    lblFechaRequerimiento.setBounds(192, 33, 142, 18);
    infRequerimiento.add(lblFechaRequerimiento);

    txtFechaRequerimiento = new JTextField();
    txtFechaRequerimiento.setBounds(192, 58, 155, 25);
    txtFechaRequerimiento.setText(fechaF);
    txtFechaRequerimiento.setEnabled(false);
    infRequerimiento.add(txtFechaRequerimiento);
    txtFechaRequerimiento.setColumns(10);

    JLabel lblTipoRequerimiento = new JLabel("Tipo requerimiento");
    lblTipoRequerimiento.setBounds(402, 33, 109, 18);
    infRequerimiento.add(lblTipoRequerimiento);

    jcbTipoRequerimiento = new JComboBox();
    jcbTipoRequerimiento.setBounds(402, 58, 101, 25);
    jcbTipoRequerimiento.addActionListener(this);
    infRequerimiento.add(jcbTipoRequerimiento);

    JLabel lblEstado = new JLabel("Estado");
    lblEstado.setBounds(21, 107, 119, 18);
    infRequerimiento.add(lblEstado);

    jcbEstado = new JComboBox();
    jcbEstado.setBounds(21, 132, 101, 25);
    jcbEstado.setEnabled(false);
    infRequerimiento.add(jcbEstado);

    JLabel lblPrioridad = new JLabel("Prioridad");
    lblPrioridad.setBounds(192, 107, 109, 18);
    infRequerimiento.add(lblPrioridad);

    jcbNivelRequerimiento = new JComboBox();
    jcbNivelRequerimiento.setBounds(192, 132, 101, 25);
    infRequerimiento.add(jcbNivelRequerimiento);

    JPanel infCliente = new JPanel();
    infCliente.setBorder(
        new TitledBorder(
            UIManager.getBorder("TitledBorder.border"),
            "INFORMACI\u00D3N CLIENTE",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    infCliente.setBounds(10, 225, 623, 256);
    panelInfoBasica.add(infCliente);
    infCliente.setLayout(null);

    JLabel lblIdentificacin = new JLabel("Identificaci\u00F3n");
    lblIdentificacin.setBounds(20, 30, 101, 18);
    infCliente.add(lblIdentificacin);

    JLabel lblNewLabel = new JLabel("Nombre");
    lblNewLabel.setBounds(172, 30, 77, 18);
    infCliente.add(lblNewLabel);

    JLabel lblCorreElectronico = new JLabel("Corre electr\u00F3nico");
    lblCorreElectronico.setBounds(20, 159, 108, 18);
    infCliente.add(lblCorreElectronico);

    txtIdCliente = new JTextField();
    txtIdCliente.setBounds(20, 55, 108, 25);
    txtIdCliente.addFocusListener(this);
    infCliente.add(txtIdCliente);
    txtIdCliente.setColumns(10);

    txtNombreCliente = new JTextField();
    txtNombreCliente.setBounds(172, 55, 164, 25);
    txtNombreCliente.setEnabled(false);
    infCliente.add(txtNombreCliente);
    txtNombreCliente.setColumns(10);

    txtCorreoCliente = new JTextField();
    txtCorreoCliente.setBounds(20, 187, 177, 25);
    txtCorreoCliente.setEnabled(false);
    infCliente.add(txtCorreoCliente);
    txtCorreoCliente.setColumns(10);

    lblEmpresa = new JLabel("Empresa");
    lblEmpresa.setBounds(386, 96, 101, 18);
    infCliente.add(lblEmpresa);

    JLabel lblTelfono = new JLabel("Tel\u00E9fono");
    lblTelfono.setBounds(20, 96, 89, 18);
    infCliente.add(lblTelfono);

    JLabel lblDireccion = new JLabel("Direcci\u00F3n");
    lblDireccion.setBounds(172, 96, 89, 18);
    infCliente.add(lblDireccion);

    txtDireccionCliente = new JTextField();
    txtDireccionCliente.setBounds(172, 121, 164, 25);
    txtDireccionCliente.setEnabled(false);
    infCliente.add(txtDireccionCliente);
    txtDireccionCliente.setColumns(10);

    txtTelefonoCliente = new JTextField();
    txtTelefonoCliente.setBounds(20, 121, 108, 25);
    txtTelefonoCliente.setEnabled(false);
    infCliente.add(txtTelefonoCliente);
    txtTelefonoCliente.setColumns(10);

    txtEmpresaCliente = new JTextField();
    txtEmpresaCliente.setBounds(386, 121, 163, 25);
    txtEmpresaCliente.setEnabled(false);
    infCliente.add(txtEmpresaCliente);
    txtEmpresaCliente.setColumns(10);

    JLabel lblApellido = new JLabel("Apellidos");
    lblApellido.setBounds(386, 32, 101, 14);
    infCliente.add(lblApellido);

    txtApellidosCliente = new JTextField();
    txtApellidosCliente.setBounds(385, 55, 164, 25);
    txtApellidosCliente.setEnabled(false);
    infCliente.add(txtApellidosCliente);
    txtApellidosCliente.setColumns(10);

    JPanel panelProblemas = new JPanel();
    pestañas.addTab("Problemas", null, panelProblemas, null);
    panelProblemas.setLayout(null);

    JPanel tiposProblemas = new JPanel();
    tiposProblemas.setBorder(
        new TitledBorder(
            null, "TIPOS DE PROBLEMAS", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    tiposProblemas.setBounds(10, 11, 585, 433);
    panelProblemas.add(tiposProblemas);
    tiposProblemas.setLayout(null);

    JPanel problemaTecnico = new JPanel();
    problemaTecnico.setBorder(
        new TitledBorder(
            null, "PROBLEMAS T\u00C9CNICOS", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    problemaTecnico.setBounds(10, 29, 283, 146);
    tiposProblemas.add(problemaTecnico);
    problemaTecnico.setLayout(null);

    chbNoprende = new JCheckBox("No prende");
    chbNoprende.setBounds(12, 30, 100, 20);
    chbNoprende.addActionListener(this);
    problemaTecnico.add(chbNoprende);

    chbReinicia = new JCheckBox("Se reinicia");
    chbReinicia.setBounds(12, 50, 100, 20);
    chbReinicia.addActionListener(this);
    problemaTecnico.add(chbReinicia);

    chbArchivosPerdidos = new JCheckBox("Archivos perdidos");
    chbArchivosPerdidos.setBounds(12, 70, 135, 20);
    chbArchivosPerdidos.addActionListener(this);
    problemaTecnico.add(chbArchivosPerdidos);

    chbBloqueo = new JCheckBox("Bloqueo/Lentitud");
    chbBloqueo.setBounds(12, 90, 150, 20);
    chbBloqueo.addActionListener(this);
    problemaTecnico.add(chbBloqueo);

    chbSinAudio = new JCheckBox("No se oye");
    chbSinAudio.setBounds(12, 110, 150, 20);
    chbSinAudio.addActionListener(this);
    problemaTecnico.add(chbSinAudio);

    chbMensaje = new JCheckBox("Mensaje de error");
    chbMensaje.setBounds(145, 30, 120, 20);
    chbMensaje.addActionListener(this);
    problemaTecnico.add(chbMensaje);

    chbSinRed = new JCheckBox("Conexión de red");
    chbSinRed.setBounds(145, 50, 120, 20);
    chbSinRed.addActionListener(this);
    problemaTecnico.add(chbSinRed);

    chbOtrosTec = new JCheckBox("Otros");
    chbOtrosTec.setBounds(145, 70, 100, 20);
    chbOtrosTec.addActionListener(this);
    problemaTecnico.add(chbOtrosTec);

    JPanel problemaHardware = new JPanel();
    problemaHardware.setBorder(
        new TitledBorder(
            null, "PROBLEMAS HARDWARE", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    problemaHardware.setBounds(303, 29, 272, 146);
    tiposProblemas.add(problemaHardware);
    problemaHardware.setLayout(null);

    chbMonitor = new JCheckBox("Monitor");
    chbMonitor.setBounds(12, 30, 100, 20);
    chbMonitor.addActionListener(this);
    problemaHardware.add(chbMonitor);

    chbMouse = new JCheckBox("Mouse");
    chbMouse.setBounds(12, 50, 100, 20);
    chbMouse.addActionListener(this);
    problemaHardware.add(chbMouse);

    chbTeclado = new JCheckBox("Teclado");
    chbTeclado.setBounds(12, 70, 100, 20);
    chbTeclado.addActionListener(this);
    problemaHardware.add(chbTeclado);

    chbRegulador = new JCheckBox("Regulador");
    chbRegulador.setBounds(12, 90, 100, 20);
    chbRegulador.addActionListener(this);
    problemaHardware.add(chbRegulador);

    chbParlantes = new JCheckBox("Parlantes");
    chbParlantes.setBounds(12, 110, 100, 20);
    chbParlantes.addActionListener(this);
    problemaHardware.add(chbParlantes);

    chbUnidadCdDvd = new JCheckBox("Unidad CD/DVD");
    chbUnidadCdDvd.setBounds(145, 30, 120, 20);
    chbUnidadCdDvd.addActionListener(this);
    problemaHardware.add(chbUnidadCdDvd);

    chbPuertoUsb = new JCheckBox("Puerto USB");
    chbPuertoUsb.setBounds(145, 50, 100, 20);
    chbPuertoUsb.addActionListener(this);
    problemaHardware.add(chbPuertoUsb);

    chbOtroHard = new JCheckBox("Otro");
    chbOtroHard.setBounds(145, 70, 100, 20);
    chbOtroHard.addActionListener(this);
    problemaHardware.add(chbOtroHard);

    JPanel instalacion = new JPanel();
    instalacion.setBorder(
        new TitledBorder(
            null, "INSTALACI\u00D3N SOFTWARE", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    instalacion.setBounds(157, 208, 283, 156);
    tiposProblemas.add(instalacion);
    instalacion.setLayout(null);

    chbAntivirus = new JCheckBox("Antivirus");
    chbAntivirus.setBounds(12, 30, 80, 20);
    chbAntivirus.addActionListener(this);
    instalacion.add(chbAntivirus);

    chbDriver = new JCheckBox("Drivers/Controladores");
    chbDriver.setBounds(12, 50, 150, 20);
    chbDriver.addActionListener(this);
    instalacion.add(chbDriver);

    chbOfice = new JCheckBox("Paquete office");
    chbOfice.setBounds(12, 70, 135, 20);
    chbOfice.addActionListener(this);
    instalacion.add(chbOfice);

    chbTodos = new JCheckBox("Todos los programas");
    chbTodos.setBounds(12, 90, 145, 20);
    chbTodos.addActionListener(this);
    instalacion.add(chbTodos);

    chbOtrosInsta = new JCheckBox("Otros");
    chbOtrosInsta.setBounds(12, 110, 135, 20);
    chbOtrosInsta.addActionListener(this);
    instalacion.add(chbOtrosInsta);

    JPanel panelObservacion = new JPanel();
    pestañas.addTab("Observaciones", null, panelObservacion, null);
    panelObservacion.setLayout(null);

    panelDescripcion = new JPanel();
    panelDescripcion.setBorder(
        new TitledBorder(
            UIManager.getBorder("TitledBorder.border"),
            "DESCRIPCI\u00D3N",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panelDescripcion.setBounds(10, 90, 585, 123);
    panelObservacion.add(panelDescripcion);
    panelDescripcion.setLayout(null);

    txaDescripcion = new JTextArea();
    txaDescripcion.setLineWrap(true);
    txaDescripcion.addFocusListener(this);
    txaDescripcion.setBounds(20, 21, 542, 88);
    panelDescripcion.add(txaDescripcion);

    JPanel panelAsunto = new JPanel();
    panelAsunto.setBorder(
        new TitledBorder(null, "ASUNTO", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelAsunto.setBounds(10, 11, 585, 69);
    panelObservacion.add(panelAsunto);
    panelAsunto.setLayout(null);

    txtAsunto = new JTextField();
    txtAsunto.setBounds(20, 25, 541, 25);
    txtAsunto.addFocusListener(this);
    txtAsunto.setEditable(false);
    panelAsunto.add(txtAsunto);
    txtAsunto.setColumns(10);

    panelObservaciones = new JPanel();
    panelObservaciones.setBorder(
        new TitledBorder(
            null, "OBSERVACIONES", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelObservaciones.setBounds(10, 228, 585, 123);
    panelObservacion.add(panelObservaciones);
    panelObservaciones.setLayout(null);

    txaObservaciones = new JTextArea();
    txaObservaciones.setBounds(20, 21, 542, 88);
    txaObservaciones.addFocusListener(this);
    panelObservaciones.add(txaObservaciones);

    panelSolucion = new JPanel();
    panelSolucion.setBorder(
        new TitledBorder(
            null, "SOLUCI\u00D3N", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelSolucion.setBounds(10, 362, 585, 125);
    panelObservacion.add(panelSolucion);
    panelSolucion.setLayout(null);

    txaSolucion = new JTextArea();
    txaSolucion.setBounds(20, 21, 542, 88);
    txaSolucion.addFocusListener(this);
    panelSolucion.add(txaSolucion);

    panelUsuarios = new JPanel();
    pestañas.addTab("Usuarios", null, panelUsuarios, null);
    panelUsuarios.setLayout(null);

    panelAtendido = new JPanel();
    panelAtendido.setBorder(
        new TitledBorder(null, "ATENDIDO POR", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelAtendido.setBounds(10, 11, 585, 100);
    panelUsuarios.add(panelAtendido);
    panelAtendido.setLayout(null);

    lblIdReceptor = new JLabel("Identificaci\u00F3n");
    lblIdReceptor.setBounds(22, 24, 116, 18);
    panelAtendido.add(lblIdReceptor);

    lblNombreReceptor = new JLabel("Nombre");
    lblNombreReceptor.setBounds(185, 24, 85, 18);
    panelAtendido.add(lblNombreReceptor);

    lblApellidosReceptor = new JLabel("Apellidos");
    lblApellidosReceptor.setBounds(400, 24, 95, 18);
    panelAtendido.add(lblApellidosReceptor);

    txtIdReceptor = new JTextField();
    txtIdReceptor.setBounds(22, 53, 116, 25);
    txtIdReceptor.setText(lSG.getId_Empleado());
    txtIdReceptor.setEnabled(false);
    panelAtendido.add(txtIdReceptor);
    txtIdReceptor.setColumns(10);

    txtNombreReceptor = new JTextField();
    txtNombreReceptor.setBounds(185, 53, 170, 25);
    txtNombreReceptor.setText(lSG.getNombre());
    txtNombreReceptor.setEnabled(false);
    panelAtendido.add(txtNombreReceptor);
    txtNombreReceptor.setColumns(10);

    txtApellidosReceptor = new JTextField();
    txtApellidosReceptor.setBounds(400, 53, 170, 25);
    txtApellidosReceptor.setText(lSG.getApellido());
    txtApellidosReceptor.setEnabled(false);
    panelAtendido.add(txtApellidosReceptor);
    txtApellidosReceptor.setColumns(10);

    panelAsignado = new JPanel();
    panelAsignado.setBorder(
        new TitledBorder(null, "ASIGNADO A", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelAsignado.setBounds(10, 134, 585, 100);
    panelUsuarios.add(panelAsignado);
    panelAsignado.setLayout(null);

    txtIdAsignado = new JTextField();
    txtIdAsignado.setColumns(10);
    txtIdAsignado.setBounds(22, 53, 116, 25);
    txtIdAsignado.setEnabled(false);
    panelAsignado.add(txtIdAsignado);

    lblIdAsignado = new JLabel("Identificaci\u00F3n");
    lblIdAsignado.setBounds(22, 24, 116, 18);
    panelAsignado.add(lblIdAsignado);

    txtNombreAsignado = new JTextField();
    txtNombreAsignado.setColumns(10);
    txtNombreAsignado.setEnabled(false);
    txtNombreAsignado.setBounds(185, 53, 170, 25);
    panelAsignado.add(txtNombreAsignado);

    lblNombreAsignado = new JLabel("Nombre");
    lblNombreAsignado.setBounds(185, 24, 85, 18);
    panelAsignado.add(lblNombreAsignado);

    lblApellidosAsignado = new JLabel("Apellidos");
    lblApellidosAsignado.setBounds(400, 24, 95, 18);
    panelAsignado.add(lblApellidosAsignado);

    txtApellidosAsignado = new JTextField();
    txtApellidosAsignado.setColumns(10);
    txtApellidosAsignado.setEnabled(false);
    txtApellidosAsignado.setBounds(400, 53, 170, 25);
    panelAsignado.add(txtApellidosAsignado);

    panelInfoAdicional = new JPanel();
    panelInfoAdicional.setBorder(
        new TitledBorder(
            null,
            "INFORMACI\u00D3N ADICIONAL",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panelInfoAdicional.setBounds(10, 258, 585, 111);
    panelUsuarios.add(panelInfoAdicional);
    panelInfoAdicional.setLayout(null);

    lblTipoAsistencia = new JLabel("Tipo de asistencia");
    lblTipoAsistencia.setBounds(22, 30, 158, 18);
    panelInfoAdicional.add(lblTipoAsistencia);

    cbxTipoAsistencia = new JComboBox();
    cbxTipoAsistencia.setBounds(22, 59, 158, 25);
    panelInfoAdicional.add(cbxTipoAsistencia);

    lblCalificacion = new JLabel("Calificaci\u00F3n");
    lblCalificacion.setBounds(263, 32, 118, 14);
    panelInfoAdicional.add(lblCalificacion);

    cbxCalificacion = new JComboBox();
    cbxCalificacion.setBounds(263, 59, 135, 25);
    panelInfoAdicional.add(cbxCalificacion);

    panelOperaciones = new JPanel();
    panelOperaciones.setBorder(
        new TitledBorder(null, "OPERACIONES", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelOperaciones.setBounds(10, 396, 585, 80);
    panelUsuarios.add(panelOperaciones);
    panelOperaciones.setLayout(null);

    btnGuardar = new JButton("Guardar");
    btnGuardar.setBounds(335, 30, 89, 25);
    btnGuardar.addActionListener(this);
    panelOperaciones.add(btnGuardar);

    btnBorrarCampos = new JButton("Borrar campos");
    btnBorrarCampos.setBounds(156, 30, 123, 25);
    btnBorrarCampos.addActionListener(this);
    panelOperaciones.add(btnBorrarCampos);

    Val.tipoIncidente(jcbTipoRequerimiento);
    Val.tipoAsistencia(cbxTipoAsistencia);
    Val.calificacion(cbxCalificacion);
    Val.prioridad(jcbNivelRequerimiento);
    Val.estados(jcbEstado);
    Val.bloquarPaneles(
        chbNoprende,
        chbReinicia,
        chbArchivosPerdidos,
        chbBloqueo,
        chbSinAudio,
        chbMensaje,
        chbSinRed,
        chbOtrosTec,
        chbMonitor,
        chbMouse,
        chbTeclado,
        chbRegulador,
        chbParlantes,
        chbUnidadCdDvd,
        chbPuertoUsb,
        chbOtroHard,
        chbAntivirus,
        chbDriver,
        chbOfice,
        chbTodos,
        chbOtrosInsta,
        jcbTipoRequerimiento);

    panelIncidentesHistorial = new JPanel();
    panelIncidentesHistorial.setBounds(163, 29, 709, 527);
    getContentPane().add(panelIncidentesHistorial);
    panelIncidentesHistorial.setLayout(null);
    panelIncidentesHistorial.setVisible(false);

    Dtm =
        new DefaultTableModel(
            DatosIncidentes,
            new String[] {
              "C\u00F3digo incidente",
              "Clave unica",
              "Fecha incidente",
              "Cliente",
              "Prioridad",
              "Estado"
            }) {
          boolean[] columnEditables = new boolean[] {false, false, false, false, false, false};

          public boolean isCellEditable(int row, int column) {
            return columnEditables[column];
          }
        };

    JPanel consultarIncidentes = new JPanel();
    consultarIncidentes.setBorder(
        new TitledBorder(
            null, "CONSULTAR INCIDENTES", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    consultarIncidentes.setBounds(0, 0, 699, 516);
    panelIncidentesHistorial.add(consultarIncidentes);
    consultarIncidentes.setLayout(null);

    panelIncidentes = new JPanel();
    panelIncidentes.setBounds(15, 21, 673, 232);
    consultarIncidentes.add(panelIncidentes);
    panelIncidentes.setBorder(
        new TitledBorder(null, "INCIDENTES", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelIncidentes.setLayout(null);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(15, 30, 641, 183);
    panelIncidentes.add(scrollPane);
    tablaIncidentes = new JTable();
    scrollPane.setViewportView(tablaIncidentes);
    tablaIncidentes.setModel(Dtm);

    JPanel panelHistorial = new JPanel();
    panelHistorial.setBounds(15, 264, 672, 242);
    consultarIncidentes.add(panelHistorial);
    panelHistorial.setBorder(
        new TitledBorder(null, "HISTORIAL", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelHistorial.setLayout(null);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(15, 24, 640, 207);
    panelHistorial.add(scrollPane_1);
    tablaHistorial = new JTable();
    tablaHistorial.setModel(
        new DefaultTableModel(
            new Object[][] {},
            new String[] {
              "Clave unica",
              "Modificaci\u00F3n #",
              "Fecha incidencia",
              "Empleado",
              "Prioridad",
              "Estado"
            }) {
          boolean[] columnEditables = new boolean[] {false, false, false, false, false, false};

          public boolean isCellEditable(int row, int column) {
            return columnEditables[column];
          }
        });
    tablaHistorial.getColumnModel().getColumn(0).setPreferredWidth(96);
    tablaHistorial.getColumnModel().getColumn(1).setPreferredWidth(90);
    tablaHistorial.getColumnModel().getColumn(2).setPreferredWidth(97);
    tablaHistorial.getColumnModel().getColumn(3).setPreferredWidth(205);
    scrollPane_1.setViewportView(tablaHistorial);
    tablaIncidentes.addMouseListener(this);
    tablaIncidentes.getColumnModel().getColumn(0).setPreferredWidth(95);
    tablaIncidentes.getColumnModel().getColumn(2).setPreferredWidth(90);
    tablaIncidentes.getColumnModel().getColumn(3).setPreferredWidth(205);

    Dtm2 =
        new DefaultTableModel(
            DatosIncidentesConsul,
            new String[] {
              "C\u00F3digo incidente",
              "Modificaci\u00F3n #",
              "Fecha incidencia",
              "Empleado",
              "Prioridad",
              "Estado"
            }) {
          boolean[] columnEditables = new boolean[] {false, false, false, false, false, false};

          public boolean isCellEditable(int row, int column) {
            return columnEditables[column];
          }
        };

    setVisible(true);
    // panelSostenedor.setVisible(false);
  }
  private void initComponents() { // GEN-BEGIN:initComponents

    // COMPONENTES DE LA PESTAÑA 1
    jPanel1 = new javax.swing.JPanel();
    PanelP = new javax.swing.JPanel();

    jButton1 = new javax.swing.JButton(); // linea 2
    jButton2 = new javax.swing.JButton();

    jEtiq1 = new javax.swing.JLabel();
    jEtiq2 = new javax.swing.JLabel();
    jEtiq3 = new javax.swing.JLabel();
    jEtiq4 = new javax.swing.JLabel();
    jEtiq5 = new javax.swing.JLabel();

    // Se crea el scroll para el área de texto de los vectores
    vectores = new javax.swing.JTextArea(null, 0, 0);
    help = new javax.swing.JEditorPane();
    help.setEditable(false);

    scroll = new javax.swing.JScrollPane(vectores);
    scroll2 = new javax.swing.JScrollPane(help);

    tvariables = new javax.swing.JTextField();
    texpresion = new javax.swing.JTextField();
    tconstantes = new javax.swing.JTextField();

    TabFolders = new javax.swing.JTabbedPane();

    // COMPONENTES DE LA PESTAÑA 2
    buttonGroup1 = new javax.swing.ButtonGroup();
    buttonGroup2 = new javax.swing.ButtonGroup();
    PanelP = new javax.swing.JPanel();
    Label1 = new javax.swing.JLabel();
    Label2 = new javax.swing.JLabel();
    Label3 = new javax.swing.JLabel();
    tConstantes = new javax.swing.JTextField();
    tVariables = new javax.swing.JTextField();
    tExpresion = new javax.swing.JTextField();
    Panel2 = new javax.swing.JPanel();
    Label4 = new javax.swing.JLabel();
    Etiq = new javax.swing.JLabel();
    Label5 = new javax.swing.JLabel();
    Label6 = new javax.swing.JLabel();
    Label7 = new javax.swing.JLabel();
    rECM = new javax.swing.JRadioButton();
    rKS = new javax.swing.JRadioButton();
    Label8 = new javax.swing.JLabel();
    Label9 = new javax.swing.JLabel();
    Label10 = new javax.swing.JLabel();
    Label11 = new javax.swing.JLabel();
    Label12 = new javax.swing.JLabel();
    Label13 = new javax.swing.JLabel();
    Label14 = new javax.swing.JLabel();
    rAutomatico = new javax.swing.JRadioButton();
    rArchivo = new javax.swing.JRadioButton();
    Label15 = new javax.swing.JLabel();
    Label16 = new javax.swing.JLabel();
    tCruce = new javax.swing.JTextField();
    tMutacion = new javax.swing.JTextField();
    tPoblacion = new javax.swing.JTextField();
    tGeneraciones = new javax.swing.JTextField();
    tEntrada = new javax.swing.JTextField();
    tSalida = new javax.swing.JTextField();
    tValmin = new javax.swing.JTextField();
    tValmax = new javax.swing.JTextField();
    tValarchivo = new javax.swing.JTextField();
    Label17 = new javax.swing.JLabel();
    tErrormin = new javax.swing.JTextField();
    tErrormax = new javax.swing.JTextField();
    tDelta = new javax.swing.JTextField();
    tKS = new javax.swing.JTextField();
    bEvolucion = new javax.swing.JButton();
    barra = new javax.swing.JProgressBar();

    // UBICACION DE LOS COMPONENTES DE LA PRIMERA PESTAÑA
    getContentPane().setLayout(null);
    // getContentPane().setBackground(new java.awt.Color(255,195,140));

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Parámetros de Entrada Para el Simulador");
    setResizable(false);

    jPanel1.setLayout(null);

    jPanel1.setBackground(new java.awt.Color(240, 240, 240));
    jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(100, 100, 100)));
    jEtiq1.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12));
    jEtiq1.setText("Función :");
    jPanel1.add(jEtiq1);
    jEtiq1.setBounds(30, 45, 70, 13);

    jEtiq2.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12));
    jEtiq2.setText("Variables: ");
    jPanel1.add(jEtiq2);
    jEtiq2.setBounds(30, 79, 70, 13);

    jEtiq3.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 11));
    jEtiq3.setText("Constantes: ");
    jPanel1.add(jEtiq3);
    jEtiq3.setBounds(25, 109, 72, 19);

    jEtiq4.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12));
    jEtiq4.setText("  Vectores");
    jPanel1.add(jEtiq4);
    jEtiq4.setBounds(30, 145, 80, 13);

    jEtiq5.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12));
    jEtiq5.setText("  Iniciales:");
    jPanel1.add(jEtiq5);
    jEtiq5.setBounds(30, 165, 80, 13);

    tconstantes.setFont(new java.awt.Font("Arial", 1, 13));
    tconstantes.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    jPanel1.add(tconstantes);
    tconstantes.setBounds(100, 110, 240, 23);
    tconstantes.setText("");

    tvariables.setFont(new java.awt.Font("Arial", 1, 13));
    tvariables.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    jPanel1.add(tvariables);
    tvariables.setBounds(100, 75, 240, 23);
    tvariables.setText("");

    texpresion.setFont(new java.awt.Font("Arial", 1, 11));
    texpresion.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    jPanel1.add(texpresion);
    texpresion.setBounds(100, 40, 240, 23);
    texpresion.setText("");

    vectores.setFont(new java.awt.Font("Arial", 1, 14));
    scroll.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    jPanel1.add(scroll);
    scroll.setBounds(100, 145, 240, 193);
    vectores.setText("");

    // AREA DONDE SE LE MUESTRAN LOS COMENTARIOS DE AYUDA AL USUARIO
    help.setFont(new java.awt.Font("Times New Roman", 2, 13));
    help.setBackground(new java.awt.Color(240, 240, 240));
    help.setBounds(390, 52, 204, 294);
    scroll2.setBackground(new java.awt.Color(240, 240, 240));
    scroll2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    scroll2.setAutoscrolls(true);
    //        scroll2.setCorner(this,1);
    jPanel1.add(scroll2);
    scroll2.setBounds(360, 40, 206, 298);
    letrero_inicial();

    // getContentPane().add(jPanel1);

    // DEFINE LAS DIMENSIONES DEL PANEL: x,y,ancho,altura
    // jPanel1.setBounds(40, 20, 340, 320);

    TabFolders.setBackground(new java.awt.Color(225, 225, 225));
    TabFolders.add(" Parámetros de Entrada ", jPanel1);

    // UBICACION DE LOS COMPONENTES DE LA SEGUNDA PESTAÑA
    // getContentPane().setLayout(null);
    PanelP.setLayout(null);
    PanelP.setBackground(new java.awt.Color(240, 240, 240));
    PanelP.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(100, 100, 100)));

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle(
        "Estimador de parámetros para funciones no lineales por simulación de algoritmos evolutivos");
    setResizable(false);

    Label4.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label4.setText("Probabilidad Cruce:");
    PanelP.add(Label4);
    Label4.setBounds(40, 20, 110, 13);

    Label5.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label5.setText("Probabilidad de mutaci\u00f3n:");
    PanelP.add(Label5);
    Label5.setBounds(40, 50, 130, 13);

    Label6.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label6.setText("Cantidad de poblaci\u00f3n:");
    PanelP.add(Label6);
    Label6.setBounds(40, 80, 120, 13);

    Label7.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label7.setText("N\u00famero de generaciones:");
    PanelP.add(Label7);
    Label7.setBounds(40, 110, 130, 13);

    rECM.setBackground(new java.awt.Color(240, 240, 240));
    rECM.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    rECM.setText("ECM");
    rECM.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            RECMActionPerformed(evt);
          }
        });

    PanelP.add(rECM);
    rECM.setBounds(312, 40, 49, 21);

    rKS.setBackground(new java.awt.Color(240, 240, 240));
    rKS.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    rKS.setText("Kolmogorov - Smirnov");
    rKS.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            RKSActionPerformed(evt);
          }
        });

    PanelP.add(rKS);
    rKS.setBounds(310, 60, 130, 21);

    Label8.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label8.setText("Error m\u00ednimo:");
    PanelP.add(Label8);
    Label8.setBounds(300, 120, 80, 13);

    Label9.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label9.setText("Error m\u00e1ximo:");
    PanelP.add(Label9);
    Label9.setBounds(300, 150, 70, 13);

    Label9.setVisible(false);

    Label10.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label10.setText("Delta de error:");
    PanelP.add(Label10);
    Label10.setBounds(300, 180, 80, 13);

    Label10.setVisible(false);

    Label11.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label11.setText("Porcentaje de puntos (K-S):");
    PanelP.add(Label11);
    Label11.setBounds(300, 150, 130, 13);

    /*Label12.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label12.setText("Archivo de entrada:");
    PanelP.add(Label12);
    Label12.setBounds(40, 140, 92, 13);*/

    Label13.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label13.setText("Archivo de salida:");
    PanelP.add(Label13);
    Label13.setBounds(40, 140, 100, 13);

    Label14.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));
    Label14.setText("Calcular pobaci\u00f3n inicial ");
    PanelP.add(Label14);
    Label14.setBounds(20, 210, 220, 13);

    rAutomatico.setBackground(new java.awt.Color(240, 240, 240));
    rAutomatico.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    rAutomatico.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    rAutomatico.setText("Autom\u00e1ticamente:");
    PanelP.add(rAutomatico);
    rAutomatico.setBounds(50, 230, 130, 21);

    rArchivo.setBackground(new java.awt.Color(240, 240, 240));
    rArchivo.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    rArchivo.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    rArchivo.setText("Valores dados de archivo:");
    PanelP.add(rArchivo);
    rArchivo.setBounds(50, 300, 150, 21);

    Label15.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label15.setText("Valores entre:");
    PanelP.add(Label15);
    Label15.setBounds(60, 260, 80, 13);

    Label16.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    Label16.setText("y");
    PanelP.add(Label16);
    Label16.setBounds(210, 260, 20, 13);

    tCruce.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tCruce.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tCruce);
    tCruce.setBounds(140, 20, 110, 18);
    tCruce.setText("0.5");

    tMutacion.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tMutacion.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tMutacion);
    tMutacion.setBounds(170, 50, 80, 18);
    tMutacion.setText("0.025");

    tPoblacion.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tPoblacion.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tPoblacion);
    tPoblacion.setBounds(160, 80, 90, 18);
    tPoblacion.setText("200");

    tGeneraciones.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tGeneraciones.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tGeneraciones);
    tGeneraciones.setBounds(170, 110, 80, 18);
    tGeneraciones.setText("100");

    tEntrada.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    PanelP.add(tEntrada);
    tEntrada.setBounds(240, 140, 110, 18);
    tEntrada.setText("Entrada.txt");
    tEntrada.setVisible(false);

    tSalida.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tSalida.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tSalida);
    tSalida.setBounds(130, 140, 120, 18);
    tSalida.setText("Salida.txt");

    tValmin.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tValmin.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tValmin);
    tValmin.setBounds(140, 260, 60, 18);
    tValmin.setText("-100.0");

    tValmax.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tValmax.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tValmax);
    tValmax.setBounds(230, 260, 60, 18);
    tValmax.setText("100.0");

    tDelta.setVisible(false);

    tValarchivo.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tValarchivo.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tValarchivo);
    tValarchivo.setBounds(70, 330, 220, 18);
    tValarchivo.setText("dataDefault.txt");

    Label17.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));
    Label17.setText("C\u00e1lculo del error:");
    PanelP.add(Label17);
    Label17.setBounds(300, 20, 100, 13);

    tErrormin.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tErrormin.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tErrormin);
    tErrormin.setBounds(440, 120, 80, 18);
    tErrormin.setText("0.0");

    tErrormax.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tErrormax.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tErrormax);
    tErrormax.setBounds(390, 150, 80, 18);
    tErrormax.setText("0.01");

    tErrormax.setVisible(false);

    tDelta.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    PanelP.add(tDelta);
    tDelta.setBounds(390, 180, 80, 18);
    tDelta.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    tDelta.setText("0.1");

    tKS.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 10));
    tKS.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));
    PanelP.add(tKS);
    tKS.setBounds(440, 150, 80, 18);
    tKS.setText("0.8");

    bEvolucion.setText("Iniciar!");
    bEvolucion.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 20));
    bEvolucion.setBackground(new java.awt.Color(210, 210, 210));
    bEvolucion.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(100, 100, 100)));

    bEvolucion.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            BEvolucionActionPerformed(evt);
          }
        });

    tExpresion.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent e) {
            TExpresionActionPerformed(e);
          }
        });

    PanelP.add(bEvolucion);
    bEvolucion.setBounds(370, 280, 150, 70);

    Etiq.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 10));
    Etiq.setBounds(345, 183, 190, 70);
    Etiq.setText("Evolución de las Generaciones:");
    PanelP.add(Etiq);
    Etiq.setVisible(false);

    barra.setBounds(370, 240, 150, 20);

    barra.setMinimum(0);
    barra.setMaximum(100);
    barra.setVisible(false);
    barra.setBackground(new java.awt.Color(240, 240, 240));
    barra.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
    PanelP.add(barra);

    buttonGroup1.add(rECM);
    buttonGroup1.add(rKS);
    rECM.setSelected(true);
    rECM.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 100, 200)));

    buttonGroup2.add(rArchivo);
    buttonGroup2.add(rAutomatico);
    rAutomatico.setSelected(true);

    TabFolders.setEnabled(true);
    TabFolders.add(" Ejecución de la Simulación ", PanelP);
    TabFolders.setBounds(40, 20, 600, 400);
    getContentPane().add(TabFolders, java.awt.BorderLayout.CENTER);

    // Se adicionan los "escuchadores" de foco a los campos de texto de la primera pestaña

    SymFocus aSymFocus = new SymFocus(this);
    texpresion.addFocusListener(aSymFocus);
    tconstantes.addFocusListener(aSymFocus);
    tvariables.addFocusListener(aSymFocus);
    vectores.addFocusListener(aSymFocus);

    pack();

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 925) / 2, (screenSize.height - 582) / 2, 675, 482);
  }
Exemple #8
0
  private JPanel buildPanel() {
    CellConstraints cc = new CellConstraints();
    FormLayout layout = new FormLayout("fill:0:grow, 3dlu, pref", "p");
    PanelBuilder builder = new PanelBuilder(layout);

    int row = 1;
    for (Note note : d_notes) {
      builder.add(AuxComponentFactory.createNoteView(note, d_editable), cc.xyw(1, row, 3));
      LayoutUtil.addRow(layout);
      row += 2;
    }
    if (d_editable) {
      final ValueModel model = new ValueHolder(DEFAULT_NOTE_TEXT);
      JScrollPane editNote = AuxComponentFactory.createTextArea(model, true);
      final JButton addNoteButton = new JButton(Main.IMAGELOADER.getIcon(FileNames.ICON_NOTE_NEW));
      addNoteButton.setEnabled(false);

      final JTextArea area = (JTextArea) editNote.getViewport().getView();
      area.setBackground(AuxComponentFactory.COLOR_NOTE_EDIT);

      area.getDocument()
          .addDocumentListener(
              new DocumentListener() {
                private void validateComponents() {
                  if (area.getText().equals("") || area.getText().equals(DEFAULT_NOTE_TEXT))
                    addNoteButton.setEnabled(false);
                  else addNoteButton.setEnabled(true);
                }

                public void changedUpdate(DocumentEvent e) {
                  validateComponents();
                }

                public void removeUpdate(DocumentEvent e) {
                  validateComponents();
                }

                public void insertUpdate(DocumentEvent e) {
                  validateComponents();
                }
              });
      area.addFocusListener(
          new FocusListener() {

            public void focusLost(FocusEvent e) {
              if (area.getText().equals("")) {
                area.setText(DEFAULT_NOTE_TEXT);
              }
            }

            public void focusGained(FocusEvent e) {
              if (area.getText().equals(DEFAULT_NOTE_TEXT)) {
                area.setText("");
              }
            }
          });

      builder.add(editNote, cc.xy(1, row));
      builder.add(addNoteButton, cc.xy(3, row));

      addNoteButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              d_notes.add(new Note(Source.MANUAL, (String) model.getValue()));
            }
          });
    }

    return builder.getPanel();
  }
  public BugZillaAssistant(
      ProgressThread thread, final Throwable exception, final XmlRpcClient client)
      throws XmlRpcException {
    super("send_bugreport", true, new Object[] {});
    rpcClient = client;
    thread.getProgressListener().setCompleted(35);
    if (thread.isCancelled()) {
      return;
    }
    // gather information to fill out combo boxes
    Object[] compVals, severityVals, platformVals, osVals;
    // components
    Map<String, String> valQueryMap = new HashMap<String, String>();
    valQueryMap.put("field", "component");
    valQueryMap.put("product_id", "2");
    Map resultMap = (Map) rpcClient.execute("Bug.legal_values", new Object[] {valQueryMap});
    compVals = (Object[]) resultMap.get("values");
    thread.getProgressListener().setCompleted(50);
    if (thread.isCancelled()) {
      return;
    }
    // severity
    valQueryMap = new HashMap<String, String>();
    valQueryMap.put("field", "severity");
    valQueryMap.put("product_id", "2");
    resultMap = (Map) rpcClient.execute("Bug.legal_values", new Object[] {valQueryMap});
    severityVals = (Object[]) resultMap.get("values");
    thread.getProgressListener().setCompleted(65);
    if (thread.isCancelled()) {
      return;
    }
    // platform
    valQueryMap = new HashMap<String, String>();
    valQueryMap.put("field", "platform");
    valQueryMap.put("product_id", "2");
    resultMap = (Map) rpcClient.execute("Bug.legal_values", new Object[] {valQueryMap});
    platformVals = (Object[]) resultMap.get("values");
    thread.getProgressListener().setCompleted(80);
    if (thread.isCancelled()) {
      return;
    }
    // operating system
    valQueryMap = new HashMap<String, String>();
    valQueryMap.put("field", "op_sys");
    valQueryMap.put("product_id", "2");
    resultMap = (Map) rpcClient.execute("Bug.legal_values", new Object[] {valQueryMap});
    osVals = (Object[]) resultMap.get("values");
    thread.getProgressListener().setCompleted(95);
    if (thread.isCancelled()) {
      return;
    }

    Collection<AbstractButton> buttons = new LinkedList<AbstractButton>();

    final JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    final JPanel loginPanel = new JPanel();
    loginPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(GAP, 0, 0, GAP);

    JLabel loginLabel =
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_e_mail.label"));
    loginPanel.add(loginLabel, gbc);

    final JTextField loginName = new JTextField(15);
    loginName.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_e_mail.tip"));
    gbc.gridx = 1;
    gbc.weightx = 1;
    loginPanel.add(loginName, gbc);

    JLabel passwordLabel =
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_password.label"));
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 0;
    loginPanel.add(passwordLabel, gbc);

    final JPasswordField loginPassword = new JPasswordField(15);
    loginPassword.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_password.tip"));
    gbc.gridx = 1;
    gbc.weightx = 1;
    loginPanel.add(loginPassword, gbc);

    final JCheckBox useAnonymousLogin = new JCheckBox();
    useAnonymousLogin.setText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_as_anonymous.label"));
    useAnonymousLogin.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_as_anonymous.tip"));
    useAnonymousLogin.setSelected(false);
    useAnonymousLogin.setAlignmentX(Component.LEFT_ALIGNMENT);
    useAnonymousLogin.setMinimumSize(useAnonymousLogin.getPreferredSize());
    useAnonymousLogin.addItemListener(
        new ItemListener() {

          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              loginName.setEditable(false);
              loginPassword.setEditable(false);
            } else {
              loginName.setEditable(true);
              loginPassword.setEditable(true);
            }
          }
        });
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.weightx = 0;
    loginPanel.add(useAnonymousLogin, gbc);

    gbc.gridwidth = 2;
    gbc.weightx = 1;
    gbc.gridy = 3;
    gbc.insets = new Insets(GAP * 2, 0, GAP, 0);
    loginPanel.add(new JSeparator(), gbc);
    panel.add(loginPanel);

    final JPanel detailPanel = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(GAP, 0, 0, GAP);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.anchor = GridBagConstraints.WEST;
    c.weighty = 0;
    detailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".component.label") + ":"), c);

    c.gridx = 1;
    c.gridy = 0;
    final JComboBox compBox = new JComboBox(compVals);
    compBox.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".component.tip"));
    compBox.setSelectedItem("Vega: Processes, data flow  and meta data");
    detailPanel.add(compBox, c);

    c.gridx = 2;
    c.gridy = 0;
    detailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".severity.label") + ":"), c);

    c.gridx = 3;
    c.gridy = 0;
    final JComboBox severityBox = new JComboBox(severityVals);
    severityBox.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".severity.tip"));
    severityBox.setSelectedItem("normal");
    detailPanel.add(severityBox, c);

    c.gridx = 0;
    c.gridy = 1;
    detailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".platform.label") + ":"), c);

    c.gridx = 1;
    c.gridy = 1;
    final JComboBox platformBox = new JComboBox(platformVals);
    platformBox.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".platform.tip"));
    detailPanel.add(platformBox, c);

    c.gridx = 2;
    c.gridy = 1;
    detailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".os.label") + ":"), c);

    c.gridx = 3;
    c.gridy = 1;
    final JComboBox osBox = new JComboBox(osVals);
    osBox.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".os.tip"));
    String os = System.getProperty("os.name");
    if (os.toLowerCase(Locale.ENGLISH).contains("windows")) {
      osBox.setSelectedItem("Windows");
      platformBox.setSelectedItem("PC");
    } else if (os.toLowerCase(Locale.ENGLISH).contains("linux")) {
      osBox.setSelectedItem("Linux");
      platformBox.setSelectedItem("PC");
    } else if (os.toLowerCase(Locale.ENGLISH).contains("mac")) {
      osBox.setSelectedItem("Mac OS");
      platformBox.setSelectedItem("Macintosh");
    } else {
      osBox.setSelectedItem("Other");
      platformBox.setSelectedItem("Other");
    }
    detailPanel.add(osBox, c);

    c.gridx = 4;
    c.gridy = 0;
    c.weightx = 1;
    detailPanel.add(new JLabel(), c);

    c.gridy = 1;
    detailPanel.add(new JLabel(), c);

    c.gridwidth = 5;
    c.gridx = 0;
    c.gridy = 2;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(GAP * 2, 0, GAP, 0);
    detailPanel.add(new JSeparator(), c);
    panel.add(detailPanel);

    final JPanel mailPanel = new JPanel(new GridBagLayout());
    c = new GridBagConstraints();

    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(GAP, 0, 0, GAP);
    c.weighty = 0;
    c.weightx = 0;
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;
    final JCheckBox addProcessCheckBox = new JCheckBox();
    addProcessCheckBox.setText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".add_process_xml.label"));
    addProcessCheckBox.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".add_process_xml.tip"));
    addProcessCheckBox.setSelected(true);
    addProcessCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    addProcessCheckBox.setMinimumSize(addProcessCheckBox.getPreferredSize());
    mailPanel.add(addProcessCheckBox, c);

    c.gridx = 1;
    final JCheckBox addSysPropsCheckBox = new JCheckBox();
    addSysPropsCheckBox.setText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".add_system_props.label"));
    addSysPropsCheckBox.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".add_system_props.tip"));
    addSysPropsCheckBox.setSelected(true);
    addSysPropsCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    addSysPropsCheckBox.setMinimumSize(addSysPropsCheckBox.getPreferredSize());
    mailPanel.add(addSysPropsCheckBox, c);

    c.gridx = 2;
    c.weightx = 0.75;
    mailPanel.add(new JLabel(), c);

    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 1;
    mailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".summary.label") + ":"), c);

    final JTextField summaryField = new JTextField(15);
    summaryField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".summary.tip"));
    c.gridy = 2;
    mailPanel.add(summaryField, c);

    c.gridy = 3;
    mailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".description.label") + ":"), c);

    descriptionField.setLineWrap(true);
    descriptionField.setWrapStyleWord(true);
    descriptionField.addFocusListener(
        new FocusAdapter() {

          @Override
          public void focusGained(FocusEvent e) {
            if (descriptionField.getText().equals(descriptionText)) {
              descriptionField.setText("");
              descriptionField.removeFocusListener(this);
            }
          }
        });
    descriptionField.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".description.tip"));
    JScrollPane descriptionPane = new ExtendedJScrollPane(descriptionField);
    descriptionPane.setBorder(createBorder());
    descriptionPane.setPreferredSize(new Dimension(400, 400));
    c.gridy = 4;
    c.weighty = 1;
    mailPanel.add(descriptionPane, c);

    c.insets = new Insets(GAP, 0, 0, 0);
    c.gridx = 3;
    c.gridy = 0;
    c.gridheight = 5;
    c.weightx = 0.25;
    c.weighty = 1;
    attachments.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane attachmentPane = new JScrollPane(attachments);
    attachmentPane.setBorder(createBorder());
    attachmentPane.setPreferredSize(new Dimension(150, 400));
    mailPanel.add(attachmentPane, c);
    panel.add(mailPanel);

    buttons.add(
        new JButton(
            new ResourceAction("send_bugreport.add_file") {
              private static final long serialVersionUID = 5152169309271935854L;

              @Override
              public void actionPerformed(ActionEvent e) {
                File file = SwingTools.chooseFile(null, null, true, null, null);
                if (file != null) {
                  ((DefaultListModel) attachments.getModel()).addElement(file);
                }
              }
            }));
    buttons.add(
        new JButton(
            new ResourceAction("send_bugreport.remove_file") {
              private static final long serialVersionUID = 5353693430346577972L;

              public void actionPerformed(ActionEvent e) {
                if (attachments.getSelectedIndex() >= 0) {
                  ((DefaultListModel) attachments.getModel())
                      .remove(attachments.getSelectedIndex());
                }
              }
            }));
    JButton infoButton =
        new JButton(
            new ResourceAction("send_bugreport.info") {
              private static final long serialVersionUID = 2135052418891516027L;

              @Override
              public void actionPerformed(ActionEvent e) {
                BugReportViewerDialog dialog = new BugReportViewerDialog();
                dialog.setInfoText(
                    BugReport.createCompleteBugDescription(
                        descriptionField.getText().trim(),
                        exception,
                        addProcessCheckBox.isSelected(),
                        addSysPropsCheckBox.isSelected()));
                dialog.setVisible(true);
              }
            });
    buttons.add(infoButton);

    submitButton =
        new JButton(
            new ResourceAction("send_bugreport.submit") {
              private static final long serialVersionUID = -4559762951458936715L;

              @Override
              public void actionPerformed(ActionEvent e) {

                // check fields
                email = loginName.getText().trim();
                pawo = loginPassword.getPassword();
                String summary = summaryField.getText().trim();
                String description = descriptionField.getText().trim();
                final String version = RapidMiner.getShortVersion();
                if (!useAnonymousLogin.isSelected()) {
                  if (email.length() <= 0) {
                    SwingTools.showVerySimpleErrorMessage("enter_email");
                    return;
                  }
                  if (!email.matches("(.+?)@(.+?)[.](.+?)")) {
                    SwingTools.showVerySimpleErrorMessage("enter_correct_email");
                    return;
                  }
                  boolean noPW = true;
                  for (char c : pawo) {
                    if (c != ' ') {
                      noPW = false;
                      break;
                    }
                  }
                  if (noPW) {
                    SwingTools.showVerySimpleErrorMessage("enter_password");
                    return;
                  }
                } else {
                  email = "*****@*****.**";
                  pawo =
                      new char[] {
                        '!', 'z', '4', '8', '#', 'H', 'c', '2', '$', '%', 'm', ')', '9', '+', '*',
                        '*'
                      };
                }
                if (summary.length() <= 0) {
                  SwingTools.showVerySimpleErrorMessage("enter_summary");
                  return;
                }
                // more than a single word for a descriptive summary required!
                String[] splitResult = summary.trim().split("\\s");
                if (splitResult.length < 2) {
                  SwingTools.showVerySimpleErrorMessage("enter_descriptive_summary");
                  return;
                }
                if (description.length() <= 0 || description.equals(descriptionText)) {
                  SwingTools.showVerySimpleErrorMessage("enter_description");
                  return;
                }

                // all checks passed, bug report would be created right now, however we want the
                // user
                // to check his browser for similar/duplicate bugs by opening the bugzilla search
                // page with
                // given parameters
                try {
                  if (Desktop.isDesktopSupported()) {
                    Desktop desktop = Desktop.getDesktop();
                    if (desktop.isSupported(Desktop.Action.BROWSE)) {
                      String bugzillaSearchString =
                          "http://bugs.rapid-i.com/buglist.cgi?field0-0-0=attach_data.thedata&type0-0-1=allwordssubstr&field0-0-1=longdesc&query_format=advanced&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&value0-0-1="
                              + exception.getMessage()
                              + "&type0-0-0=allwordssubstr&value0-0-0="
                              + exception.getMessage();
                      URL bugzillaURL = new URL(bugzillaSearchString);
                      URI bugzillaURI =
                          new URI(
                              bugzillaURL.getProtocol(),
                              bugzillaURL.getHost(),
                              bugzillaURL.getPath(),
                              bugzillaURL.getQuery(),
                              null);
                      desktop.browse(bugzillaURI);
                      int returnVal =
                          SwingTools.showConfirmDialog(
                              "send_bugreport.check_browser_for_duplicates",
                              ConfirmDialog.YES_NO_OPTION);
                      // user clicked no, don't submit
                      if (returnVal == ConfirmDialog.NO_OPTION) {
                        return;
                      }
                    }
                  }
                } catch (URISyntaxException e1) {
                  // should not occur (famous last comment)
                } catch (IOException e1) {
                  // we can't change it, so ignore it
                }

                // create bugreport in own progess thread (cancel not allowed)
                submitButton.setEnabled(false);
                new ProgressThread("send_report_to_bugzilla", false) {

                  @Override
                  public void run() {
                    try {
                      getProgressListener().setTotal(100);
                      ListModel model = attachments.getModel();
                      File[] attachments = new File[model.getSize()];
                      for (int i = 0; i < attachments.length; i++) {
                        attachments[i] = (File) model.getElementAt(i);
                      }
                      getProgressListener().setCompleted(20);

                      XmlRpcClient client =
                          XmlRpcHandler.login(XmlRpcHandler.BUGZILLA_URL, email, pawo);
                      getProgressListener().setCompleted(40);

                      BugReport.createBugZillaReport(
                          client,
                          exception,
                          summaryField.getText().trim(),
                          descriptionField.getText().trim(),
                          String.valueOf(compBox.getSelectedItem()),
                          version,
                          String.valueOf(severityBox.getSelectedItem()),
                          String.valueOf(platformBox.getSelectedItem()),
                          String.valueOf(osBox.getSelectedItem()),
                          RapidMinerGUI.getMainFrame().getProcess(),
                          RapidMinerGUI.getMainFrame().getMessageViewer().getLogMessage(),
                          attachments,
                          addProcessCheckBox.isSelected(),
                          addSysPropsCheckBox.isSelected());

                      getProgressListener().setCompleted(100);
                      SwingTools.showMessageDialog("bugreport_successful");
                      dispose();
                    } catch (XmlRpcException e1) {
                      SwingTools.showVerySimpleErrorMessage(
                          "bugreport_xmlrpc_error", e1.getLocalizedMessage());
                    } catch (Exception e2) {
                      LogService.getRoot().warning(e2.getLocalizedMessage());
                      SwingTools.showVerySimpleErrorMessage("bugreport_creation_failed");
                    } finally {
                      getProgressListener().complete();
                      for (int i = 0; i < pawo.length; i++) {
                        pawo[i] = 0;
                      }
                      submitButton.setEnabled(true);
                    }
                  }
                }.start();
              }
            });
    buttons.add(submitButton);
    buttons.add(makeCancelButton());

    layoutDefault(panel, LARGE, buttons);
  }
  // Constructor
  JavaTerm() {
    int ii;
    JMenu menu;
    JMenuBar menuBar;

    // Load in the port number from the last time we ran
    try {
      // try opening the file JavaTerm.pref
      DataInputStream prefs = new DataInputStream(new FileInputStream(m_PrefsFileName));
      // Read in serial port index
      m_PortIndex = prefs.readInt();
      m_IsNative = prefs.readBoolean();
      // check to make sure the value we read is valid
      if (m_PortIndex < 0 || m_PortIndex >= m_PortMenuItem.length) {
        throw new IOException(m_PrefsFileName + " is corrupt");
      }
      // init the serial port
      initSerialPort();
    }
    // We'll get here if the file doesn't exist because it's the first time running this program,
    // it can't be found / opened, or the requested serial port can't be opened
    catch (IOException e) {
      System.out.println(
          "preferences file 'JavaTerm.pref' not found / didn't open or there was a problem opening serial port.  Searching for serial port");

      // Open the first available serial port.
      // This code can be adapted to provide a list of available serial ports.
      find_open_serial_port:
      for (ii = 0; ii < m_PortMenuItem.length; ii++) {
        try {
          m_PortIndex = ii + 1; // This is the serial port we want to open
          initSerialPort(); // Try opening this serial port.  Throws exception if there's a problem
          System.out.println("Opening serial port Comm" + m_PortIndex);
          break find_open_serial_port; // If we haven't thrown an exception, we're done
        } catch (IOException ee) { // wind up here if initSerialPort() above has a problem
          if (ii == m_PortMenuItem.length - 1) {
            System.out.println("Couldn't open any serial ports");
            System.exit(0); // can't open any serial ports.
          }
        }
      }
    }

    // new our window frame
    m_Frame = new JFrame("Javaterm");

    // set frame parameters

    // add the menu.
    menuBar = new JMenuBar();
    menu = new JMenu("Sitting");
    file_elem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int choice = fileopener.showOpenDialog(null);
            if (choice == JFileChooser.APPROVE_OPTION) {
              File myfile = fileopener.getSelectedFile();

              //     File_out=new FileOutputStream(myFile);
              //   Data_out=new DataOutputStream(File_out);
              try { // myfile.getCanonicalPath(myfile);
                //     Bread=new BufferedReader(new FileReader(myfile));
                FileInputStream File_in = new FileInputStream(myfile);
                DataInputStream Data_in = new DataInputStream(File_in);
                m_TextOutput.setText(" ");
                byte ch[] = new byte[50000];
                int ii = 0;
                while (ii != -1) {
                  ii = Data_in.read(ch);
                  try { //    if(str!=-1)
                    for (int j = 0; j < ii; j++) {
                      m_SerialPort.writeByte(ch[j]);
                      Thread.sleep(18);
                    }

                    Thread.sleep(0);
                  } catch (InterruptedException ex) {
                    Data_in.close();
                    File_in.close();
                    m_TextOutput.append("\nFile Sent !");
                    ex.printStackTrace();
                  }
                }
                m_TextOutput.append("\nFile Sent !");

              } catch (IOException ex) {

                m_TextOutput.append("\nFile Sent !");
                // ex.printStackTrace();
              }
            }
          }
        });
    menu.add(file_elem);
    for (ii = 0; ii < m_PortMenuItem.length; ii++) {
      menu.add(m_PortMenuItem[ii] = new JCheckBoxMenuItem("Com " + (ii + 1), false));
      m_PortMenuItem[ii].addItemListener(this);
    }
    m_PortMenuItem[m_PortIndex - 1].setState(true);

    menuBar.add(menu);

    menu = new JMenu("Clear");
    menu.add(m_ClearMenuItem);
    m_ClearMenuItem.addActionListener(this);
    menuBar.add(menu);

    m_Frame.setJMenuBar(menuBar);
    cp = m_Frame.getContentPane();

    cp.setLayout(new FlowLayout());
    cp.add(OutputLabel);
    m_TextOutput = new JTextArea(10, 40);
    TextOutputSc =
        new JScrollPane(
            m_TextOutput,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    cp.add(TextOutputSc);
    // create where the text areas goes
    cp.add(inputLabel);
    m_TextInput = new JTextArea(10, 40);
    TextInputSc =
        new JScrollPane(
            m_TextInput,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    m_TextInput.setEditable(false);
    cp.add(TextInputSc);

    // position the text areas
    //        updateWindowComponents();

    // When a key is pressed, send that keystroke to the serial port
    m_TextOutput.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            //     System.out.println("You Typed a character ");
            byte tempByte = (byte) e.getKeyChar();
            m_SerialPort.writeByte(tempByte); // <-- Here's where the data gets written
            // DONT use writeChar().  It's a two byte char
            // and has screwey results.

            // HACKISH:  Need to add newline to carriage returns for proper operation
            // You may not need this.
            if (tempByte == '\r') {
              m_SerialPort.writeByte((byte) '\n');
            }
          }
        });

    // Make sure the focus stays on the output window.  If input pane gets focus, set focus back to
    // output pane
    m_TextInput.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent e) {
            m_TextOutput.requestFocus();
          }
        });

    // If user clicks close box, exit this program
    m_Frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            // Write the current serial port to disk
            writePrefs();
            System.exit(0);
          }
        });

    // If user resizes the window, need to reposition the text areas.
    m_Frame.addComponentListener(
        new ComponentAdapter() {
          public void componentResized(ComponentEvent e) {
            updateWindowComponents();
          }
        });
    savebutt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            File myfile = new File(nameFiled.getText());
            FileOutputStream File_out;
            try {
              File_out = new FileOutputStream(myfile);
              DataOutputStream Data_out = new DataOutputStream(File_out);
              BufferedWriter myWrit = new BufferedWriter(new FileWriter(myfile));
              myWrit.write(inputString);
              myWrit.flush();
              myWrit.close();
              Data_out.close();
              File_out.close();
            } catch (IOException ex) {
              ex.printStackTrace();
            }
          }
        });

    nameFiled.setText("rec.txt");
    cp.add(namelabel);
    cp.add(nameFiled);
    cp.add(savebutt);

    m_Frame.setSize(500, 600);
    m_Frame.setLocation(100, 100);
    m_Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    m_Frame.setVisible(true);

    // Infinite loop.  WindowListener above will break us out of loop with call to System.exit(0);
    for (; true; ) {
      // Get any pending characters from serial port.
      // Returns empty string if there's nothing to read.
      // This is in contrast to readByte() which patiently waits for data.

      if (m_SerialPort != null) {
        inputString += m_SerialPort.readString();
      }

      try {
        Thread.sleep(10);
      } catch (InterruptedException e) {
      }
    }
  }
Exemple #11
0
  private void addingListeners() {
    input.addFocusListener(
        new FocusListener() {
          @Override
          public void focusLost(FocusEvent arg0) {
            if (input.getText().isEmpty()) refresh();
          }

          @Override
          public void focusGained(FocusEvent arg0) {
            if (input.getText().equals("No files found..")) input.setText("");
          }
        });
    ofBtn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            try {
              File mrgdir = new File("merge");
              if (!mrgdir.exists()) mrgdir.mkdirs();
              Desktop.getDesktop().open(mrgdir);
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        });
    nsBtn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            Step4SizeMatcher.main(null);
            dispose();
          }
        });
    rBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            refresh();
          }
        });
    sBtn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            if (started == false) {
              if (JOptionPane.showOptionDialog(
                      null,
                      "Do you really want to start process?\nIt will OVERWRITE all the merged files you have already done.\nContinue?",
                      "Starting?",
                      JOptionPane.YES_NO_OPTION,
                      JOptionPane.QUESTION_MESSAGE,
                      null,
                      null,
                      null)
                  == JOptionPane.YES_OPTION) {
                log.setText("");
                mergerThread =
                    new MergerThread(
                        input.getText().split("\n"),
                        new ActionListener() {
                          @Override
                          public void actionPerformed(ActionEvent arg0) {
                            mergerThread = null;
                            input.setEnabled(true);
                            rBtn.setEnabled(true);
                            nsBtn.setEnabled(true);
                            started = false;
                            sBtn.setText("Start");
                          }
                        });
                mergerThread.start();
                input.setEnabled(false);
                rBtn.setEnabled(false);
                nsBtn.setEnabled(false);
                started = true;
                sBtn.setText("Stop");
              }
            } else {
              if (JOptionPane.showOptionDialog(
                      null,
                      "Do you really want to stop process?",
                      "Quit?",
                      JOptionPane.YES_NO_OPTION,
                      JOptionPane.QUESTION_MESSAGE,
                      null,
                      null,
                      null)
                  == JOptionPane.YES_OPTION) {
                PrintStream pw = mergerThread.getPS();
                if (pw != null)
                  synchronized (pw) {
                    pw.close();
                  }
                Scanner sc = mergerThread.getScanner();
                if (sc != null)
                  synchronized (sc) {
                    sc.close();
                  }
                pw = mergerThread.getCurFilePS();
                if (pw != null)
                  synchronized (pw) {
                    pw.close();
                  }
                mergerThread.stop();
                mergerThread = null;
                input.setEnabled(true);
                rBtn.setEnabled(true);
                nsBtn.setEnabled(true);
                started = false;
                sBtn.setText("Start");
              }
            }
          }
        });
  }