Example usage for javax.swing JDialog dispose

List of usage examples for javax.swing JDialog dispose

Introduction

In this page you can find the example usage for javax.swing JDialog dispose.

Prototype

public void dispose() 

Source Link

Document

Releases all of the native screen resources used by this Window , its subcomponents, and all of its owned children.

Usage

From source file:interfaces.InterfazPrincipal.java

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
    String nombreCliente = nombreClienteReporteCliente.getText();
    String identificacion = identificacionClienteCliente.getText();
    try {/*  w ww  . jav  a  2  s  . com*/
        //08-11-2014 listar clientes por nombre
        ControladorCliente controladorCliente = new ControladorCliente();
        ArrayList<Cliente> listaClientes = new ArrayList<Cliente>();

        if (nombreCliente.equals("") && identificacion.equals("")) {
            listaClientes = controladorCliente.obtenerClientes();
        } else {
            int identificacionNumerico = 0;
            if (!identificacion.equals("")) {
                identificacionNumerico = Integer.parseInt(identificacion);
            }
            listaClientes = controladorCliente.obtenerClientes(nombreCliente, identificacionNumerico);
        }

        //08-11-2014 Crear dialogo de bsqueda
        final JDialog dialogoEditar = new JDialog(this);

        dialogoEditar.setTitle("Buscar clientes");
        dialogoEditar.setSize(300, 300);
        dialogoEditar.setResizable(false);

        JPanel panelDialogo = new JPanel();

        panelDialogo.setLayout(new GridBagLayout());

        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.HORIZONTAL;

        JLabel ediitarTextoPrincipalDialogo = new JLabel("Buscar cliente");
        c.gridx = 0;
        c.gridy = 0;
        c.gridwidth = 2;
        c.insets = new Insets(10, 60, 10, 10);
        Font textoGrande = new Font("Arial", 1, 16);
        ediitarTextoPrincipalDialogo.setFont(textoGrande);
        panelDialogo.add(ediitarTextoPrincipalDialogo, c);

        c.gridx = 0;
        c.gridy = 1;
        c.gridwidth = 2;
        c.insets = new Insets(10, 10, 10, 10);
        final JTable tablaDialogo = new JTable();
        DefaultTableModel modeloTabla = new DefaultTableModel() {

            @Override
            public boolean isCellEditable(int row, int column) {
                //all cells false
                return false;
            }
        };
        ;

        modeloTabla.addColumn("Identificacin");
        modeloTabla.addColumn("Nombre");

        //LLenar tabla
        for (int i = 0; i < listaClientes.size(); i++) {
            Object[] data = { "1", "2" };
            data[0] = listaClientes.get(i).getCliente_id();
            data[1] = listaClientes.get(i).getNombre();
            modeloTabla.addRow(data);
        }

        tablaDialogo.setModel(modeloTabla);
        tablaDialogo.getColumn("Identificacin").setMinWidth(110);
        tablaDialogo.getColumn("Nombre").setMinWidth(110);
        tablaDialogo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        JScrollPane scroll = new JScrollPane(tablaDialogo);
        scroll.setPreferredSize(new Dimension(220, 150));

        panelDialogo.add(scroll, c);

        c.insets = new Insets(0, 0, 0, 10);
        c.gridx = 0;
        c.gridy = 2;
        c.gridwidth = 1;
        JButton botonGuardarClienteDialogo = new JButton("Elegir");
        panelDialogo.add(botonGuardarClienteDialogo, c);

        c.gridx = 1;
        c.gridy = 2;
        c.gridwidth = 1;
        JButton botonCerrarClienteDialogo = new JButton("Cancelar");
        panelDialogo.add(botonCerrarClienteDialogo, c);

        dialogoEditar.add(panelDialogo);
        dialogoEditar.setVisible(true);

        botonCerrarClienteDialogo.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                dialogoEditar.dispose();
            }
        });

        botonGuardarClienteDialogo.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                int row = tablaDialogo.getSelectedRow();
                if (row == -1) {
                    JOptionPane.showMessageDialog(dialogoEditar, "Por favor seleccione una fila");

                } else {
                    Object identificacionCliente = tablaDialogo.getValueAt(row, 0);
                    jTextFieldIdentificacionClienteReporte.setText(String.valueOf(identificacionCliente));
                    botonGenerarReporteCliente.setEnabled(true);
                    dialogoEditar.dispose();

                }

            }
        }); // TODO add your handling code here:     
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "El valor de la identificacin de ser numrico");

    }

}

From source file:interfaces.InterfazPrincipal.java

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
    // TODO add your handling code here:
    String nombre = jTextFieldNombreSaldoProveedores.getText();
    ControladorProveedores controladorProveedores = new ControladorProveedores();
    ArrayList<Proveedores> listaProveedores = controladorProveedores.obtenerProveedores("", nombre);

    final JDialog dialogoEditar = new JDialog(this);

    dialogoEditar.setTitle("Buscar proveedores");
    dialogoEditar.setSize(500, 300);//from  w w  w.  java2  s.  c  o m
    dialogoEditar.setResizable(false);

    JPanel panelDialogo = new JPanel();

    panelDialogo.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel ediitarTextoPrincipalDialogo = new JLabel("Buscar Proveedores");
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 3;
    c.insets = new Insets(10, 60, 10, 10);
    Font textoGrande = new Font("Arial", 1, 16);
    ediitarTextoPrincipalDialogo.setFont(textoGrande);
    panelDialogo.add(ediitarTextoPrincipalDialogo, c);

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 3;
    c.insets = new Insets(10, 10, 10, 10);
    final JTable tablaDialogo = new JTable();
    DefaultTableModel modeloTabla = new DefaultTableModel() {

        @Override
        public boolean isCellEditable(int row, int column) {
            //all cells false
            return false;
        }
    };
    ;
    modeloTabla.addColumn("ID");
    modeloTabla.addColumn("Identificacin");
    modeloTabla.addColumn("Nombre");

    //LLenar tabla
    for (int i = 0; i < listaProveedores.size(); i++) {
        Object[] data = { "1", "2", "3" };
        data[0] = listaProveedores.get(i).getID();
        data[1] = listaProveedores.get(i).getIdentificacion();
        data[2] = listaProveedores.get(i).getNombre();
        System.out.println("Nombre!!" + data[2]);
        modeloTabla.addRow(data);
    }

    tablaDialogo.setModel(modeloTabla);
    tablaDialogo.getColumn("ID").setMinWidth(70);
    tablaDialogo.getColumn("Identificacin").setMinWidth(60);
    tablaDialogo.getColumn("Nombre").setMinWidth(150);
    tablaDialogo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scroll = new JScrollPane(tablaDialogo);
    scroll.setPreferredSize(new Dimension(220, 150));

    panelDialogo.add(scroll, c);

    c.insets = new Insets(0, 0, 0, 10);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    JButton botonGuardarClienteDialogo = new JButton("Elegir");
    panelDialogo.add(botonGuardarClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 1;
    JButton botonCerrarClienteDialogo = new JButton("Cancelar");
    panelDialogo.add(botonCerrarClienteDialogo, c);

    dialogoEditar.add(panelDialogo);
    dialogoEditar.setVisible(true);

    botonCerrarClienteDialogo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialogoEditar.dispose();
        }
    });

    botonGuardarClienteDialogo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int row = tablaDialogo.getSelectedRow();
            if (row == -1) {
                JOptionPane.showMessageDialog(dialogoEditar, "Por favor seleccione una fila");

            } else {
                Object identificacionCliente = tablaDialogo.getValueAt(row, 0);
                Object idCliente = tablaDialogo.getValueAt(row, 1);
                mostrarIDProveedor.setText(String.valueOf(identificacionCliente));
                String nombreClientePago = String.valueOf(tablaDialogo.getValueAt(row, 2));

                //Limitar a 15 caracteres
                if (nombreClientePago.length() >= 15) {
                    nombreClientePago = nombreClientePago.substring(0, 12);

                }
                textoNombreProveedor.setText(nombreClientePago);

                DefaultTableModel modeloClientes = (DefaultTableModel) TablaDeSaldoProveedor.getModel();
                for (int i = 0; i < modeloClientes.getRowCount(); i++) {
                    modeloClientes.removeRow(i);
                }

                modeloClientes.setRowCount(0);
                ControladorFlujoCompras controladorFlujoCompra = new ControladorFlujoCompras();

                //SELECT * FROM Flujo_Factura where factura_id in (select factura_id from Factura where cliente_id = 1130614506);
                ArrayList<Flujo_Compra> flujosProveedor = controladorFlujoCompra.obtenerFlujosCompras(
                        " where ID_CompraProveedor in (select ID_CompraProveedor from Compra_Proveedores where IDProveedor = "
                                + String.valueOf(identificacionCliente) + ") order by ID_CompraProveedor");
                double pago = 0.0;

                for (int i = 0; i < flujosProveedor.size(); i++) {
                    Flujo_Compra datos = flujosProveedor.get(i);
                    Object[] rowData = { datos.getID_CompraProveedor(), datos.getTipo_flujo(), datos.getFecha(),
                            datos.getMonto() };

                    if (datos.getTipo_flujo().equals("deuda")) {
                        pago += Double.parseDouble(datos.getMonto() + "");
                    } else {
                        pago -= Double.parseDouble(datos.getMonto() + "");
                    }

                    modeloClientes.addRow(rowData);
                }

                TablaDeSaldoProveedor.setModel(modeloClientes);
                deudaActualProveedor.setText(String.valueOf(pago));
                dialogoEditar.dispose();

                //Mostrar en table de clientes los datos
                botonRegistrarAbono.setEnabled(true);
            }

        }

    });

}

From source file:interfaces.InterfazPrincipal.java

private void tablaUsuariosDelSistemaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaUsuariosDelSistemaMouseClicked
    // TODO add your handling code here:
    String opcionHabilitar = "Habilitar";
    String nombreUsuario = String
            .valueOf(tablaUsuariosDelSistema.getValueAt(tablaUsuariosDelSistema.getSelectedRow(), 0));
    String estado = String
            .valueOf(tablaUsuariosDelSistema.getValueAt(tablaUsuariosDelSistema.getSelectedRow(), 2));
    if (estado.equals("Habilitado")) {
        opcionHabilitar = "Deshabilitar";
    }//from ww  w.ja  v a  2  s . c o  m
    Object[] opciones = { "Cancelar", "Editar", opcionHabilitar };
    final ControladorUsuarios controladorUsuarios = new ControladorUsuarios();
    final Usuarios usuarioSelecionado = controladorUsuarios.obtenerUsuario(nombreUsuario);
    if (nombreUsuario.equals("admin") || nombreUsuario.equals(JTextFieldnombreDeUsuario.getText())) {
        JOptionPane.showMessageDialog(this,
                "No se puede editarse a si mismo o el usuario administrador del sistema", "Mensaje del sistema",
                JOptionPane.WARNING_MESSAGE);
    } else {
        int opcionElegida = JOptionPane.showOptionDialog(this, "Por favor elija una opcin", "Editar cliente",
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, opciones, null);
        switch (opcionElegida) {
        case 1:
            final JDialog dialogoEditar = new JDialog(this);
            dialogoEditar.setTitle("Editar usuario");
            dialogoEditar.setSize(400, 310);
            dialogoEditar.setResizable(false);
            JPanel panelDialogo = new JPanel();
            panelDialogo.setLayout(new GridBagLayout());
            GridBagConstraints c = new GridBagConstraints();
            c.fill = GridBagConstraints.HORIZONTAL;
            JLabel editarTextoPrincipalDialogo = new JLabel("Editar clientes");
            c.gridx = 0;
            c.gridy = 0;
            c.gridwidth = 2;
            c.insets = new Insets(15, 10, 40, 0);
            c.ipadx = 0;
            Font textoGrande = new Font("Arial", 1, 18);
            editarTextoPrincipalDialogo.setFont(textoGrande);
            panelDialogo.add(editarTextoPrincipalDialogo, c);
            c.insets = new Insets(0, 5, 10, 0);
            c.gridx = 0;
            c.gridy = 1;
            c.gridwidth = 1;
            c.ipadx = 0;
            JLabel editarNombreClienteDialogo = new JLabel("Login:");
            panelDialogo.add(editarNombreClienteDialogo, c);
            final JTextField valorEditarNombreClienteDialogo = new JTextField();
            c.gridx = 1;
            c.gridy = 1;
            c.gridwidth = 1;
            c.ipadx = 0;
            c.insets = new Insets(0, 5, 10, 0);
            valorEditarNombreClienteDialogo.setText(usuarioSelecionado.getLogin());
            panelDialogo.add(valorEditarNombreClienteDialogo, c);
            c.gridx = 0;
            c.gridy = 2;
            c.gridwidth = 1;
            c.ipadx = 0;
            c.insets = new Insets(0, 5, 10, 0);
            JLabel editarPasswordClienteDialogo = new JLabel("Contrasea:");
            panelDialogo.add(editarPasswordClienteDialogo, c);
            final JTextField valoreditarPasswordClienteDialogo = new JTextField();
            c.gridx = 1;
            c.gridy = 2;
            c.gridwidth = 1;
            c.ipadx = 0;
            c.insets = new Insets(0, 5, 10, 0);
            panelDialogo.add(valoreditarPasswordClienteDialogo, c);
            c.gridx = 0;
            c.gridy = 3;
            c.gridwidth = 2;
            c.ipadx = 0;
            c.insets = new Insets(0, 5, 10, 0);
            JLabel mensajeEditarPassword = new JLabel(
                    "Si no desea editar la contrasea deje este espacio en blanco:");
            panelDialogo.add(mensajeEditarPassword, c);
            c.gridx = 0;
            c.gridy = 4;
            c.gridwidth = 1;
            c.ipadx = 0;
            c.insets = new Insets(0, 15, 10, 15);
            JButton botonGuardarClienteDialogo = new JButton("Guardar");
            panelDialogo.add(botonGuardarClienteDialogo, c);
            c.gridx = 1;
            c.gridy = 4;
            c.gridwidth = 1;
            c.insets = new Insets(0, 15, 10, 15);
            c.ipadx = 0;
            JButton botonCerrarClienteDialogo = new JButton("Cancelar");
            panelDialogo.add(botonCerrarClienteDialogo, c);
            botonCerrarClienteDialogo.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    dialogoEditar.dispose();
                }
            });
            botonGuardarClienteDialogo.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    String nombreUsuario = valorEditarNombreClienteDialogo.getText();
                    usuarioSelecionado.setLogin(nombreUsuario);
                    if (!valoreditarPasswordClienteDialogo.getText().equals("")) {
                        usuarioSelecionado.setPassword(valoreditarPasswordClienteDialogo.getText());
                    }
                    controladorUsuarios.modificarUsuario(usuarioSelecionado.getUser_id(),
                            usuarioSelecionado.getLogin(), usuarioSelecionado.getPassword());
                    JOptionPane.showMessageDialog(dialogoEditar, "Se ha modificado el usuario con xito",
                            "Mensaje del sistema", JOptionPane.INFORMATION_MESSAGE);
                    generarTablaUsuarios();
                    dialogoEditar.dispose();
                }
            });
            dialogoEditar.add(panelDialogo);
            dialogoEditar.setVisible(true);
            break;
        case 2:
            if (estado.equals("Habilitado")) {
                usuarioSelecionado.setStatus('i');
            } else {
                usuarioSelecionado.setStatus('e');
            }
            controladorUsuarios.modificarEstadoUsuario(usuarioSelecionado);
            JOptionPane.showMessageDialog(this, "Se ha cambiado el estado del usuario", "Mensaje del sistema",
                    JOptionPane.INFORMATION_MESSAGE);
            generarTablaUsuarios();
            break;
        default:
            break;
        }
    } // TODO add your handling code here:

}

From source file:interfaces.InterfazPrincipal.java

private void botonAgregarProductoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAgregarProductoActionPerformed
    String nombre = jTextField_Factura_Producto_Nombre.getText();
    String descripcion = jTextField_Factura_Producto_Descripcion.getText();
    ControladorProducto controladorPro = new ControladorProducto();
    String restriccion = "";

    boolean encounter = true;

    if (!nombre.equals("")) {
        if (encounter) {
            encounter = false;/*from   w  ww  .  j av a2 s.  co m*/
            restriccion = " where ";
        } else {
            restriccion += " OR ";
        }

        restriccion += " nombre like '%" + nombre + "%'";
    }

    if (!descripcion.equals("")) {
        if (encounter) {
            encounter = false;
            restriccion = " where ";
        } else {
            restriccion += " OR ";
        }

        restriccion += " descripcion like '%" + descripcion + "%'";
    }

    ArrayList<Productos> listaDeProductos = controladorPro.getProducto(restriccion);

    final JDialog dialogoEditar = new JDialog(this);
    dialogoEditar.setTitle("Buscar clientes");
    dialogoEditar.setSize(600, 310);
    dialogoEditar.setResizable(false);

    JPanel panelDialogo = new JPanel();

    panelDialogo.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel editarTextoPrincipalDialogo = new JLabel("Buscar Producto");
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 6;
    c.insets = new Insets(15, 200, 40, 0);
    c.ipadx = 100;
    Font textoGrande = new Font("Arial", 1, 18);
    editarTextoPrincipalDialogo.setFont(textoGrande);
    panelDialogo.add(editarTextoPrincipalDialogo, c);

    final JTable table = new JTable();
    DefaultTableModel modeloTabla = new DefaultTableModel() {

        @Override
        public boolean isCellEditable(int row, int column) {
            //all cells false
            return false;
        }
    };
    ;

    modeloTabla.addColumn("Numero");
    modeloTabla.addColumn("Identificacin");
    modeloTabla.addColumn("Nombre");
    modeloTabla.addColumn("Descripcion");
    modeloTabla.addColumn("Unidades Disponibles");
    modeloTabla.addColumn("Precio");

    //LLenar tabla
    for (int i = 0; i < listaDeProductos.size(); i++) {
        Object[] data = { "1", "2", "3", "4", "5", "6" };
        data[0] = (i + 1);
        data[1] = listaDeProductos.get(i).getProductoId();
        data[2] = listaDeProductos.get(i).getNombre();
        data[3] = listaDeProductos.get(i).getDescripcion();
        data[4] = listaDeProductos.get(i).getUnidadesDisponibles();
        data[5] = listaDeProductos.get(i).getPrecio();

        modeloTabla.addRow(data);
    }

    table.setModel(modeloTabla);
    table.getColumn("Numero").setMinWidth(50);
    table.getColumn("Identificacin").setMinWidth(50);
    table.getColumn("Nombre").setMinWidth(110);
    table.getColumn("Descripcion").setMinWidth(110);
    table.getColumn("Unidades Disponibles").setMinWidth(40);
    table.getColumn("Precio").setMinWidth(110);

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scroll = new JScrollPane(table);
    scroll.setPreferredSize(new Dimension(320, 150));

    //final JTable table = new JTable(row, col);       
    table.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            //jTextField_Factura_Cliente_Id.setText(table.getValueAt(table.getSelectedRow(), 1).toString());
            //System.out.println(table.getValueAt(table.getSelectedRow(), 3).toString());
            DefaultTableModel modelo = (DefaultTableModel) TablaDeFacturaProducto.getModel();

            Object[] fila = new Object[7];

            fila[0] = table.getValueAt(table.getSelectedRow(), 0).toString();
            fila[1] = table.getValueAt(table.getSelectedRow(), 1).toString();
            fila[2] = table.getValueAt(table.getSelectedRow(), 2).toString();
            fila[3] = table.getValueAt(table.getSelectedRow(), 3).toString();
            //fila[4] = table.getValueAt(table.getSelectedRow(), 4).toString();
            fila[4] = (String) JOptionPane.showInputDialog("Ingrese el nmero de unidades que va a vender");
            fila[5] = table.getValueAt(table.getSelectedRow(), 5).toString();

            Double valorProducto = Double.parseDouble((String) fila[5]);
            String valorActualProducto = String.valueOf(Double.parseDouble(valorActualFactura.getText())
                    + Double.parseDouble((String) fila[4]) * valorProducto);
            valorActualFactura.setText(valorActualProducto);
            fila[6] = Double.parseDouble((String) fila[4]) * valorProducto;
            modelo.addRow(fila);
            //modelo.getColumnName(4).
            /*TablaDeFacturaProducto.setModel(modelo);
             TablaDeFacturaProducto.getColumnClass(4). ;*/
            dialogoEditar.dispose();
        }
    });

    c.insets = new Insets(0, 5, 10, 0);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 200;

    panelDialogo.add(scroll, c);

    //panelDialogo.add(table, c);
    dialogoEditar.add(panelDialogo);
    dialogoEditar.setVisible(true);

}

From source file:net.phyloviz.project.action.LoadDataSetAction.java

@Override
public void actionPerformed(ActionEvent ae) {

    final JDialog dialog = createLoadingDialog();

    EventQueue.invokeLater(new Runnable() {

        public void run() {
            Properties prop = new Properties();
            String propFileName = "config.properties.pviz";

            String projectDir = getProjectLocation();
            File visualization = new File(projectDir, VIZ_FOLDER);
            try {
                InputStream inputStream = new FileInputStream(new File(projectDir, propFileName));
                prop.load(inputStream);//  ww w .  j  a v a  2  s .  co  m

                StatusDisplayer.getDefault().setStatusText("Loading DataSet...");

                String dataSetName = prop.getProperty("dataset-name");
                if (dataSetAlreadyOpened(dataSetName)) {
                    JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
                            "DataSet already opened!");
                    WindowManager.getDefault().findTopComponent("DataSetExplorerTopComponent").requestActive();

                } else {

                    String typingFactory = prop.getProperty("typing-factory"),
                            typingFile = prop.getProperty("typing-file"),
                            populationFactory = prop.getProperty("population-factory"),
                            populationFile = prop.getProperty("population-file"),
                            populationFK = prop.getProperty("population-foreign-key"),
                            algorithmOutput = prop.getProperty("algorithm-output"),
                            algorithmOutputFactory = prop.getProperty("algorithm-output-factory"),
                            algorithmOutputDistanceProvider = prop.getProperty("algorithm-output-distance"),
                            algorithmOutputLevel = prop.getProperty("algorithm-output-level"),
                            visualizations = prop.getProperty("visualization"),
                            vizfilter = prop.getProperty("visualization-filter"),
                            vizpalette = prop.getProperty("visualization-palette");

                    String[] algoOutput = algorithmOutput != null ? algorithmOutput.split(",")
                            : new String[] { "" };
                    String[] algoOutputFactory = algorithmOutputFactory != null
                            ? algorithmOutputFactory.split(",")
                            : new String[] { "" };
                    String[] algoOutputDistance = algorithmOutputDistanceProvider != null
                            ? algorithmOutputDistanceProvider.split(",")
                            : new String[] { "" };
                    String[] algoOutputLevel = algorithmOutputLevel != null ? algorithmOutputLevel.split(",")
                            : new String[] { "" };
                    String[] viz = visualizations != null ? visualizations.split(",") : new String[] {};

                    if (dataSetName != null && (!dataSetName.equals(""))) {

                        DataSet ds = new DataSet(dataSetName);

                        StatusDisplayer.getDefault().setStatusText("Loading typing data...");

                        TypingFactory tf = null;
                        TypingData<? extends AbstractProfile> td = null;

                        Collection<? extends ProjectTypingDataFactory> tfLookup = (Lookup.getDefault()
                                .lookupAll(ProjectTypingDataFactory.class));
                        for (ProjectTypingDataFactory ptdi : tfLookup) {
                            if (ptdi.getClass().getName().equals(typingFactory)) {
                                tf = (TypingFactory) ptdi;
                                td = ptdi.onLoad(new FileReader(new File(projectDir, typingFile)));
                                td.setDescription(tf.toString());
                                ds.add(ptdi);
                            }
                        }

                        Population pop = null;
                        if (populationFile != null && (!populationFile.equals("")) && populationFK != null) {

                            StatusDisplayer.getDefault().setStatusText("Loading isolate data...");
                            pop = ((PopulationFactory) Class.forName(populationFactory).newInstance())
                                    .loadPopulation(new FileReader(new File(projectDir, populationFile)));
                            ds.add(pop);

                            int key = Integer.parseInt(populationFK);
                            StatusDisplayer.getDefault().setStatusText("Integrating data...");
                            td = tf.integrateData(td, pop, key);
                            ds.setPopKey(key);
                        }

                        int v_i = 0;
                        Collection<? extends ProjectItemFactory> pifactory = (Lookup.getDefault()
                                .lookupAll(ProjectItemFactory.class));
                        for (int i = 0; i < algoOutput.length; i++) {

                            for (ProjectItemFactory pif : pifactory) {
                                String pifName = pif.getClass().getName();
                                if (pifName.equals(algoOutputFactory[i])) {

                                    Visualization v = new Visualization();
                                    PersistentVisualization pv = null;
                                    if (viz.length > v_i
                                            && viz[v_i].split("\\.")[0].equals(algoOutput[i].split("\\.")[2])) {
                                        try (FileInputStream fileIn = new FileInputStream(
                                                new File(visualization, viz[v_i++]))) {

                                            try (ObjectInputStream in = new ObjectInputStream(fileIn)) {

                                                pv = (PersistentVisualization) in.readObject();

                                            }

                                        } catch (IOException | ClassNotFoundException e) {
                                            Exceptions.printStackTrace(e);
                                        }
                                        v.pv = pv;
                                        if (vizfilter != null) {
                                            TreeFilter treefilter = loadTreeFilter(visualization, vizfilter);
                                            v.filter = treefilter.filter;
                                            DataModel dm = treefilter.datamodel
                                                    .equals(TypingData.class.getCanonicalName()) ? td : pop;
                                            v.category = loadCategoryPalette(visualization, vizpalette, dm,
                                                    v.filter);
                                        }
                                    }
                                    StatusDisplayer.getDefault().setStatusText("Loading algorithms...");
                                    AbstractDistance ad = null;
                                    Collection<? extends DistanceProvider> dpLookup = (Lookup.getDefault()
                                            .lookupAll(DistanceProvider.class));
                                    for (DistanceProvider dp : dpLookup) {
                                        if (dp.getClass().getCanonicalName().equals(algoOutputDistance[i])) {
                                            ad = dp.getDistance(td);
                                        }
                                    }

                                    ProjectItem pi = pif.loadData(ds, td, projectDir, algoOutput[i], ad,
                                            Integer.parseInt(algoOutputLevel[i]));
                                    if (pi != null) {
                                        pi.addVisualization(v);
                                        td.add(pi);
                                    } else {
                                        return;
                                    }
                                }
                            }
                        }

                        ds.add(td);

                        Lookup.getDefault().lookup(DataSetTracker.class).add(ds);
                        StatusDisplayer.getDefault().setStatusText("Dataset loaded.");
                        WindowManager.getDefault().findTopComponent("DataSetExplorerTopComponent")
                                .requestActive();

                    } else {
                        Exceptions.printStackTrace(new IllegalArgumentException("DataSet name not found!"));
                    }
                }
            } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException
                    | NumberFormatException e) {
                Exceptions.printStackTrace(e);
            }
            dialog.dispose();
        }
    });

    dialog.setVisible(true);
}

From source file:interfaces.InterfazPrincipal.java

private void TablaDeProductosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TablaDeProductosMouseClicked
    // TODO add your handling code here:
    int fila = TablaDeProductos.getSelectedRow();
    final int identificacion = (int) TablaDeProductos.getValueAt(fila, 1);

    final ControladorProducto controladorP = new ControladorProducto();
    ArrayList<Productos> listaProductos = controladorP.getProducto(" where producto_id = " + identificacion);
    final Productos productoActual = listaProductos.get(0);

    final JDialog dialogoEditar = new JDialog(this);

    dialogoEditar.setTitle("Editar clientes");
    dialogoEditar.setSize(600, 310);//from w  ww .ja  v  a 2  s . co  m
    dialogoEditar.setResizable(false);

    JPanel panelDialogo = new JPanel();

    panelDialogo.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel editarTextoPrincipalDialogo = new JLabel("Editar producto");
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 4;
    c.insets = new Insets(15, 200, 40, 0);
    c.ipadx = 100;
    Font textoGrande = new Font("Arial", 1, 18);
    editarTextoPrincipalDialogo.setFont(textoGrande);
    panelDialogo.add(editarTextoPrincipalDialogo, c);

    c.insets = new Insets(0, 5, 10, 0);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 40;
    JLabel editarNombreClienteDialogo = new JLabel("Nombre:");
    panelDialogo.add(editarNombreClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);
    final JTextField valorEditarNombreClienteDialogo = new JTextField();
    valorEditarNombreClienteDialogo.setText(productoActual.getNombre());
    panelDialogo.add(valorEditarNombreClienteDialogo, c);

    final JTextField valorEditarUnidadesProductoDialogo = new JTextField();
    valorEditarUnidadesProductoDialogo.setText(String.valueOf(productoActual.getUnidadesDisponibles()));
    panelDialogo.add(valorEditarUnidadesProductoDialogo, c);

    c.gridx = 2;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 15, 10, 0);
    JLabel editarTelefonoClienteDialogo = new JLabel("Precio");
    panelDialogo.add(editarTelefonoClienteDialogo, c);

    c.gridx = 3;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 0, 10, 0);

    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 5, 10, 0);
    JLabel editarCelularClienteDialogo = new JLabel("Descripcion:");
    panelDialogo.add(editarCelularClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);

    final JTextField valorEditarDescripcionProductoDialogo = new JTextField();
    valorEditarDescripcionProductoDialogo.setText(productoActual.getDescripcion());
    panelDialogo.add(valorEditarDescripcionProductoDialogo, c);
    c.gridx = 2;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 5, 10, 0);
    JLabel editarMontoClienteDialogo = new JLabel("Unidades");
    panelDialogo.add(editarMontoClienteDialogo, c);

    c.gridx = 3;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);

    final JTextField valorEditarPrecioProductoDialogo = new JTextField();
    valorEditarPrecioProductoDialogo.setText(productoActual.getPrecio() + "");
    panelDialogo.add(valorEditarPrecioProductoDialogo, c);

    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 5, 10, 0);
    JLabel editarCodigoBarrasProyecto = new JLabel("Cdigo de barras:");
    panelDialogo.add(editarCodigoBarrasProyecto, c);

    c.gridx = 1;
    c.gridy = 3;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);

    final JTextField valorCodigoDeBarras = new JTextField();
    valorCodigoDeBarras.setText(productoActual.getCodigoBarras());
    panelDialogo.add(valorCodigoDeBarras, c);

    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 2;
    c.ipadx = 100;
    c.insets = new Insets(15, 40, 0, 0);
    JButton botonGuardarProductoDialogo = new JButton("Guardar");
    panelDialogo.add(botonGuardarProductoDialogo, c);

    c.gridx = 2;
    c.gridy = 4;
    c.gridwidth = 2;
    c.insets = new Insets(15, 40, 0, 0);
    c.ipadx = 100;

    JButton botonCerrarProductoDialogo = new JButton("Cancelar");
    panelDialogo.add(botonCerrarProductoDialogo, c);

    dialogoEditar.add(panelDialogo);

    botonCerrarProductoDialogo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialogoEditar.dispose();
        }
    });

    botonGuardarProductoDialogo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            try {

                String[] selection = { "nombre", "descripcion", "unidades", "precio", "codigoBarras" };
                String[] value = { valorEditarNombreClienteDialogo.getText(),
                        valorEditarDescripcionProductoDialogo.getText(),
                        valorEditarUnidadesProductoDialogo.getText(),
                        valorEditarPrecioProductoDialogo.getText(), valorCodigoDeBarras.getText() };
                String[] type_value = { "varchar", "varchar", "int", "double", "varchar" };
                String restriction = " where producto_id = " + identificacion;
                controladorP.updateProduct(selection, value, type_value, restriction);
                JOptionPane.showMessageDialog(dialogoEditar, "Se ha editado el producto xitosamente");
                dialogoEditar.dispose();

                //Refrescar busqueda actual
                jButton2ActionPerformed(null);

            } catch (Exception event) {

                JOptionPane.showMessageDialog(dialogoEditar, "El valor del monto debe ser numrico");

            }

        }
    });

    dialogoEditar.setVisible(true);
}

From source file:interfaces.InterfazPrincipal.java

private void TablaDeClientesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TablaDeClientesMouseClicked
    // TODO add your handling code here:
    int fila = TablaDeClientes.getSelectedRow();
    int identificacion = (int) TablaDeClientes.getValueAt(fila, 0);

    final ControladorCliente controladorCliente = new ControladorCliente();
    ArrayList<Cliente> listaClientes = controladorCliente.obtenerClientes("", identificacion);
    final Cliente clienteActual = listaClientes.get(0);

    final JDialog dialogoEditar = new JDialog(this);

    dialogoEditar.setTitle("Editar clientes");
    dialogoEditar.setSize(600, 310);/*from  w  w  w.jav a  2s . c  om*/
    dialogoEditar.setResizable(false);

    JPanel panelDialogo = new JPanel();

    panelDialogo.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel editarTextoPrincipalDialogo = new JLabel("Editar clientes");
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 4;
    c.insets = new Insets(15, 200, 40, 0);
    c.ipadx = 100;
    Font textoGrande = new Font("Arial", 1, 18);
    editarTextoPrincipalDialogo.setFont(textoGrande);
    panelDialogo.add(editarTextoPrincipalDialogo, c);

    c.insets = new Insets(0, 5, 10, 0);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 40;
    JLabel editarNombreClienteDialogo = new JLabel("Nombre:");
    panelDialogo.add(editarNombreClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);
    final JTextField valorEditarNombreClienteDialogo = new JTextField();
    valorEditarNombreClienteDialogo.setText(clienteActual.getNombre());
    panelDialogo.add(valorEditarNombreClienteDialogo, c);

    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 5, 10, 0);
    JLabel editarCelularClienteDialogo = new JLabel("Celular:");
    panelDialogo.add(editarCelularClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);

    final JTextField valorEditarCelularClienteDialogo = new JTextField();
    valorEditarCelularClienteDialogo.setText(clienteActual.getNumero_celular());
    panelDialogo.add(valorEditarCelularClienteDialogo, c);
    c.gridx = 2;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 5, 10, 0);
    JLabel editarMontoClienteDialogo = new JLabel("Monto a prestar:");
    panelDialogo.add(editarMontoClienteDialogo, c);

    c.gridx = 3;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);
    final JTextField valorEditarMontoClienteDialogo = new JTextField();
    valorEditarMontoClienteDialogo.setText(String.valueOf(clienteActual.getMonto_prestamo()));
    panelDialogo.add(valorEditarMontoClienteDialogo, c);

    c.gridx = 2;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 15, 10, 0);
    JLabel editarTelefonoClienteDialogo = new JLabel("Telefono:");
    panelDialogo.add(editarTelefonoClienteDialogo, c);

    c.gridx = 3;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 0, 10, 0);
    final JTextField valorEditarTelefonoClienteDialogo = new JTextField();
    valorEditarTelefonoClienteDialogo.setText(clienteActual.getNumero_telefono());
    panelDialogo.add(valorEditarTelefonoClienteDialogo, c);

    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 0, 10, 0);

    JLabel editarAddressClienteDialogo = new JLabel("Direccin:");
    panelDialogo.add(editarAddressClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 3;
    c.gridwidth = 3;
    c.ipadx = 400;
    c.insets = new Insets(0, 15, 10, 0);
    final JTextField valorEditarAddressClienteDialogo = new JTextField();
    valorEditarAddressClienteDialogo.setText(clienteActual.getDireccion());
    panelDialogo.add(valorEditarAddressClienteDialogo, c);

    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 2;
    c.ipadx = 100;
    c.insets = new Insets(15, 40, 0, 0);
    JButton botonGuardarClienteDialogo = new JButton("Guardar");
    panelDialogo.add(botonGuardarClienteDialogo, c);

    c.gridx = 2;
    c.gridy = 4;
    c.gridwidth = 2;
    c.insets = new Insets(15, 40, 0, 0);
    c.ipadx = 100;

    JButton botonCerrarClienteDialogo = new JButton("Cancelar");
    panelDialogo.add(botonCerrarClienteDialogo, c);

    dialogoEditar.add(panelDialogo);

    botonCerrarClienteDialogo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialogoEditar.dispose();
        }
    });

    botonGuardarClienteDialogo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            try {
                clienteActual.setDireccion(valorEditarAddressClienteDialogo.getText());
                clienteActual.setMonto_prestamo(Double.parseDouble(valorEditarMontoClienteDialogo.getText()));
                clienteActual.setNombre(valorEditarNombreClienteDialogo.getText());
                clienteActual.setNumero_celular(valorEditarCelularClienteDialogo.getText());
                clienteActual.setNumero_telefono(valorEditarTelefonoClienteDialogo.getText());

                controladorCliente.editarCliente(clienteActual);
                JOptionPane.showMessageDialog(dialogoEditar, "Se ha editado el cliente xitosamente");
                dialogoEditar.dispose();

                //Refrescar busqueda actual
                String nombreCliente = nombreClienteBusqueda.getText();

                int identificacionClienteInt = 0;

                ControladorCliente controladorCliente = new ControladorCliente();

                ArrayList<Cliente> listaDeClientes = controladorCliente.obtenerClientes(nombreCliente,
                        identificacionClienteInt);

                //Agregar filas
                DefaultTableModel modelo = (DefaultTableModel) TablaDeClientes.getModel();

                for (int i = 0; i < modelo.getRowCount(); i++) {
                    modelo.removeRow(i);
                }
                modelo.setRowCount(0);
                for (int i = 0; i < listaDeClientes.size(); i++) {
                    Cliente cliente = listaDeClientes.get(i);
                    Object[] fila = new Object[4];
                    fila[0] = cliente.getCliente_id();
                    fila[1] = cliente.getNombre();
                    fila[2] = cliente.getMonto_prestamo();
                    //button.setText("<HTML>Click the <FONT color=\"#000099\"><U>link "+i+"</U></FONT>"+ " to go to the Java website.</HTML>");

                    fila[3] = "Editar";
                    modelo.addRow(fila);

                }

                TablaDeClientes.setModel(modelo);

            } catch (Exception event) {

                JOptionPane.showMessageDialog(dialogoEditar, "El valor del monto debe ser numrico");

            }

        }
    });

    dialogoEditar.setVisible(true);
    /*Action mostrarMensaje;
     mostrarMensaje = new AbstractAction() {
     @Override
     public void actionPerformed(ActionEvent e) {
     JTable table = (JTable) e.getSource();
     int modelRow = Integer.valueOf(e.getActionCommand());
     ((DefaultTableModel) table.getModel()).removeRow(modelRow);
     }
     };
     ButtonColumn buttonColumn = new ButtonColumn(TablaDeClientes, mostrarMensaje, 3);
     buttonColumn.setMnemonic(KeyEvent.VK_E);*/
}

From source file:interfaces.InterfazPrincipal.java

private void botonBuscarClienteCrearFacturaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonBuscarClienteCrearFacturaActionPerformed

    String nombre = nombreClienteCrearFactura.getText();
    String identificacion = IdentificacionClienteBuscarFactura.getText();

    ControladorCliente controladorCliente = new ControladorCliente();

    try {//from www.ja v  a2 s.  c  o m
        int id = 0;
        if (!identificacion.equals("")) {
            id = Integer.parseInt(identificacion);
        }

        ArrayList<Cliente> listaClientes = controladorCliente.obtenerClientes(nombre, id);

        if (listaClientes.isEmpty()) {
            mensajesBusquedaClientesFactura.setText("La busqueda no arrojo resultados");
            return;
        }

        final JDialog dialogoEditar = new JDialog(this);
        dialogoEditar.setTitle("Buscar clientes");
        dialogoEditar.setSize(600, 310);
        dialogoEditar.setResizable(false);

        JPanel panelDialogo = new JPanel();

        panelDialogo.setLayout(new GridBagLayout());

        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.HORIZONTAL;

        JLabel editarTextoPrincipalDialogo = new JLabel("Buscar Cliente");
        c.gridx = 0;
        c.gridy = 0;
        c.gridwidth = 4;
        c.insets = new Insets(15, 200, 40, 0);
        c.ipadx = 100;
        Font textoGrande = new Font("Arial", 1, 18);
        editarTextoPrincipalDialogo.setFont(textoGrande);
        panelDialogo.add(editarTextoPrincipalDialogo, c);

        /*Vector col = new Vector();
         col.add("1");
         col.add("2");
         col.add("3");
         col.add("4");
         Vector row = new Vector();
                
         for (int i = 0; i < listaClientes.size(); i++) {
         Cliente cliente = listaClientes.get(i);
         Vector temp = new Vector();
         temp.add((i + 1) + "");
         temp.add(cliente.getNombre());
         temp.add(cliente.getCliente_id() + "");
         temp.add(cliente.getMonto_prestamo() + "");
         System.out.println("info" + cliente.getNombre() + "," + cliente.getMonto_prestamo());
         row.add(temp);
         }
                
         final JTable table = new JTable(row, col);         */
        final JTable table = new JTable();
        DefaultTableModel modeloTabla = new DefaultTableModel() {

            @Override
            public boolean isCellEditable(int row, int column) {
                //all cells false
                return false;
            }
        };
        ;

        modeloTabla.addColumn("Numero");
        modeloTabla.addColumn("Identificacin");
        modeloTabla.addColumn("Nombre");
        modeloTabla.addColumn("Monto Prestamo");

        //LLenar tabla
        for (int i = 0; i < listaClientes.size(); i++) {
            Object[] data = { "1", "2", "3", "4" };
            data[0] = (i + 1);
            data[1] = listaClientes.get(i).getCliente_id();
            data[2] = listaClientes.get(i).getNombre();
            data[3] = listaClientes.get(i).getMonto_prestamo();

            modeloTabla.addRow(data);
        }

        table.setModel(modeloTabla);
        table.getColumn("Numero").setMinWidth(50);
        table.getColumn("Identificacin").setMinWidth(50);
        table.getColumn("Nombre").setMinWidth(110);
        table.getColumn("Monto Prestamo").setMinWidth(110);

        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        JScrollPane scroll = new JScrollPane(table);
        scroll.setPreferredSize(new Dimension(320, 150));

        table.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                jTextField_Factura_Cliente_Id.setText(table.getValueAt(table.getSelectedRow(), 1).toString());
                String identificacion = table.getValueAt(table.getSelectedRow(), 3).toString();
                ControladorFlujoFactura controladorFlujoFactura = new ControladorFlujoFactura();

                //SELECT * FROM Flujo_Factura where factura_id in (select factura_id from Factura where cliente_id = 1130614506);
                ArrayList<String[]> flujosCliente = controladorFlujoFactura.getTodosFlujo_Factura(
                        " where factura_id in (select factura_id from Factura where cliente_id = "
                                + String.valueOf(identificacion)
                                + " and estado=\"fiado\") order by factura_id");
                double pago = 0.0;

                for (int i = 0; i < flujosCliente.size(); i++) {
                    String[] datos = flujosCliente.get(i);
                    Object[] rowData = { datos[1], datos[2], datos[3], datos[4] };

                    if (datos[2].equals("deuda")) {
                        pago += Double.parseDouble(datos[4]);
                    } else {
                        pago -= Double.parseDouble(datos[4]);
                    }

                }
                nombreClienteCrearFactura.setText(table.getValueAt(table.getSelectedRow(), 2).toString());
                IdentificacionClienteBuscarFactura
                        .setText(table.getValueAt(table.getSelectedRow(), 1).toString());
                double montoPrestamo = Double
                        .parseDouble(table.getValueAt(table.getSelectedRow(), 3).toString());
                Double totalDisponible = montoPrestamo - pago;
                valorActualPrestamo.setText(String.valueOf(totalDisponible));
                //System.out.println(table.getValueAt(table.getSelectedRow(), 3).toString());
                botonAgregarProducto.setEnabled(true);
                botonGuardarFactura.setEnabled(true);
                botonEstablecerMontoFactura.setEnabled(true);
                dialogoEditar.dispose();
            }
        });

        c.insets = new Insets(0, 5, 10, 0);
        c.gridx = 0;
        c.gridy = 1;
        c.gridwidth = 1;
        c.ipadx = 200;

        //panelDialogo.add(table, c);
        panelDialogo.add(scroll, c);
        dialogoEditar.add(panelDialogo);
        dialogoEditar.setVisible(true);
    } catch (Exception e) {
        mensajesBusquedaClientesFactura.setText("La identificacion debe ser un numero");

    }

}

From source file:userinterface.properties.GUIGraphHandler.java

public void plotNewFunction() {

    JDialog dialog;
    JRadioButton radio2d, radio3d, newGraph, existingGraph;
    JTextField functionField, seriesName;
    JButton ok, cancel;/*from  w ww  .  j a  va 2  s. c  o m*/
    JComboBox<String> chartOptions;
    JLabel example;

    //init all the fields of the dialog
    dialog = new JDialog(GUIPrism.getGUI());
    radio2d = new JRadioButton("2D");
    radio3d = new JRadioButton("3D");
    newGraph = new JRadioButton("New Graph");
    existingGraph = new JRadioButton("Exisiting");
    chartOptions = new JComboBox<String>();
    functionField = new JTextField();
    ok = new JButton("Plot");
    cancel = new JButton("Cancel");
    seriesName = new JTextField();
    example = new JLabel("<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>");
    example.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            example.setCursor(new Cursor(Cursor.HAND_CURSOR));
            example.setForeground(Color.BLUE);
        }

        @Override
        public void mouseExited(MouseEvent e) {
            example.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            example.setForeground(Color.BLACK);
        }

        @Override
        public void mouseClicked(MouseEvent e) {

            if (e.getButton() == MouseEvent.BUTTON1) {

                if (radio2d.isSelected()) {
                    functionField.setText("x/2 + 5");
                } else {
                    functionField.setText("x+y+5");
                }

                functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15));
                functionField.setForeground(Color.BLACK);

            }
        }

    });

    //set dialog properties
    dialog.setSize(400, 350);
    dialog.setTitle("Plot a new function");
    dialog.setModal(true);
    dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS));
    dialog.setLocationRelativeTo(GUIPrism.getGUI());

    //add every component to their dedicated panels
    JPanel graphTypePanel = new JPanel(new FlowLayout());
    graphTypePanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function type"));
    graphTypePanel.add(radio2d);
    graphTypePanel.add(radio3d);

    JPanel functionFieldPanel = new JPanel(new BorderLayout());
    functionFieldPanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function"));
    functionFieldPanel.add(functionField, BorderLayout.CENTER);
    functionFieldPanel.add(example, BorderLayout.SOUTH);

    JPanel chartSelectPanel = new JPanel();
    chartSelectPanel.setLayout(new BoxLayout(chartSelectPanel, BoxLayout.Y_AXIS));
    chartSelectPanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Plot function to"));
    JPanel radioPlotPanel = new JPanel(new FlowLayout());
    radioPlotPanel.add(newGraph);
    radioPlotPanel.add(existingGraph);
    JPanel chartOptionsPanel = new JPanel(new FlowLayout());
    chartOptionsPanel.add(chartOptions);
    chartSelectPanel.add(radioPlotPanel);
    chartSelectPanel.add(chartOptionsPanel);

    JPanel bottomControlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    bottomControlPanel.add(ok);
    bottomControlPanel.add(cancel);

    JPanel seriesNamePanel = new JPanel(new BorderLayout());
    seriesNamePanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name"));
    seriesNamePanel.add(seriesName, BorderLayout.CENTER);

    // add all the panels to the dialog

    dialog.add(graphTypePanel);
    dialog.add(functionFieldPanel);
    dialog.add(chartSelectPanel);
    dialog.add(seriesNamePanel);
    dialog.add(bottomControlPanel);

    // do all the enables and set properties

    radio2d.setSelected(true);
    newGraph.setSelected(true);
    chartOptions.setEnabled(false);
    functionField.setText("Add function expression here....");
    functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15));
    functionField.setForeground(Color.GRAY);
    seriesName.setText("New function");
    ok.setMnemonic('P');
    cancel.setMnemonic('C');
    example.setToolTipText("click to try out");

    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok");
    ok.getActionMap().put("ok", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ok.doClick();
        }
    });

    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "cancel");
    cancel.getActionMap().put("cancel", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cancel.doClick();
        }
    });

    boolean found = false;

    for (int i = 0; i < theTabs.getTabCount(); i++) {

        if (theTabs.getComponentAt(i) instanceof Graph) {
            chartOptions.addItem(getGraphName(i));
            found = true;
        }
    }

    if (!found) {

        existingGraph.setEnabled(false);
        chartOptions.setEnabled(false);
    }

    //add all the action listeners

    radio2d.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (radio2d.isSelected()) {

                radio3d.setSelected(false);

                if (chartOptions.getItemCount() > 0) {
                    existingGraph.setEnabled(true);
                    chartOptions.setEnabled(true);
                }

                example.setText(
                        "<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>");
            }
        }
    });

    radio3d.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (radio3d.isSelected()) {

                radio2d.setSelected(false);
                newGraph.setSelected(true);
                existingGraph.setEnabled(false);
                chartOptions.setEnabled(false);
                example.setText("<html><font size=3 color=red>Example:</font><font size=3>x+y+5</font></html>");

            }

        }
    });

    newGraph.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (newGraph.isSelected()) {
                existingGraph.setSelected(false);
                chartOptions.setEnabled(false);
            }
        }
    });

    existingGraph.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (existingGraph.isSelected()) {

                newGraph.setSelected(false);
                chartOptions.setEnabled(true);
            }
        }
    });

    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            String function = functionField.getText();

            Expression expr = null;

            try {

                expr = GUIPrism.getGUI().getPrism().parseSingleExpressionString(function);
                expr = (Expression) expr.accept(new ASTTraverseModify() {

                    @Override
                    public Object visit(ExpressionIdent e) throws PrismLangException {
                        return new ExpressionConstant(e.getName(), TypeDouble.getInstance());
                    }

                });

                expr.typeCheck();
                expr.semanticCheck();

            } catch (PrismLangException e1) {

                // for copying style
                JLabel label = new JLabel();

                // html content in our case the error we want to show
                JEditorPane ep = new JEditorPane("text/html",
                        "<html> There was an error parsing the function. To read about what built-in"
                                + " functions are supported <br>and some more information on the functions, visit "
                                + "<a href='http://www.prismmodelchecker.org/manual/ThePRISMLanguage/Expressions'>Prism expressions site</a>."
                                + "<br><br><font color=red>Error: </font>" + e1.getMessage() + " </html>");

                // handle link events
                ep.addHyperlinkListener(new HyperlinkListener() {
                    @Override
                    public void hyperlinkUpdate(HyperlinkEvent e) {
                        if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                            try {
                                Desktop.getDesktop().browse(e.getURL().toURI());
                            } catch (IOException | URISyntaxException e1) {

                                e1.printStackTrace();
                            }
                        }
                    }
                });
                ep.setEditable(false);
                ep.setBackground(label.getBackground());

                // show the error dialog
                JOptionPane.showMessageDialog(dialog, ep, "Parse Error", JOptionPane.ERROR_MESSAGE);
                return;
            }

            if (radio2d.isSelected()) {

                ParametricGraph graph = null;

                if (newGraph.isSelected()) {

                    graph = new ParametricGraph("");
                } else {

                    for (int i = 0; i < theTabs.getComponentCount(); i++) {

                        if (theTabs.getTitleAt(i).equals(chartOptions.getSelectedItem())) {

                            graph = (ParametricGraph) theTabs.getComponent(i);
                        }
                    }

                }

                dialog.dispose();
                defineConstantsAndPlot(expr, graph, seriesName.getText(), newGraph.isSelected(), true);

            } else if (radio3d.isSelected()) {

                try {

                    expr = (Expression) expr.accept(new ASTTraverseModify() {
                        @Override
                        public Object visit(ExpressionIdent e) throws PrismLangException {
                            return new ExpressionConstant(e.getName(), TypeDouble.getInstance());
                        }

                    });

                    expr.semanticCheck();
                    expr.typeCheck();

                } catch (PrismLangException e1) {
                    e1.printStackTrace();
                }

                if (expr.getAllConstants().size() < 2) {

                    JOptionPane.showMessageDialog(dialog,
                            "There are not enough variables in the function to plot a 3D chart!", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                // its always a new graph
                ParametricGraph3D graph = new ParametricGraph3D(expr);
                dialog.dispose();
                defineConstantsAndPlot(expr, graph, seriesName.getText(), true, false);
            }

            dialog.dispose();
        }
    });

    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });

    // we will show info about the function when field is out of focus
    functionField.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {

            if (!functionField.getText().equals("")) {
                return;
            }

            functionField.setText("Add function expression here....");
            functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15));
            functionField.setForeground(Color.GRAY);
        }

        @Override
        public void focusGained(FocusEvent e) {

            if (!functionField.getText().equals("Add function expression here....")) {
                return;
            }

            functionField.setForeground(Color.BLACK);
            functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15));
            functionField.setText("");
        }
    });

    // show the dialog
    dialog.setVisible(true);
}

From source file:userinterface.properties.GUIGraphHandler.java

public void defineConstantsAndPlot(Expression expr, JPanel graph, String seriesName, Boolean isNewGraph,
        boolean is2D) {

    JDialog dialog;
    JButton ok, cancel;// ww w .  j ava  2  s. com
    JScrollPane scrollPane;
    ConstantPickerList constantList;
    JComboBox<String> xAxis, yAxis;

    //init everything
    dialog = new JDialog(GUIPrism.getGUI());
    dialog.setTitle("Define constants and select axes");
    dialog.setSize(500, 400);
    dialog.setLocationRelativeTo(GUIPrism.getGUI());
    dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS));
    dialog.setModal(true);

    constantList = new ConstantPickerList();
    scrollPane = new JScrollPane(constantList);

    xAxis = new JComboBox<String>();
    yAxis = new JComboBox<String>();

    ok = new JButton("Ok");
    ok.setMnemonic('O');
    cancel = new JButton("Cancel");
    cancel.setMnemonic('C');

    //add all components to their dedicated panels
    JPanel exprPanel = new JPanel(new FlowLayout());
    exprPanel.setBorder(new TitledBorder("Function"));
    exprPanel.add(new JLabel(expr.toString()));

    JPanel axisPanel = new JPanel();
    axisPanel.setBorder(new TitledBorder("Select axis constants"));
    axisPanel.setLayout(new BoxLayout(axisPanel, BoxLayout.Y_AXIS));
    JPanel xAxisPanel = new JPanel(new FlowLayout());
    xAxisPanel.add(new JLabel("X axis:"));
    xAxisPanel.add(xAxis);
    JPanel yAxisPanel = new JPanel(new FlowLayout());
    yAxisPanel.add(new JLabel("Y axis:"));
    yAxisPanel.add(yAxis);
    axisPanel.add(xAxisPanel);
    axisPanel.add(yAxisPanel);

    JPanel constantPanel = new JPanel(new BorderLayout());
    constantPanel.setBorder(new TitledBorder("Please define the following constants"));
    constantPanel.add(scrollPane, BorderLayout.CENTER);
    constantPanel.add(new ConstantHeader(), BorderLayout.NORTH);

    JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    bottomPanel.add(ok);
    bottomPanel.add(cancel);

    //fill the axes components

    for (int i = 0; i < expr.getAllConstants().size(); i++) {

        xAxis.addItem(expr.getAllConstants().get(i));

        if (!is2D)
            yAxis.addItem(expr.getAllConstants().get(i));
    }

    if (!is2D) {
        yAxis.setSelectedIndex(1);
    }

    //fill the constants table

    for (int i = 0; i < expr.getAllConstants().size(); i++) {

        ConstantLine line = new ConstantLine(expr.getAllConstants().get(i), TypeDouble.getInstance());
        constantList.addConstant(line);

        if (!is2D) {
            if (line.getName().equals(xAxis.getSelectedItem().toString())
                    || line.getName().equals(yAxis.getSelectedItem().toString())) {

                line.doFuncEnables(false);
            } else {
                line.doFuncEnables(true);
            }
        }

    }

    //do enables

    if (is2D) {
        yAxis.setEnabled(false);
    }

    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok");
    ok.getActionMap().put("ok", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ok.doClick();
        }
    });

    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "cancel");
    cancel.getActionMap().put("cancel", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cancel.doClick();
        }
    });

    //add action listeners

    xAxis.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (is2D) {
                return;
            }

            String item = xAxis.getSelectedItem().toString();

            if (item.equals(yAxis.getSelectedItem().toString())) {

                int index = yAxis.getSelectedIndex();

                if (index != yAxis.getItemCount() - 1) {
                    yAxis.setSelectedIndex(++index);
                } else {
                    yAxis.setSelectedIndex(--index);
                }

            }

            for (int i = 0; i < constantList.getNumConstants(); i++) {

                ConstantLine line = constantList.getConstantLine(i);

                if (line.getName().equals(xAxis.getSelectedItem().toString())
                        || line.getName().equals(yAxis.getSelectedItem().toString())) {

                    line.doFuncEnables(false);
                } else {

                    line.doFuncEnables(true);
                }

            }
        }
    });

    yAxis.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            String item = yAxis.getSelectedItem().toString();

            if (item.equals(xAxis.getSelectedItem().toString())) {

                int index = xAxis.getSelectedIndex();

                if (index != xAxis.getItemCount() - 1) {
                    xAxis.setSelectedIndex(++index);
                } else {
                    xAxis.setSelectedIndex(--index);
                }
            }

            for (int i = 0; i < constantList.getNumConstants(); i++) {

                ConstantLine line = constantList.getConstantLine(i);

                if (line.getName().equals(xAxis.getSelectedItem().toString())
                        || line.getName().equals(yAxis.getSelectedItem().toString())) {

                    line.doFuncEnables(false);
                } else {

                    line.doFuncEnables(true);
                }

            }
        }
    });

    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            try {

                constantList.checkValid();

            } catch (PrismException e2) {
                JOptionPane.showMessageDialog(dialog,
                        "<html> One or more of the defined constants are invalid. <br><br> <font color=red>Error: </font>"
                                + e2.getMessage() + "</html>",
                        "Parse Error", JOptionPane.ERROR_MESSAGE);
                return;
            }

            if (is2D) {

                // it will always be a parametric graph in 2d case
                ParametricGraph pGraph = (ParametricGraph) graph;

                ConstantLine xAxisConstant = constantList.getConstantLine(xAxis.getSelectedItem().toString());

                if (xAxisConstant == null) {
                    //should never happen
                    JOptionPane.showMessageDialog(dialog, "The selected axis is invalid.", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                double xStartValue = Double.parseDouble(xAxisConstant.getStartValue());
                double xEndValue = Double.parseDouble(xAxisConstant.getEndValue());
                double xStepValue = Double.parseDouble(xAxisConstant.getStepValue());

                int seriesCount = 0;

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line.getName().equals(xAxis.getSelectedItem().toString())) {
                        seriesCount++;
                    } else {

                        seriesCount += line.getTotalNumOfValues();

                    }
                }

                // if there will be too many series to be plotted, ask the user if they are sure they know what they are doing
                if (seriesCount > 10) {

                    int res = JOptionPane.showConfirmDialog(dialog,
                            "This configuration will create " + seriesCount + " series. Continue?", "Confirm",
                            JOptionPane.YES_NO_OPTION);

                    if (res == JOptionPane.NO_OPTION) {
                        return;
                    }

                }

                Values singleValuesGlobal = new Values();

                //add the single values to a global values list

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line.getTotalNumOfValues() == 1) {

                        double singleValue = Double.parseDouble(line.getSingleValue());
                        singleValuesGlobal.addValue(line.getName(), singleValue);
                    }
                }

                // we just have one variable so we can plot directly
                if (constantList.getNumConstants() == 1
                        || singleValuesGlobal.getNumValues() == constantList.getNumConstants() - 1) {

                    SeriesKey key = pGraph.addSeries(seriesName);

                    pGraph.hideShape(key);
                    pGraph.getXAxisSettings().setHeading(xAxis.getSelectedItem().toString());
                    pGraph.getYAxisSettings().setHeading("function");

                    for (double x = xStartValue; x <= xEndValue; x += xStepValue) {

                        double ans = -1;

                        Values vals = new Values();
                        vals.addValue(xAxis.getSelectedItem().toString(), x);

                        for (int ii = 0; ii < singleValuesGlobal.getNumValues(); ii++) {

                            try {
                                vals.addValue(singleValuesGlobal.getName(ii),
                                        singleValuesGlobal.getDoubleValue(ii));
                            } catch (PrismLangException e1) {
                                e1.printStackTrace();
                            }

                        }

                        try {
                            ans = expr.evaluateDouble(vals);
                        } catch (PrismLangException e1) {
                            e1.printStackTrace();
                        }

                        pGraph.addPointToSeries(key, new PrismXYDataItem(x, ans));

                    }

                    if (isNewGraph) {
                        addGraph(pGraph);
                    }

                    dialog.dispose();
                    return;
                }

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line == xAxisConstant || singleValuesGlobal.contains(line.getName())) {
                        continue;
                    }

                    double lineStart = Double.parseDouble(line.getStartValue());
                    double lineEnd = Double.parseDouble(line.getEndValue());
                    double lineStep = Double.parseDouble(line.getStepValue());

                    for (double j = lineStart; j < lineEnd; j += lineStep) {

                        SeriesKey key = pGraph.addSeries(seriesName);
                        pGraph.hideShape(key);

                        for (double x = xStartValue; x <= xEndValue; x += xStepValue) {

                            double ans = -1;

                            Values vals = new Values();
                            vals.addValue(xAxis.getSelectedItem().toString(), x);
                            vals.addValue(line.getName(), j);

                            for (int ii = 0; ii < singleValuesGlobal.getNumValues(); ii++) {

                                try {
                                    vals.addValue(singleValuesGlobal.getName(ii),
                                            singleValuesGlobal.getDoubleValue(ii));
                                } catch (PrismLangException e1) {
                                    // TODO Auto-generated catch block
                                    e1.printStackTrace();
                                }

                            }

                            for (int ii = 0; ii < constantList.getNumConstants(); ii++) {

                                if (constantList.getConstantLine(ii) == xAxisConstant
                                        || singleValuesGlobal
                                                .contains(constantList.getConstantLine(ii).getName())
                                        || constantList.getConstantLine(ii) == line) {

                                    continue;
                                }

                                ConstantLine temp = constantList.getConstantLine(ii);
                                double val = Double.parseDouble(temp.getStartValue());

                                vals.addValue(temp.getName(), val);
                            }

                            try {
                                ans = expr.evaluateDouble(vals);
                            } catch (PrismLangException e1) {
                                e1.printStackTrace();
                            }

                            pGraph.addPointToSeries(key, new PrismXYDataItem(x, ans));
                        }
                    }

                }

                if (isNewGraph) {
                    addGraph(graph);
                }
            } else {

                // this will always be a parametric graph for the 3d case
                ParametricGraph3D pGraph = (ParametricGraph3D) graph;

                //add the graph to the gui
                addGraph(pGraph);

                //Get the constants we want to put on the x and y axis
                ConstantLine xAxisConstant = constantList.getConstantLine(xAxis.getSelectedItem().toString());
                ConstantLine yAxisConstant = constantList.getConstantLine(yAxis.getSelectedItem().toString());

                //add the single values to a global values list

                Values singleValuesGlobal = new Values();

                for (int i = 0; i < constantList.getNumConstants(); i++) {

                    ConstantLine line = constantList.getConstantLine(i);

                    if (line.getTotalNumOfValues() == 1) {

                        double singleValue = Double.parseDouble(line.getSingleValue());
                        singleValuesGlobal.addValue(line.getName(), singleValue);
                    }
                }

                pGraph.setGlobalValues(singleValuesGlobal);
                pGraph.setAxisConstants(xAxis.getSelectedItem().toString(), yAxis.getSelectedItem().toString());
                pGraph.setBounds(xAxisConstant.getStartValue(), xAxisConstant.getEndValue(),
                        yAxisConstant.getStartValue(), yAxisConstant.getEndValue());

                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        //plot the graph
                        pGraph.plot(expr.toString(), xAxis.getSelectedItem().toString(), "Function",
                                yAxis.getSelectedItem().toString());

                        //calculate the sampling rates from the step sizes as given by the user

                        int xSamples = (int) ((Double.parseDouble(xAxisConstant.getEndValue())
                                - Double.parseDouble(xAxisConstant.getStartValue()))
                                / Double.parseDouble(xAxisConstant.getStepValue()));
                        int ySamples = (int) ((Double.parseDouble(xAxisConstant.getEndValue())
                                - Double.parseDouble(xAxisConstant.getStartValue()))
                                / Double.parseDouble(xAxisConstant.getStepValue()));

                        pGraph.setSamplingRates(xSamples, ySamples);
                    }
                });

            }

            dialog.dispose();
        }
    });

    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });

    //add everything to the dialog show the dialog

    dialog.add(exprPanel);
    dialog.add(axisPanel);
    dialog.add(constantPanel);
    dialog.add(bottomPanel);
    dialog.setVisible(true);

}