Example usage for javax.swing.table DefaultTableModel removeRow

List of usage examples for javax.swing.table DefaultTableModel removeRow

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableModel removeRow.

Prototype

public void removeRow(int row) 

Source Link

Document

Removes the row at row from the model.

Usage

From source file:interfaces.InterfazPrincipal.java

private void botonGuardarFacturaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonGuardarFacturaActionPerformed
    // TODO add your handling code here:

    String id_cliente = jTextField_Factura_Cliente_Id.getText();

    if (id_cliente.equals("") || valorActualFactura.equals("0.0")) {
        JOptionPane.showMessageDialog(this,
                "Por favor indique el monto de la factura o ingrese los productos a ella");

    } else {/* ww w  .  j a  v a 2s  .  c  o m*/
        //System.err.println("Numero de filas" + TablaDeFacturaProducto.getRowCount());
        ArrayList<String> lineaCodigoProductos = new ArrayList<String>();
        ArrayList<String> lineaUnidadesProductos = new ArrayList<String>();
        ArrayList<String> lineaMontoProductos = new ArrayList<String>();
        double monto = 0d;
        try {
            double pago = Double.parseDouble(
                    (String) JOptionPane.showInputDialog("Ingrese por favor el monto pagado por el cliente"));
            while (pago < 0.0) {
                pago = Double.parseDouble((String) JOptionPane.showInputDialog(
                        "El pago debe ser positivo \nIngrese por favor el monto pagado por el cliente"));

            }

            double prestamo = Double.parseDouble(valorActualPrestamo.getText());
            double montoFactura = Double.parseDouble(valorActualFactura.getText());
            while (montoFactura - pago < 0.0) {
                pago = Double.parseDouble((String) JOptionPane.showInputDialog(
                        "El pago no debe ser superior al monto de la factura \nIngrese por favor el monto pagado por el cliente"));

            }
            if (prestamo - montoFactura <= 0.0) {
                int opcion = JOptionPane.showConfirmDialog(this,
                        "Con este prstamo el cliente excede su limite de prestamos. \n Desea continuar?",
                        "Mensaje del sistema", JOptionPane.YES_NO_OPTION);
                if (opcion != JOptionPane.YES_OPTION) {
                    return;
                }

            }

            for (int i = 0; i < TablaDeFacturaProducto.getRowCount(); i++) {
                /*
                 * Fila 0: ID producto
                 * Fila 4: Cantidad
                 */
                String ProductoId = String.valueOf(TablaDeFacturaProducto.getValueAt(i, 0));
                lineaCodigoProductos.add(ProductoId);

                int numeroUnidades = Integer.parseInt(String.valueOf(TablaDeFacturaProducto.getValueAt(i, 4)));

                String unidades = String.valueOf(numeroUnidades);
                lineaUnidadesProductos.add(unidades);

                double valorUnitario = Double
                        .parseDouble(String.valueOf(TablaDeFacturaProducto.getValueAt(i, 5)));
                double valorProductoTotal = numeroUnidades * valorUnitario;
                lineaMontoProductos.add(String.valueOf(valorProductoTotal));

                monto += valorProductoTotal;
            }

            if (TablaDeFacturaProducto.getRowCount() == 0) {
                monto = Double.parseDouble(valorActualFactura.getText());
            }

            String estado = "";
            if (monto == pago) {
                estado = "pagado";
            } else {
                estado = "fiado";
            }

            ControladorFactura controladorFactura = new ControladorFactura();
            //String[] selection = {"cliente_id", "fecha", "estado", "identificacionCliente"};
            Calendar calendario = Calendar.getInstance();
            String dia = Integer.toString(calendario.get(Calendar.DATE));
            String mes = Integer.toString(calendario.get(Calendar.MONTH)) + 1;
            String annio = Integer.toString(calendario.get(Calendar.YEAR));
            Date date = new Date();
            DateFormat hourFormat = new SimpleDateFormat("HH:mm:ss");
            String hora = hourFormat.format(date);

            String fecha = annio + "-" + mes + "-" + dia + " " + hora;
            String[] selection = { id_cliente, fecha, estado, String.valueOf(monto) };
            ArrayList<String[]> facturaActual = controladorFactura.insertFactura(selection);

            //Ingresar productos
            if (TablaDeFacturaProducto.getRowCount() > 0) {
                ControladorFactura_Productos controladorFactura_Productos = new ControladorFactura_Productos();
                for (int i = 0; i < lineaCodigoProductos.size(); i++) {
                    //        String [] selection = {"factura_id","producto_id","unidades","precio"};
                    String[] insertarLineaProducto = { facturaActual.get(0)[0], lineaCodigoProductos.get(i),
                            lineaUnidadesProductos.get(i), lineaMontoProductos.get(i) };
                    controladorFactura_Productos.insertFactura_Productos(insertarLineaProducto);
                }
            }
            //Ingresar flujo factura
            ControladorFlujoFactura controladorFlujoFactura = new ControladorFlujoFactura();
            // String [] selection = {"factura_id","tipo_flujo","fecha","identificacionCliente"};

            String value[] = { facturaActual.get(0)[0], "abono", fecha, String.valueOf(pago) };
            controladorFlujoFactura.insertFlujo_Factura(value);

            String value2[] = { facturaActual.get(0)[0], "deuda", fecha, String.valueOf(monto) };
            controladorFlujoFactura.insertFlujo_Factura(value2);

            botonEstablecerMontoFactura.setEnabled(false);
            botonAgregarProducto.setEnabled(false);
            botonGuardarFactura.setEnabled(false);
            jTextField_Factura_Cliente_Id.setText("");

            DefaultTableModel modeloTabla = (DefaultTableModel) TablaDeFacturaProducto.getModel();

            for (int i = 0; i < modeloTabla.getRowCount(); i++) {
                modeloTabla.removeRow(i);
            }

            modeloTabla.setRowCount(0);
            TablaDeFacturaProducto.setModel(modeloTabla);

            Object opciones[] = { "Cerrar", "Imprimir", "Guardar en disco" };
            GenerarFactura generarFactura = new GenerarFactura();
            int opcion = JOptionPane.showOptionDialog(this,
                    "Se ha guardado la factura con xito\nQue desea hacer?", "Elija una opcin",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, opciones, null);

            switch (opcion) {
            case 1:
                generarFactura.imprimirFactura(Integer.parseInt(facturaActual.get(0)[0]), this);
                break;
            case 2:
                PDDocument documento = generarFactura.crearFactura(Integer.parseInt(facturaActual.get(0)[0]),
                        this);
                JFileChooser fc = new JFileChooser();
                FileNameExtensionFilter filter = new FileNameExtensionFilter("Archivo PDF", "pdf", "text");
                fc.setFileFilter(filter);
                fc.showSaveDialog(this);
                if (fc.getSelectedFile() != null) {
                    File selectedFile = fc.getSelectedFile();
                    try {

                        documento.save(selectedFile + ".pdf");
                        JOptionPane.showMessageDialog(this, "El archivo ha sido guardado en disco");

                    } catch (Exception ex) {
                        JOptionPane.showMessageDialog(this, "EL Archivo no se puede leer!");
                    }
                }
                break;

            default:
                break;
            }

            nombreClienteCrearFactura.setText("");
            IdentificacionClienteBuscarFactura.setText("");
            valorActualPrestamo.setText("");
            jTextField_Factura_Cliente_Id.setText("");
            jTextField_Factura_Producto_Nombre.setText("");
            jTextField_Factura_Producto_Descripcion.setText("");
            valorMontoFactura.setText("");
            valorActualFactura.setText("0.0");
            valorActualPrestamo.setText("0.0");
            botonGuardarFactura.setEnabled(false);
            botonEstablecerMontoFactura.setEnabled(false);
            botonAgregarProducto.setEnabled(false);
        } catch (Exception e) {
        }

    }

}

From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java

private void miscSplit() {
    if (jideTabbedPane1.getSelectedIndex() == 0) {
        DefaultTableModel model = (DefaultTableModel) jSourcesTable.getModel();
        int sources = model.getRowCount();
        if (sources == 0) {
            showInfo("Keine Herkunftsdrfer eingetragen");
            return;
        }/*  ww  w.  j  a v  a2  s .c o m*/
        List<Village> sourceVillages = new LinkedList<Village>();
        Hashtable<Village, UnitHolder> attTable = new Hashtable<Village, UnitHolder>();
        Hashtable<Village, UnitHolder> fakeTable = new Hashtable<Village, UnitHolder>();
        for (int i = 0; i < sources; i++) {
            Village sourceVillage = (Village) model.getValueAt(i, jSourcesTable.convertColumnIndexToModel(0));
            if (!sourceVillages.contains(sourceVillage)) {
                sourceVillages.add(sourceVillage);
                boolean fake = (Boolean) jSourcesTable.getValueAt(i,
                        jSourcesTable.convertColumnIndexToModel(2));
                UnitHolder unit = (UnitHolder) jSourcesTable.getValueAt(i,
                        jSourcesTable.convertColumnIndexToModel(1));
                if (fake) {
                    fakeTable.put(sourceVillage, unit);
                } else {
                    attTable.put(sourceVillage, unit);
                }
            }
        }
        mTroopSplitDialog.setupAndShow(sourceVillages);
        TroopSplit[] splits = mTroopSplitDialog.getSplits();
        if (splits.length == 0) {
            //canceled
            return;
        }
        for (int i = sources - 1; i >= 0; i--) {
            model.removeRow(i);
        }
        int overallSplitCount = 0;
        for (TroopSplit split : splits) {
            overallSplitCount += split.getSplitCount();
            for (int i = 0; i < split.getSplitCount(); i++) {
                boolean isFake = false;
                UnitHolder unit = attTable.get(split.getVillage());
                if (unit == null) {
                    unit = fakeTable.get(split.getVillage());
                    isFake = true;
                }
                model.addRow(new Object[] { split.getVillage(), unit, isFake, 0 });
            }
        }

        String message = ((sourceVillages.size() == 1) ? "Herkunftsdorf "
                : sourceVillages.size() + " Herkunftsdrfer ")
                + ((overallSplitCount == 1) ? "einmal" : overallSplitCount + " mal ") + " geteilt";
        showSuccess(message);
    } else {
        showInfo("Diese Funktion ist nur fr Herkunftsdrfer verfgbar");
    }
}

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  ww.ja  v  a2s .  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 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:semaforo.Semaforo.java

public void setUp() {

    this.setTitle("Semaforo");
    URL hj = getClass().getResource("resources/semaforo.png");
    setIconImage(Toolkit.getDefaultToolkit().getImage(hj));

    listener = new UpdateTableListener() {

        @Override/*from w w  w .jav  a  2 s.  c om*/
        public void addTickers() {

            // Add in Tickers Table
            Settings settings = Controller.getSettings();
            synchronized (updateLock) {
                update = 1;
            }
            CustomRenderer cr = new CustomRenderer(TableTicker.getDefaultRenderer(Object.class),
                    Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY);

            TableTicker.setDefaultRenderer(Object.class, cr);
            DefaultTableModel model = (DefaultTableModel) TableTicker.getModel();

            Object[] o = new Object[2];
            for (int i = model.getRowCount(); i < settings.getTickers().size(); i++) {

                o[0] = settings.getTickers().get(i).getName();
                o[1] = 0;
                model.addRow(o);
            }

            // Resize the vector of values
            num_positions = Controller.getSettings().getTickers().size();

            num_positions++;

            // Add in Week Tables
            CustomRenderer cr1 = new CustomRenderer(TableWeek1.getDefaultRenderer(Object.class),
                    Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY);
            CustomRenderer cr2 = new CustomRenderer(TableWeek2.getDefaultRenderer(Object.class),
                    Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY);
            CustomRenderer cr3 = new CustomRenderer(TableWeek3.getDefaultRenderer(Object.class),
                    Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY);

            // Table Week 1
            TableWeek1.setDefaultRenderer(Object.class, cr1);
            DefaultTableModel model1 = (DefaultTableModel) TableWeek1.getModel();

            Object[] o1 = new Object[10];

            // Table Week 2
            TableWeek2.setDefaultRenderer(Object.class, cr2);
            DefaultTableModel model2 = (DefaultTableModel) TableWeek2.getModel();

            Object[] o2 = new Object[10];

            // Table Week 3
            TableWeek3.setDefaultRenderer(Object.class, cr3);
            DefaultTableModel model3 = (DefaultTableModel) TableWeek3.getModel();

            Object[] o3 = new Object[10];

            for (int i = model1.getRowCount(); i < settings.getTickers().size(); i++) {

                model1.addRow(o1);

                model2.addRow(o2);

                model3.addRow(o3);
            }

            synchronized (updateLock) {
                update = 0;
            }

        }

        @Override
        public boolean canUpdate() {
            return update == 1;
        }

        @Override
        public void stopThread() {
            synchronized (updateLock) {
                update = 2;
            }
        }

        @Override
        public void updateTickers() {
            synchronized (updateLock) {
                Settings settings = Controller.getSettings();
                update = 2;

                CustomRenderer cr = new CustomRenderer(TableTicker.getDefaultRenderer(Object.class),
                        Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY, Color.LIGHT_GRAY);

                TableTicker.setDefaultRenderer(Object.class, cr);

                for (int i = 0; i < settings.getTickers().size(); i++) {

                    TableTicker.setValueAt(settings.getTickers().get(i).getName(), i, 0);
                }

                update = 0;
            }
        }

        @Override
        public void updateVariables() {
            Settings settings = Controller.getSettings();
            validate();
            repaint();

            timer.setDelay(settings.getVaribable(DDBB.RATIO_REFRESCO));
        }

        @Override
        public void reomveTicker(int index) {
            synchronized (updateLock) {
                // Add in Tickers Table

                update = 2;

                DefaultTableModel model = (DefaultTableModel) TableTicker.getModel();
                model.removeRow(index);

                // Remove row in Week Tables
                // Table Week 1
                DefaultTableModel model1 = (DefaultTableModel) TableWeek1.getModel();

                // Table Week 2
                DefaultTableModel model2 = (DefaultTableModel) TableWeek2.getModel();

                // Table Week 3
                DefaultTableModel model3 = (DefaultTableModel) TableWeek3.getModel();

                // Table Week 1
                model1.removeRow(index);

                // Table Week 2
                model2.removeRow(index);

                // Table Week 3
                model3.removeRow(index);

                num_positions = Controller.getSettings().getTickers().size();

                update = 0;

            }
        }
    };

    Controller.setup(listener);/* = new Controller();*/

    Settings settings = Controller.getSettings();

    num_positions = Controller.getSettings().getTickers().size();

    loadTableTickers();

    loadTableWeek(TableWeek1, WEEK1);

    loadTableWeek(TableWeek2, WEEK2);

    loadTableWeek(TableWeek3, WEEK3);

    String cad = settings.getVaribable(DDBB.RANGO_1) > 1 ? "weeks" : "week";

    cad = settings.getVaribable(DDBB.RANGO_2) > 1 ? "weeks" : "week";

    cad = settings.getVaribable(DDBB.RANGO_3) > 1 ? "weeks" : "week";

    TableTicker.setCellSelectionEnabled(false);
    TableWeek1.setCellSelectionEnabled(false);
    TableWeek2.setCellSelectionEnabled(false);
    TableWeek3.setCellSelectionEnabled(false);
    /*validate();
     repaint();*/
    settingsGUI = new SettingsGUI(listener);
    features = new Features();
    features.setBackground(java.awt.Color.BLACK);

}

From source file:interfaces.InterfazPrincipal.java

private void TablaDeFacturaProductoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TablaDeFacturaProductoMouseClicked
    final int fila = TablaDeFacturaProducto.getSelectedRow();
    final DefaultTableModel modeloTabla = (DefaultTableModel) TablaDeFacturaProducto.getModel();

    //int identificacion = (int) TablaDeFacturaProducto.getValueAt(fila, 0);        // TODO add your handling code here:
    final JDialog dialogoEdicionProducto = new JDialog(this);
    dialogoEdicionProducto.setTitle("Editar producto");
    dialogoEdicionProducto.setSize(250, 150);
    dialogoEdicionProducto.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;/*from  w  w  w. j a  v a 2s  .c  o m*/
    c.gridy = 0;
    c.gridwidth = 3;
    c.insets = new Insets(15, 40, 10, 0);
    Font textoGrande = new Font("Arial", 1, 18);
    editarTextoPrincipalDialogo.setFont(textoGrande);
    panelDialogo.add(editarTextoPrincipalDialogo, c);

    c.insets = new Insets(0, 0, 0, 0);
    c.gridwidth = 0;

    c.gridy = 1;
    c.gridx = 0;
    JLabel textoUnidades = new JLabel("Unidades");
    panelDialogo.add(textoUnidades, c);

    c.gridy = 1;
    c.gridx = 1;
    c.gridwidth = 2;
    final JTextField valorUnidades = new JTextField();
    valorUnidades.setText(String.valueOf(modeloTabla.getValueAt(fila, 4)));

    panelDialogo.add(valorUnidades, c);

    c.gridwidth = 1;
    c.gridy = 2;
    c.gridx = 0;
    JButton guardarCambios = new JButton("Guardar");
    panelDialogo.add(guardarCambios, c);

    c.gridy = 2;
    c.gridx = 1;
    JButton eliminarProducto = new JButton("Eliminar");
    panelDialogo.add(eliminarProducto, c);

    c.gridy = 2;
    c.gridx = 2;
    JButton botonCancelar = new JButton("Cerrar");
    panelDialogo.add(botonCancelar, c);
    botonCancelar.addActionListener(new ActionListener() {

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

    eliminarProducto.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            double precio = (double) modeloTabla.getValueAt(fila, 6);
            double precioActual = Double.parseDouble(valorActualFactura.getText());

            precioActual -= precio;
            valorActualFactura.setText(String.valueOf(precioActual));
            modeloTabla.removeRow(fila);

            dialogoEdicionProducto.dispose();

        }
    });
    guardarCambios.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                int numeroUnidades = Integer.parseInt(valorUnidades.getText());
                modeloTabla.setValueAt(numeroUnidades, fila, 4);

                double precioARestar = (double) modeloTabla.getValueAt(fila, 6);

                double valorUnitario = Double.parseDouble((String) modeloTabla.getValueAt(fila, 5));

                double precioNuevo = valorUnitario * numeroUnidades;

                modeloTabla.setValueAt(precioNuevo, fila, 6);
                double precioActual = Double.parseDouble(valorActualFactura.getText());
                precioActual -= precioARestar;
                precioActual += precioNuevo;
                valorActualFactura.setText(String.valueOf(precioActual));

                dialogoEdicionProducto.dispose();

            } catch (Exception eve) {
                JOptionPane.showMessageDialog(dialogoEdicionProducto, "Por favor ingrese un valor numrico");
            }
        }
    });

    dialogoEdicionProducto.add(panelDialogo);
    dialogoEdicionProducto.setVisible(true);
}

From source file:com.peterbochs.PeterBochsDebugger.java

protected void updateAddressTranslate() {
    try {/*  w ww.ja  v  a  2  s. c om*/
        jStatusLabel.setText("Updating Address translate");
        // commandReceiver.setCommandNoOfLine(-1);
        commandReceiver.clearBuffer();
        commandReceiver.shouldShow = false;
        sendCommand("info tab");
        Thread.currentThread();
        String result = commandReceiver.getCommandResultUntilEnd();
        String[] lines = result.split("\n");
        DefaultTableModel model = (DefaultTableModel) jAddressTranslateTable.getModel();
        while (model.getRowCount() > 0) {
            model.removeRow(0);
        }
        for (int x = 1; x < lines.length; x++) {
            Vector<String> strs = new Vector<String>(Arrays.asList(lines[x].trim().split("->")));
            model.addRow(strs);
        }
        ((DefaultTableModel) jAddressTranslateTable.getModel()).fireTableDataChanged();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void updateBreakpoint() {
    try {//from   w ww.  ja  v a 2  s.co  m
        jStatusLabel.setText("Updating breakpoint");
        // commandReceiver.setCommandNoOfLine(-1);
        commandReceiver.clearBuffer();
        sendCommand("info break");
        Thread.currentThread();
        String result = commandReceiver.getCommandResultUntilEnd();
        String[] lines = result.split("\n");
        DefaultTableModel model = (DefaultTableModel) breakpointTable.getModel();
        while (model.getRowCount() > 0) {
            model.removeRow(0);
        }

        for (int x = 1; x < lines.length; x++) {
            if (lines[x].contains("breakpoint")) {
                Vector<String> strs = new Vector<String>(Arrays.asList(lines[x].trim().split(" \\s")));
                strs.add("0"); // hit count
                if (strs.size() > 1) {
                    strs.remove(1);
                    model.addRow(strs);
                }
            }
        }

        this.jRefreshELFBreakpointButtonActionPerformed(null);
        jStatusLabel.setText("");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

@SuppressWarnings("unused")
private void updateInstructionUsingNasm(BigInteger address) {
    try {//from ww w  . j  a  va 2s . c om
        if (address == null) {
            address = BigInteger.valueOf(0);
        }
        jStatusLabel.setText("Updating instruction");
        String result = Disassemble.disassemble(address, 32);
        String lines[] = result.split("\n");
        if (lines.length > 0) {
            DefaultTableModel model = (DefaultTableModel) instructionTable.getModel();
            while (model.getRowCount() > 0) {
                model.removeRow(0);
            }
            jStatusProgressBar.setMaximum(lines.length - 1);
            for (int x = 0; x < lines.length; x++) {
                jStatusProgressBar.setValue(x);
                try {
                    model.addRow(new String[] { lines[x].substring(0, 10).trim(), lines[x].substring(20).trim(),
                            lines[x].substring(10, 20).trim() });
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void parseELF(File elfFile) {
    jELFDumpPanel.remove(jTabbedPane4);//from www.ja  va  2s . com
    jTabbedPane4 = null;
    jELFDumpPanel.add(getJTabbedPane4(), BorderLayout.CENTER);

    HashMap map = ElfUtil.getELFDetail(elfFile);
    if (map != null) {
        // header
        DefaultTableModel model = (DefaultTableModel) jELFHeaderTable.getModel();
        while (model.getRowCount() > 0) {
            model.removeRow(0);
        }
        Set entries = ((HashMap) map.get("header")).entrySet();
        Iterator it = entries.iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();

            Vector<String> v = new Vector<String>();
            v.add(entry.getKey().toString());

            String bytesStr = "";

            if (entry.getValue().getClass() == Short.class) {
                jStatusLabel.setText("header " + Long.toHexString((Short) entry.getValue()));
                bytesStr += "0x" + Long.toHexString((Short) entry.getValue());
            } else if (entry.getValue().getClass() == Integer.class) {
                bytesStr += "0x" + Long.toHexString((Integer) entry.getValue());
            } else if (entry.getValue().getClass() == Long.class) {
                bytesStr += "0x" + Long.toHexString((Long) entry.getValue());
            } else {
                int b[] = (int[]) entry.getValue();
                for (int x = 0; x < b.length; x++) {
                    bytesStr += "0x" + Long.toHexString(b[x]) + " ";
                }
            }

            v.add(bytesStr);
            model.addRow(v);
        }
        // end header

        // section
        model = (DefaultTableModel) jELFSectionTable.getModel();
        while (model.getRowCount() > 0) {
            model.removeRow(0);
        }
        int sectionNo = 0;
        while (map.get("section" + sectionNo) != null) {
            entries = ((HashMap) map.get("section" + sectionNo)).entrySet();
            it = entries.iterator();
            Vector<String> v = new Vector<String>();
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();

                String bytesStr = "";
                if (entry.getValue().getClass() == Short.class) {
                    jStatusLabel.setText("section " + Long.toHexString((Short) entry.getValue()));
                    bytesStr += "0x" + Long.toHexString((Short) entry.getValue());
                } else if (entry.getValue().getClass() == Integer.class) {
                    bytesStr += "0x" + Long.toHexString((Integer) entry.getValue());
                } else if (entry.getValue().getClass() == String.class) {
                    bytesStr = (String) entry.getValue();
                } else if (entry.getValue().getClass() == Long.class) {
                    bytesStr += "0x" + Long.toHexString((Long) entry.getValue());
                } else {
                    int b[] = (int[]) entry.getValue();
                    for (int x = 0; x < b.length; x++) {
                        bytesStr += "0x" + Long.toHexString(b[x]) + " ";
                    }
                }

                v.add(bytesStr);
            }
            model.addRow(v);
            sectionNo++;
        }
        // end section

        // program header
        model = (DefaultTableModel) jProgramHeaderTable.getModel();
        while (model.getRowCount() > 0) {
            model.removeRow(0);
        }
        int programHeaderNo = 0;
        while (map.get("programHeader" + programHeaderNo) != null) {
            entries = ((HashMap) map.get("programHeader" + programHeaderNo)).entrySet();
            it = entries.iterator();
            Vector<String> v = new Vector<String>();
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();

                String bytesStr = "";
                if (entry.getValue().getClass() == Short.class) {
                    jStatusLabel.setText("Program header " + Long.toHexString((Short) entry.getValue()));
                    bytesStr += "0x" + Long.toHexString((Short) entry.getValue());
                } else if (entry.getValue().getClass() == Integer.class) {
                    bytesStr += "0x" + Long.toHexString((Integer) entry.getValue());
                } else if (entry.getValue().getClass() == Long.class) {
                    bytesStr += "0x" + Long.toHexString((Long) entry.getValue());
                } else if (entry.getValue().getClass() == String.class) {
                    bytesStr += "0x" + entry.getValue();
                } else {
                    int b[] = (int[]) entry.getValue();
                    for (int x = 0; x < b.length; x++) {
                        bytesStr += "0x" + Long.toHexString(b[x]) + " ";
                    }
                }

                v.add(bytesStr);
            }
            model.addRow(v);
            programHeaderNo++;
        }
        // program header

        // symbol table
        int symbolTableNo = 0;
        while (map.get("symbolTable" + symbolTableNo) != null) {
            DefaultTableModel tempTableModel = new DefaultTableModel(null, new String[] { "No.", "st_name",
                    "st_value", "st_size", "st_info", "st_other", "p_st_shndx" });
            JTable tempTable = new JTable();
            HashMap tempMap = (HashMap) map.get("symbolTable" + symbolTableNo);
            Vector<LinkedHashMap> v = (Vector<LinkedHashMap>) tempMap.get("vector");
            for (int x = 0; x < v.size(); x++) {
                Vector tempV = new Vector();
                jStatusLabel.setText("Symbol table " + x);
                tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("No.")));
                tempV.add(v.get(x).get("st_name"));
                tempV.add("0x" + Long.toHexString((Long) v.get(x).get("st_value")));
                tempV.add("0x" + Long.toHexString((Long) v.get(x).get("st_size")));
                tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("st_info")));
                tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("st_other")));
                tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("p_st_shndx")));

                tempTableModel.addRow(tempV);
            }

            tempTable.setModel(tempTableModel);
            JScrollPane tempScrollPane = new JScrollPane();
            tempScrollPane.setViewportView(tempTable);
            jTabbedPane4.addTab(tempMap.get("name").toString(), null, tempScrollPane, null);

            symbolTableNo++;
        }
        // end symbol table

        // note
        int noteSectionNo = 0;
        while (map.get("note" + noteSectionNo) != null) {
            DefaultTableModel tempTableModel = new DefaultTableModel(null,
                    new String[] { "No.", "namesz", "descsz", "type", "name", "desc" });
            JTable tempTable = new JTable();
            HashMap tempMap = (HashMap) map.get("note" + noteSectionNo);
            Vector<LinkedHashMap> v = (Vector<LinkedHashMap>) tempMap.get("vector");
            for (int x = 0; x < v.size(); x++) {
                Vector tempV = new Vector();
                jStatusLabel.setText("Note " + x);
                tempV.add("0x" + Long.toHexString((Integer) v.get(x).get("No.")));
                tempV.add("0x" + Long.toHexString((Long) v.get(x).get("namesz")));
                tempV.add("0x" + Long.toHexString((Long) v.get(x).get("descsz")));
                tempV.add("0x" + Long.toHexString((Long) v.get(x).get("type")));
                tempV.add(v.get(x).get("name"));
                tempV.add(v.get(x).get("desc"));

                tempTableModel.addRow(tempV);
            }

            tempTable.setModel(tempTableModel);
            JScrollPane tempScrollPane = new JScrollPane();
            tempScrollPane.setViewportView(tempTable);
            jTabbedPane4.addTab(tempMap.get("name").toString(), null, tempScrollPane, null);

            noteSectionNo++;
        }
        // end note
    }

    try {
        jStatusLabel.setText("running objdump -DS");
        Process process = Runtime.getRuntime().exec("objdump -DS " + elfFile.getAbsolutePath());
        InputStream input = process.getInputStream();
        String str = "";
        byte b[] = new byte[102400];
        int len;
        while ((len = input.read(b)) > 0) {
            str += new String(b, 0, len);
        }
        jEditorPane1.setText(str);

        jStatusLabel.setText("readelf -r");
        process = Runtime.getRuntime().exec("readelf -r " + elfFile.getAbsolutePath());
        input = process.getInputStream();
        str = "";
        b = new byte[102400];
        while ((len = input.read(b)) > 0) {
            str += new String(b, 0, len);
        }
        jSearchRelPltEditorPane.setText(str);

        jStatusLabel.setText("readelf -d");
        process = Runtime.getRuntime().exec("readelf -d " + elfFile.getAbsolutePath());
        input = process.getInputStream();
        str = "";
        b = new byte[102400];
        while ((len = input.read(b)) > 0) {
            str += new String(b, 0, len);
        }
        input.close();
        jSearchDynamicEditorPane.setText(str);

        jStatusLabel.setText("");
    } catch (IOException e) {
        e.printStackTrace();
    }
    // end symbol table
}

From source file:com.peterbochs.PeterBochsDebugger.java

public void updatePageTable(BigInteger pageDirectoryBaseAddress) {
    Vector<IA32PageDirectory> ia32_pageDirectories = new Vector<IA32PageDirectory>();
    try {//from www  .ja va2 s  . co m
        commandReceiver.clearBuffer();
        commandReceiver.shouldShow = false;
        jStatusLabel.setText("Updating page table");
        // commandReceiver.setCommandNoOfLine(512);
        sendCommand("xp /4096bx " + pageDirectoryBaseAddress);
        float totalByte2 = 4096 - 1;
        totalByte2 = totalByte2 / 8;
        int totalByte3 = (int) Math.floor(totalByte2);
        String realEndAddressStr;
        String realStartAddressStr;
        BigInteger realStartAddress = pageDirectoryBaseAddress;
        realStartAddressStr = realStartAddress.toString(16);
        BigInteger realEndAddress = realStartAddress.add(BigInteger.valueOf(totalByte3 * 8));
        realEndAddressStr = String.format("%08x", realEndAddress);
        String result = commandReceiver.getCommandResult(realStartAddressStr, realEndAddressStr, null);
        if (result != null) {
            String[] lines = result.split("\n");
            DefaultTableModel model = (DefaultTableModel) jPageDirectoryTable.getModel();
            while (model.getRowCount() > 0) {
                model.removeRow(0);
            }
            jStatusProgressBar.setMaximum(lines.length - 1);

            for (int y = 0; y < lines.length; y++) {
                jStatusProgressBar.setValue(y);
                String[] b = lines[y].replaceFirst("^.*:", "").trim().split("\t");

                for (int z = 0; z < 2; z++) {
                    try {
                        int bytes[] = new int[4];
                        for (int x = 0; x < 4; x++) {
                            bytes[x] = CommonLib.string2BigInteger(b[x + z * 4].substring(2).trim()).intValue();
                        }
                        long value = CommonLib.getInt(bytes, 0);
                        // "No.", "PT base", "AVL", "G",
                        // "D", "A", "PCD", "PWT",
                        // "U/S", "W/R", "P"

                        long baseL = value & 0xfffff000;
                        // if (baseL != 0) {
                        String base = "0x" + Long.toHexString(baseL);
                        String avl = String.valueOf((value >> 9) & 3);
                        String g = String.valueOf((value >> 8) & 1);
                        String d = String.valueOf((value >> 6) & 1);
                        String a = String.valueOf((value >> 5) & 1);
                        String pcd = String.valueOf((value >> 4) & 1);
                        String pwt = String.valueOf((value >> 3) & 1);
                        String us = String.valueOf((value >> 2) & 1);
                        String wr = String.valueOf((value >> 1) & 1);
                        String p = String.valueOf((value >> 0) & 1);

                        ia32_pageDirectories
                                .add(new IA32PageDirectory(base, avl, g, d, a, pcd, pwt, us, wr, p));

                        model.addRow(new String[] { String.valueOf(y * 2 + z), base, avl, g, d, a, pcd, pwt, us,
                                wr, p });
                        // }
                    } catch (Exception ex) {
                    }
                }
                jStatusLabel.setText("Updating page table " + (y + 1) + "/" + lines.length);
            }
            jPageDirectoryTable.setModel(model);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    /*
     * if (false && Global.debug &&
     * jAutoRefreshPageTableGraphCheckBox.isSelected()) {
     * System.out.println("aa"); GraphModel model = new DefaultGraphModel();
     * GraphLayoutCache view = new GraphLayoutCache(model, new
     * DefaultCellViewFactory() { public CellView createView(GraphModel
     * model, Object cell) { CellView view = null; if (model.isPort(cell)) {
     * view = new PortView(cell); } else if (model.isEdge(cell)) { view =
     * new EdgeView(cell); } else { if (cell instanceof IA32PageDirectory) {
     * view = new PageDirectoryView(cell); } else if (cell instanceof
     * IA32PageTable) { view = new JButtonView(cell, 1); } else { view = new
     * VertexView(cell); } } return view; } }); JGraph graph = new
     * JGraph(model, view);
     * 
     * // add cells
     * 
     * // DefaultGraphCell[] cells = new //
     * DefaultGraphCell[ia32_pageDirectories.size() + 1];
     * Vector<DefaultGraphCell> cells = new Vector<DefaultGraphCell>();
     * DefaultGraphCell root = new DefaultGraphCell("cr3 " +
     * jRegisterPanel1.jCR3TextField.getText());
     * GraphConstants.setGradientColor(root.getAttributes(), Color.red);
     * GraphConstants.setOpaque(root.getAttributes(), true);
     * GraphConstants.setBounds(root.getAttributes(), new
     * Rectangle2D.Double(0, 0, 140, 20)); root.add(new DefaultPort());
     * cells.add(root);
     * 
     * Vector<IA32PageDirectory> pageDirectoryCells = new
     * Vector<IA32PageDirectory>(); for (int x = 0; x <
     * ia32_pageDirectories.size(); x++) { IA32PageDirectory cell =
     * ia32_pageDirectories.get(x);
     * GraphConstants.setGradientColor(cell.getAttributes(), Color.orange);
     * GraphConstants.setOpaque(cell.getAttributes(), true);
     * GraphConstants.setBounds(cell.getAttributes(), new
     * Rectangle2D.Double(0, x * 20, 140, 20)); cell.add(new DefaultPort());
     * pageDirectoryCells.add(cell);
     * 
     * // page table String pageTableAddress =
     * ia32_pageDirectories.get(x).base; sendCommand("xp /4096bx " +
     * pageTableAddress);
     * 
     * float totalByte2 = 4096 - 1; totalByte2 = totalByte2 / 8; int
     * totalByte3 = (int) Math.floor(totalByte2); String realEndAddressStr;
     * String realStartAddressStr; String baseAddress = pageTableAddress;
     * long realStartAddress = CommonLib.string2BigInteger(baseAddress);
     * 
     * realStartAddressStr = String.format("%08x", realStartAddress); long
     * realEndAddress = realStartAddress + totalByte3 * 8; realEndAddressStr
     * = String.format("%08x", realEndAddress);
     * 
     * String result = commandReceiver.getCommandResult(realStartAddressStr,
     * realEndAddressStr); String[] lines = result.split("\n");
     * 
     * Vector<DefaultGraphCell> pageTables = new Vector<DefaultGraphCell>();
     * for (int y = 1; y < 4; y++) { String[] b =
     * lines[y].replaceFirst("         cell.add(new DefaultPort());^.*:",
     * "").trim().split("\t");
     * 
     * for (int z = 0; z < 2; z++) { try { int bytes[] = new int[4]; for
     * (int x2 = 0; x2 < 4; x2++) { bytes[x2] =
     * CommonLib.string2BigInteger(b[x2 + z *
     * 4].substring(2).trim()).intValue(); } long value =
     * CommonLib.getInt(bytes, 0);
     * 
     * String base = Long.toHexString(value & 0xfffff000); String avl =
     * String.valueOf((value >> 9) & 3); String g = String.valueOf((value >>
     * 8) & 1); String d = String.valueOf((value >> 6) & 1); String a =
     * String.valueOf((value >> 5) & 1); String pcd = String.valueOf((value
     * >> 4) & 1); String pwt = String.valueOf((value >> 3) & 1); String us
     * = String.valueOf((value >> 2) & 1); String wr = String.valueOf((value
     * >> 1) & 1); String p = String.valueOf((value >> 0) & 1);
     * IA32PageTable pageTableCell = new IA32PageTable(base, avl, g, d, a,
     * pcd, pwt, us, wr, p);
     * GraphConstants.setGradientColor(pageTableCell.getAttributes(),
     * Color.orange);
     * GraphConstants.setOpaque(pageTableCell.getAttributes(), true);
     * GraphConstants.setBounds(pageTableCell.getAttributes(), new
     * Rectangle2D.Double(0, (z + y) * 20, 140, 20)); pageTableCell.add(new
     * DefaultPort()); pageTables.add(pageTableCell); } catch (Exception ex)
     * { } } }
     * 
     * // group it and link it DefaultGraphCell pt[] =
     * pageTables.toArray(new DefaultGraphCell[] {}); DefaultGraphCell
     * vertex1 = new DefaultGraphCell(new String("page table" + x), null,
     * pt); vertex1.add(new DefaultPort()); cells.add(vertex1);
     * 
     * DefaultEdge edge = new DefaultEdge();
     * edge.setSource(cell.getChildAt(0));
     * edge.setTarget(vertex1.getLastChild());
     * 
     * GraphConstants.setLineStyle(edge.getAttributes(),
     * GraphConstants.STYLE_ORTHOGONAL);
     * GraphConstants.setRouting(edge.getAttributes(),
     * GraphConstants.ROUTING_DEFAULT); int arrow =
     * GraphConstants.ARROW_CLASSIC;
     * GraphConstants.setLineEnd(edge.getAttributes(), arrow);
     * GraphConstants.setEndFill(edge.getAttributes(), true);
     * 
     * cells.add(edge); }
     * 
     * if (pageDirectoryCells.toArray().length > 0) { IA32PageDirectory pt[]
     * = pageDirectoryCells.toArray(new IA32PageDirectory[] {});
     * DefaultGraphCell vertex1 = new DefaultGraphCell(new
     * String("Vertex1"), null, pt); vertex1.add(new DefaultPort());
     * cells.add(vertex1);
     * 
     * DefaultEdge edge = new DefaultEdge();
     * edge.setSource(root.getChildAt(0));
     * edge.setTarget(vertex1.getLastChild()); int arrow =
     * GraphConstants.ARROW_CLASSIC;
     * GraphConstants.setLineEnd(edge.getAttributes(), arrow);
     * GraphConstants.setEndFill(edge.getAttributes(), true);
     * 
     * // lastObj = cells[index]; cells.add(edge); }
     * 
     * graph.getGraphLayoutCache().insert(cells.toArray());
     * graph.setDisconnectable(false);
     * 
     * JGraphFacade facade = new JGraphFacade(graph); JGraphLayout layout =
     * new JGraphTreeLayout(); ((JGraphTreeLayout)
     * layout).setOrientation(SwingConstants.WEST); //
     * ((JGraphHierarchicalLayout) layout).setNodeDistance(100);
     * layout.run(facade); Map nested = facade.createNestedMap(true, true);
     * graph.getGraphLayoutCache().edit(nested);
     * 
     * // JGraphFacade facade = new JGraphFacade(graph); // JGraphLayout
     * layout = new JGraphFastOrganicLayout(); // layout.run(facade); // Map
     * nested = facade.createNestedMap(true, true); //
     * graph.getGraphLayoutCache().edit(nested);
     * 
     * jPageTableGraphPanel.removeAll(); jPageTableGraphPanel.add(new
     * JScrollPane(graph), BorderLayout.CENTER); }
     */

}