private JComponent createContents() {
		JPanel result = new JPanel(new BorderLayout());
		DefaultTableModel dm = new DefaultTableModel();
		dm.setDataVector(new Object[][] {
				{"11","12","13","14"},
				{"21","22","23","24"}
	  	}, new Object[] {
				"�,"�,"�,"�
		});
		JTable table = new JTable( dm ) {
			protected JTableHeader createDefaultTableHeader() {
				return new GroupableTableHeader(columnModel);
			}
		};
		TableColumnModel cm = table.getColumnModel();
		ColumnGroup g1 = new ColumnGroup("Group1");
		g1.add(cm.getColumn(0));
		ColumnGroup g2 = new ColumnGroup("Group2");
		g2.add(cm.getColumn(3));
		ColumnGroup g3 = new ColumnGroup("Group3");
		g3.add(cm.getColumn(1));
		g3.add(cm.getColumn(2));
		g2.add(g3);
		GroupableTableHeader header = (GroupableTableHeader)table.getTableHeader();
		header.addColumnGroup(g1);
		header.addColumnGroup(g2);
		header.addColumnGroup(g3);
		JScrollPane scroll = new JScrollPane(table);		
	    result.add(scroll,BorderLayout.CENTER);
		return result;
	}
 /**
  * Funcion que carga los datos del arrayList pasado por parametro en la tabla. En este caso son o
  * fincasCatastro o Bienes inmuebles. Se hace un instanceof para saberlo.
  *
  * @param dirRefCatas La lista de referencias del expediente
  */
 public void cargaDatosTabla(ArrayList dirRefCatas) {
   AppContext app = (AppContext) AppContext.getApplicationContext();
   Estructuras.cargarEstructura("Tipos de via normalizados de Catastro");
   String[][] datos = new String[dirRefCatas.size()][6];
   for (int i = 0; i < dirRefCatas.size(); i++) {
     DireccionLocalizacion auxDir = null;
     if (dirRefCatas.get(i) instanceof FincaCatastro) {
       FincaCatastro parcela = (FincaCatastro) dirRefCatas.get(i);
       auxDir = parcela.getDirParcela();
       datos[i][0] = parcela.getRefFinca().getRefCatastral();
     } else if (dirRefCatas.get(i) instanceof BienInmuebleCatastro) {
       BienInmuebleCatastro bien = (BienInmuebleCatastro) dirRefCatas.get(i);
       auxDir = bien.getDomicilioTributario();
       datos[i][0] = bien.getIdBienInmueble().getIdBienInmueble();
     }
     if (auxDir != null
         && Estructuras.getListaTipos().getDomainNode(auxDir.getTipoVia()) != null) {
       datos[i][1] =
           Estructuras.getListaTipos()
               .getDomainNode(auxDir.getTipoVia())
               .getTerm(app.getString(AppContext.GEOPISTA_LOCALE_KEY, "es_ES"));
     } else {
       datos[i][1] = "";
     }
     if (auxDir != null) {
       datos[i][2] = auxDir.getNombreVia();
       datos[i][3] = String.valueOf(auxDir.getPrimerNumero());
       datos[i][4] = auxDir.getCodPoligono();
       datos[i][5] = auxDir.getCodParcela();
     }
   }
   modelo.setDataVector(datos, identificadores);
   tablaRefCatasTabel.setModel(modelo);
 }
 public void actionPerformed(final ActionEvent e) {
   int i = Dao.DelSalesman(ISBN.getText().trim());
   if (i == 1) {
     JOptionPane.showMessageDialog(null, "删除成功");
     Object[][] results = getFileStates(Dao.selectSalesman());
     model.setDataVector(results, columnNames);
     table.setModel(model);
   }
 }
Example #4
0
  /**
   * This method initializes jTable
   *
   * @return javax.swing.JTable
   */
  JTable getJTable() {
    if (jTable == null) {
      Event event = new Event();
      AdministrateEventController controller = new AdministrateEventController();
      event = controller.processRetrieve();

      int colWidth = 100;
      Object[] colNames = {"Event ID", "Event Date", "Event Time", "Event Name", "Status"};
      Object[][] data = new Object[event.getEventID_list().size()][colSize];

      for (int i = 0; i < event.getEventID_list().size(); i++) {
        data[i][0] = event.getEventID_list().get(i);
        data[i][1] = controller.calendarToString(event.getEventDate_list().get(i));
        data[i][2] = event.getEventTime_list().get(i);
        data[i][3] = event.getEventName_list().get(i);
        data[i][4] = event.getEventStatus_list().get(i);
      }

      model.setDataVector(data, colNames);
      jTable = new JTable(model);

      if (viewModel != null) {
        jTable.setModel(viewModel);
        viewModel = null;
      }

      jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

      for (int i = 0; i < colSize; i++) {
        jTable.getColumnModel().getColumn(i).setCellRenderer(new Renderer());
        jTable.getColumnModel().getColumn(i).setPreferredWidth(colWidth);
      }

      jTable.getColumnModel().getColumn(3).setPreferredWidth(250);
      jTable.getColumnModel().getColumn(4).setPreferredWidth(172);

      jTable.setAutoCreateColumnsFromModel(false);
      sortAllRowsBy(model, 0, true);
      jTable.setEnabled(false);

      JTableHeader header = jTable.getTableHeader();
      header.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              JTableHeader h = (JTableHeader) e.getSource();
              int nColumn = h.columnAtPoint(e.getPoint());
              if (nColumn != -1) sortAllRowsBy(model, nColumn, true);
            }
          });

      etbml = new EventTableButtonMouseListener(jTable, source, crudFf);
      etbml.setSelection(selection);
      jTable.addMouseListener(etbml);
    }
    return jTable;
  }
 public TableModel tablaAulas(ArrayList<Aulas> aulas) {
   DefaultTableModel tablemodel = new DefaultTableModel();
   String[] columNames = {"Edificio", "Aula"};
   Object[][] data = new Object[aulas.size()][2];
   for (int i = 0; i < aulas.size(); i++) {
     data[i][0] = aulas.get(i).getId().getNombreEdificio();
     data[i][1] = aulas.get(i).getId().getNumAula();
   }
   tablemodel.setDataVector(data, columNames);
   return tablemodel;
 }
 /**
  * Erneuert das TextFeld <i>custNameTextF_ref</i> und das DefaultTableModel der Tabelle
  * <i>custTable_ref</i> mit Werten, entsprechend dem durch die JComboBox <i>cComBox_ref</i> vom
  * Benutzer ausgewaehlten Kommando.
  *
  * <p>Die Werte werden aus der durch das Haupt-GUI erhaltenen Matrix ausgelesen, welche ueber
  * dessen Methode <i>getSettings()</i> abgerufen werden kann.
  *
  * <p>Um die Werte fuer die Tabelle korrekt zu formatieren, wird die Methode
  * <i>getSelTabMatrix()</i> genutzt.
  *
  * @see #getSelTabMatrix()
  * @see TinyAdminGUI#getSettings()
  */
 private void fillSelectedItemBox() {
   int selectedIndex = cComBox_ref.getSelectedIndex();
   if (selectedIndex < 0) {
     cComBox_ref.setSelectedIndex(0);
     selectedIndex = 0;
   } // endif
   custNameTextF_ref.setText((setGui_ref.getGUI().getSettings())[1][selectedIndex][0]);
   custTableMod_ref.setDataVector(getSelTabMatrix(), new String[] {"OS", "Kommando"});
   custTable_ref.getColumnModel().getColumn(0).setPreferredWidth(60);
   custTable_ref.getColumnModel().getColumn(1).setPreferredWidth(540);
   custTableMod_ref.fireTableDataChanged();
 } // endmethod fillSelectedItemBox
 public void setTable() {
   DefaultTableModel tableModel = new DefaultTableModel();
   tableModel.setColumnIdentifiers(colHeader);
   tableModel.setRowCount(rowHeader.length);
   tableModel.setDataVector(dataTable, colHeader);
   table = new JTable(tableModel);
   table.setRowHeight(20);
   table.getColumnModel().getColumn(0).setCellRenderer(new TableCellListener(type));
   ExcelAdapter excelAdapter = new ExcelAdapter(table);
   Scroll = new JScrollPane(table);
   // scroll.setPreferredSize(new Dimension(400, 200));
 }
  private void initData() {
    dbInstance.Connect();
    QueryResults qr =
        dbInstance.QueryResults(
            "select document_title, document_uri, document_date from tabled_documents");
    dbInstance.EndConnect();

    if (qr != null) {
      if (qr.hasResults()) {
        Vector<Vector<String>> resultRows = new Vector<Vector<String>>();
        resultRows = qr.theResults();

        DefaultTableModel mdl = new DefaultTableModel();
        mdl.setDataVector(resultRows, qr.getColumnsAsVector());
        tbl_tabledDocs.setModel(mdl);
      }
    }
  }
  /**
   * Funcion que carga los datos del arrayList pasado por parametro en la tabla. Se cargan ciertos
   * datos de los expedientes pasados por parametro. Para ver las referencias se hace un instanceof
   *
   * @param expedientes Los expedientes a mostrar en la tabla
   * @param usuarios Los nombres de los usuarios de los expediente, ya que el expediente solo guarda
   *     el id usuario.
   */
  public void cargaDatosTabla(ArrayList expedientes, Hashtable usuarios) {
    editors.clear();
    String[][] datos = new String[expedientes.size()][10];
    for (int i = 0; i < expedientes.size(); i++) {
      Expediente expAux = (Expediente) expedientes.get(i);
      datos[i][0] = String.valueOf(expAux.getNumeroExpediente());
      datos[i][1] = expAux.getTipoExpediente().getCodigoTipoExpediente();
      if (expAux.isTipoTramitaExpSitFinales()) {
        // expediente de situaciones finales
        datos[i][2] =
            (I18N.get(
                "RegistroExpedientes",
                "Catastro.RegistroExpedientes.TablaBusqueda.tipoDeExpediente.situacionesFinales"));
      } else {
        // Expediente de variaciones
        datos[i][2] =
            (I18N.get(
                "RegistroExpedientes",
                "Catastro.RegistroExpedientes.TablaBusqueda.tipoDeExpediente.variaciones"));
      }
      datos[i][3] =
          Estructuras.getListaEstadosExpediente()
              .getDomainNode(String.valueOf(expAux.getIdEstado()))
              .getTerm(ConstantesCatastro.Locale);
      datos[i][4] = (String) usuarios.get(String.valueOf(expAux.getIdTecnicoCatastro()));
      datos[i][5] = String.valueOf(expAux.getFechaRegistro());
      datos[i][6] = String.valueOf(expAux.getAnnoExpedienteAdminOrigenAlteracion());
      datos[i][7] = String.valueOf(expAux.getEntidadGeneradora().getCodigo());
      ArrayList refCatas = expAux.getListaReferencias();
      if (refCatas != null && refCatas.size() > 0) {
        if (refCatas.get(0) instanceof FincaCatastro) {
          datos[i][8] = (((FincaCatastro) refCatas.get(0)).getRefFinca().getRefCatastral());
        } else if (refCatas.get(0) instanceof BienInmuebleCatastro) {
          datos[i][8] =
              (((BienInmuebleCatastro) refCatas.get(0)).getIdBienInmueble().getIdBienInmueble());
        }
      }
      rellenaRefCatas(expAux);
      datos[i][9] = expAux.getNifPresentador();
    }

    modelo.setDataVector(datos, identificadores);
    expedientesTable.setModel(modelo);
  }
  private void refreshTable() {

    try {
      if (scrollPane.isAncestorOf(table)) {
        frame.remove(scrollPane);
        scrollPane.remove(table);
        frame.validate();
        frame.repaint();
      }
    } catch (NullPointerException e) {

    }

    DefaultTableModel dm = new DefaultTableModel();
    dm.setDataVector(getValuesArray(), new Object[] {"Name", ""});

    table = new JTable(dm);
    table.getColumn("").setMaxWidth(120);
    table.getColumn("").setCellRenderer(new ButtonRenderer());
    table.getColumn("").setCellEditor(new ButtonEditor(new JCheckBox()));

    table
        .getModel()
        .addTableModelListener(
            new TableModelListener() {

              @Override
              public void tableChanged(TableModelEvent e) {

                int row = e.getFirstRow();
                int column = e.getColumn();
                TableModel model = (TableModel) e.getSource();
                String columnName = model.getColumnName(column);
                String newValue = model.getValueAt(row, column).toString();

                eaArrayList_RenamededFolders.add(
                    new EA_Rename(EA_Utils.getColumnsArrayList().get(row), newValue, row));
              }
            });

    scrollPane = new JScrollPane(table);
    scrollPane.setBounds(10, 11, 371, 206);
    frame.getContentPane().add(scrollPane);
  }
  /** we've received some new data, update the GUI */
  public void updateForm() {
    // step through the detections, collating them into the vector expected by the table
    Vector<Vector<String>> theData = new Vector<Vector<String>>(1, 1);
    Iterator<Object> it = _sensorEvents.iterator();
    while (it.hasNext()) {
      LookupSensor.LookupSensorComponentsEvent sc =
          (LookupSensor.LookupSensorComponentsEvent) it.next();
      Vector<String> thisV = new Vector<String>(1, 1);
      thisV.add(sc.getTgtName());
      thisV.add(sc.getStateString());
      thisV.add("" + (int) sc.getRP().getValueIn(WorldDistance.METRES));
      thisV.add("" + (int) sc.getRI().getValueIn(WorldDistance.METRES));
      thisV.add("" + (int) sc.getActual().getValueIn(WorldDistance.METRES));
      theData.add(thisV);
    }

    // and update the model
    _myTableModel.setDataVector(theData, _cols);
  }
Example #12
0
 public void populateTable(String[] columns, Vector<Object[]> data) throws SQLException {
   // la tabella deve essere inizializzata ogni volta che viene popolata altrimenti aggiunge righe
   // cliccando sui giorni
   // anzichè presentare solo le righe relative al giorno scelto
   initialize_table();
   SimpleDateFormat formatter = new SimpleDateFormat();
   formatter.applyPattern("HH:mm");
   DefaultTableModel aModel = (DefaultTableModel) table.getModel();
   if (data.size() > 0) {
     aModel.setColumnIdentifiers(columns);
     for (Object[] object : data) {
       object[0] = formatter.format(object[0]);
       aModel.addRow(object);
     }
     table.setModel(aModel);
   } else {
     Vector<String> noColumns = new Vector<String>();
     noColumns.add("Nessuna prenotazione per questa data");
     aModel.setDataVector(data, noColumns);
   }
   scrollPane.setViewportView(table);
 }
Example #13
0
  /** the class is for test radio cell table. */
  public TestRadioCell() {
    super("JRadioCellTable");
    setSize(400, 300);
    DefaultTableModel dm = new DefaultTableModel();
    dm.setDataVector(
        new Object[][] {
          {"1", new Integer(-1)},
          {"2", new Integer(-1)},
          {"3", new Integer(0)},
          {"4", new Integer(1)},
          {"5", new Integer(2)}
        },
        new Object[] {"Question", "Answer"});

    JTable table = new JTable(dm);
    String[] answer = {"A", "B", "C"};

    table.getColumn("Answer").setCellRenderer(new MyRadioCellRenderer(answer));
    table.getColumn("Answer").setCellEditor(new MyRadioCellEditor(new MyRadioCellRenderer(answer)));
    JScrollPane scroll = new JScrollPane(table);
    getContentPane().add(scroll);
  }
Example #14
0
  GroupableHeaderExample() {
    super("Groupable Header Example");

    DefaultTableModel dm = new DefaultTableModel();
    dm.setDataVector(
        new Object[][] {
          {"119", "foo", "bar", "ja", "ko", "zh"},
          {"911", "bar", "foo", "en", "fr", "pt"}
        },
        new Object[] {"SNo.", "1", "2", "Native", "2", "3"});

    JTable table =
        new JTable(dm) {
          protected JTableHeader createDefaultTableHeader() {
            return new GroupableTableHeader(columnModel);
          }
        };

    TableColumnModel cm = table.getColumnModel();
    ColumnGroup g_name = new ColumnGroup("Name");
    g_name.add(cm.getColumn(1));
    g_name.add(cm.getColumn(2));
    ColumnGroup g_lang = new ColumnGroup("Language");
    g_lang.add(cm.getColumn(3));
    ColumnGroup g_other = new ColumnGroup("Others");
    g_other.add(cm.getColumn(4));
    g_other.add(cm.getColumn(5));
    g_lang.add(g_other);

    GroupableTableHeader header = (GroupableTableHeader) table.getTableHeader();
    header.addColumnGroup(g_name);
    header.addColumnGroup(g_lang);
    JScrollPane scroll = new JScrollPane(table);
    getContentPane().add(scroll);
    setSize(400, 120);
  }
Example #15
0
  /**
   * Обновление данных в таблице цен + последнее обновление<br>
   * - id<br>
   * - Дата<br>
   * - АИ - 80<br>
   * - АИ - 92<br>
   * - АИ - 95<br>
   * - Дизель<br>
   *
   * @throws SQLException
   */
  private void refreshCostOil() throws SQLException {
    isChangeTable = false;
    Vector<String> header = new Vector<String>();
    {
      header.add("id");
      header.add("Дата");
      header.add("80");
      header.add("92");
      header.add("95");
      header.add("dis");
    }

    Vector<Vector<String>> values = new Vector<Vector<String>>();
    {
      // поиск последнего изменения
      ResultSet time =
          DriverManager.getConnection("jdbc:sqlite:" + Oil.PATH)
              .createStatement()
              .executeQuery(
                  "SELECT changedate,b80,b92,b95,bdis,id FROM change WHERE station_id LIKE '"
                      + station_id
                      + "';");

      while (time.next()) {
        Vector<String> item = new Vector<String>();

        item.add(time.getString(6));

        Long temp = Long.parseLong(time.getString(1));
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
        Date date = new Date(temp);

        item.add(dateFormat.format(date).toString());
        item.add(time.getString(2));
        item.add(time.getString(3));
        item.add(time.getString(4));
        item.add(time.getString(5));

        values.add(0, item);
      }
      time.close();
    }

    DefaultTableModel dtm = (DefaultTableModel) jDataTable.getModel();
    // Сначала данные, потом шапка
    dtm.setDataVector(values, header);
    // задаем ширину каждого столбца, кроме наименования
    // id
    jDataTable.getColumnModel().getColumn(0).setMinWidth(40);
    // дата
    jDataTable.getColumnModel().getColumn(1).setMinWidth(100);
    // топливо
    jDataTable.getColumnModel().getColumn(2).setMinWidth(40);
    jDataTable.getColumnModel().getColumn(3).setMinWidth(40);
    jDataTable.getColumnModel().getColumn(4).setMinWidth(40);
    jDataTable.getColumnModel().getColumn(5).setMinWidth(40);

    jDataTable.getModel().addTableModelListener(new JTableChanged());
    isChangeTable = true;

    /*
     * **********************************
     * Последнее обновление
     * **********************************
     */

    ResultSet getOil =
        DriverManager.getConnection("jdbc:sqlite:" + Oil.PATH)
            .createStatement()
            .executeQuery(
                "SELECT changedate,b80,b92,b95,bdis FROM change WHERE station_id LIKE '"
                    + station_id
                    + "';");

    Long max_time = (long) 0;
    String b80 = "";
    String b92 = "";
    String b95 = "";
    String bdis = "";

    while (getOil.next()) {
      Long temp = Long.parseLong(getOil.getString(1));

      if (temp > max_time) {
        max_time = temp;
        b80 = getOil.getString(2);
        b92 = getOil.getString(3);
        b95 = getOil.getString(4);
        bdis = getOil.getString(5);
      }
    }
    getOil.close();

    DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
    Date date = new Date(max_time);

    text_data.setText(dateFormat.format(date).toString());
    text_data.setEditable(false);

    text_bdis.setText(bdis);
    text_b95.setText(b95);
    text_b92.setText(b92);
    text_b80.setText(b80);

    jDataTable.setAutoCreateRowSorter(true);

    this.validate();
    this.repaint();
  }
Example #16
0
  public static void main(String[] args) throws IOException {

    Sql reader = new Sql();
    final String emisora = "BIMBO";
    final String serie = "";
    final Calendar day = new GregorianCalendar(2010, 10, 17);
    ArrayList<Orden> ordenes = reader.readIniciales(emisora, serie, day);
    reader.read(ordenes, emisora, serie, day);

    String datetext =
        day.get(Calendar.YEAR) + "" + (day.get(Calendar.MONTH) + 1) + "" + day.get(Calendar.DATE);

    FileWriter fw = new FileWriter("ordenes" + emisora + datetext + ".txt");
    final BufferedWriter bw = new BufferedWriter(fw);

    FileWriter fw2 = new FileWriter("ordenes2" + emisora + datetext + ".txt");
    final BufferedWriter bw2 = new BufferedWriter(fw2);

    FileWriter fwc = new FileWriter("compra" + emisora + datetext + ".txt");
    final BufferedWriter bwc = new BufferedWriter(fwc);

    FileWriter fwv = new FileWriter("venta" + emisora + datetext + ".txt");
    final BufferedWriter bwv = new BufferedWriter(fwv);

    FileWriter fwd = new FileWriter("distancia" + emisora + datetext + ".txt");
    final BufferedWriter bwd = new BufferedWriter(fwd);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final DefaultTableModel modelVenta =
        new DefaultTableModel() {
          @Override
          public Class getColumnClass(int column) {
            if (column == 1) {
              return BigDecimal.class;
            }
            return Object.class;
          }
        };
    final DefaultTableModel modelCompra =
        new DefaultTableModel() {
          @Override
          public Class getColumnClass(int column) {
            if (column == 1) {
              return BigDecimal.class;
            }
            return Object.class;
          }
        };
    final DefaultTableModel modelExec = new DefaultTableModel();
    final DefaultTableModel modelExec2 = new DefaultTableModel();
    final DefaultTableModel modelOrdenes = new DefaultTableModel();

    final JTable tableVenta = new JTable(modelVenta);
    tableVenta.setAutoCreateRowSorter(true);
    final JTable tableCompra = new JTable(modelCompra);
    tableCompra.setAutoCreateRowSorter(true);
    final JTable tableExec = new JTable(modelExec);
    final JTable tableExec2 = new JTable(modelExec2);
    final JTable tableOrdenes = new JTable(modelOrdenes);

    JScrollPane scrollPaneVenta = new JScrollPane(tableVenta);
    JScrollPane scrollPaneCompra = new JScrollPane(tableCompra);
    JScrollPane scrollPaneExec = new JScrollPane(tableExec);
    JScrollPane scrollPaneExec2 = new JScrollPane(tableExec2);
    JScrollPane scrollPaneOrdenes = new JScrollPane(tableOrdenes);
    scrollPaneVenta.setBounds(0, 0, 400, 250);
    scrollPaneCompra.setBounds(0, 250, 400, 250);
    scrollPaneExec.setBounds(400, 0, 400, 250);
    scrollPaneExec2.setBounds(400, 250, 400, 250);
    scrollPaneOrdenes.setBounds(0, 500, 800, 200);
    frame.setLayout(null);
    frame.add(scrollPaneVenta);
    frame.add(scrollPaneCompra);
    frame.add(scrollPaneExec);
    frame.add(scrollPaneExec2);
    frame.add(scrollPaneOrdenes);
    frame.setSize(806, 792);
    frame.setVisible(true);
    frame.setResizable(false);
    ArrayList<SortKey> sortKeysv = new ArrayList<RowSorter.SortKey>();
    sortKeysv.add(new RowSorter.SortKey(1, SortOrder.DESCENDING));
    sortKeysv.add(new RowSorter.SortKey(3, SortOrder.DESCENDING));
    modelVenta.addColumn("");
    modelVenta.addColumn("Precio");
    modelVenta.addColumn("Volumen");
    modelVenta.addColumn("Folio");
    tableVenta.getRowSorter().setSortKeys(sortKeysv);
    ArrayList<SortKey> sortKeysc = new ArrayList<RowSorter.SortKey>();
    sortKeysc.add(new RowSorter.SortKey(1, SortOrder.DESCENDING));
    sortKeysc.add(new RowSorter.SortKey(3, SortOrder.ASCENDING));
    modelCompra.addColumn("");
    modelCompra.addColumn("Precio");
    modelCompra.addColumn("Volumen");
    modelCompra.addColumn("Folio");
    tableCompra.getRowSorter().setSortKeys(sortKeysc);
    modelExec.addColumn("Hora");
    modelExec.addColumn("Precio");
    modelExec.addColumn("Volumen");
    modelExec2.addColumn("Hora");
    modelExec2.addColumn("Precio");
    modelExec2.addColumn("Volumen");
    modelOrdenes.addColumn("Tipo");
    modelOrdenes.addColumn("Precio");
    modelOrdenes.addColumn("Volumen");
    modelOrdenes.addColumn("Hora");
    modelOrdenes.addColumn("Folio");
    modelOrdenes.addColumn("Folio Ant.");
    modelOrdenes.addColumn("Casa de Bolsa");
    Object[] columns = {
      "Tipo", "Precio", "Volumen", "Hora", "Folio", "Folio Ant.", "Casa de Bolsa", "Orden"
    };
    Vector<Object> columnNames = convertToVector(columns);
    Vector<Object> data = new Vector<Object>(6000);
    for (int i = 0; i < ordenes.size(); i++) {
      Vector<Object> row = convertToVector(ordenes.get(i).toRow());
      data.add(row);
    }
    modelOrdenes.setDataVector(data, columnNames);
    DateRenderer2 render = new DateRenderer2();
    tableOrdenes.getColumnModel().getColumn(3).setCellRenderer(render);
    tableExec.getColumnModel().getColumn(0).setCellRenderer(render);
    tableExec2.getColumnModel().getColumn(0).setCellRenderer(render);
    JButton buttonNext = new JButton("Siguiente");
    buttonNext.setBounds(30, 716, 100, 30);
    frame.add(buttonNext);
    buttonNext.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Execute when button is pressed
            if (modelOrdenes.getRowCount() > 0)
              action(
                  day,
                  modelCompra,
                  modelVenta,
                  modelOrdenes,
                  modelExec,
                  modelExec2,
                  tableCompra,
                  tableVenta,
                  tableExec,
                  tableExec2,
                  bw,
                  bw2,
                  bwc,
                  bwv,
                  bwd);
          }
        });

    JButton buttonDeleteCompra = new JButton("Cancelar Compra");
    buttonDeleteCompra.setBounds(150, 716, 200, 30);
    frame.add(buttonDeleteCompra);
    buttonDeleteCompra.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Execute when button is pressed
            int d = tableCompra.getSelectedRow();
            try {
              modelCompra.removeRow(tableCompra.convertRowIndexToModel(d));
            } catch (Exception ex) {
              System.out.println("Cannot delete row: " + ex);
            }
          }
        });

    JButton buttonDeleteVenta = new JButton("Cancelar Venta");
    buttonDeleteVenta.setBounds(370, 716, 200, 30);
    frame.add(buttonDeleteVenta);
    buttonDeleteVenta.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Execute when button is pressed
            int d = tableVenta.getSelectedRow();
            try {
              modelVenta.removeRow(tableVenta.convertRowIndexToModel(d));
            } catch (Exception ex) {
              System.out.println("Cannot delete row: " + ex);
            }
          }
        });
    JButton buttonPlay = new JButton("Play");
    buttonPlay.setBounds(600, 716, 100, 30);
    frame.add(buttonPlay);
    buttonPlay.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Execute when button is pressed
            int i = 0;
            // while(tableOrdenes.getRowCount() > 0 && i < 100) {
            while (tableOrdenes.getRowCount() > 0) {
              Date cal = (Date) modelOrdenes.getValueAt(0, 3);
              action(
                  day,
                  modelCompra,
                  modelVenta,
                  modelOrdenes,
                  modelExec,
                  modelExec2,
                  tableCompra,
                  tableVenta,
                  tableExec,
                  tableExec2,
                  bw,
                  bw2,
                  bwc,
                  bwv,
                  bwd);
              // modelCompra.getValueAt(0, 1)

              i++;
            }
            if (tableOrdenes.getRowCount() <= 0)
              try {
                bw.close();
                bw2.close();
                bwc.close();
                bwv.close();
                bwd.close();
              } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
          }
        });
  }
  /**
   * createContestantsTable Method - Method for creating & updating the Contestants JTable.
   *
   * @param createFromFile
   */
  public void createContestantsTable(String createFromFile) {

    contestantHeader =
        new Object[] {"Unique ID", "First Name", "Last Name", "Team", "Elimination Week"};

    if (createFromFile.equalsIgnoreCase("y")) {
      /*Create Contestants Object*/
      contestants = new Contestants();

      /*Restore Contestants Data from Text File*/
      contestants.resetFromFile(gameSettings.filename_contestants);
    } else {
      contestants.resetFromFile(gameSettings.filename_contestants);
    }

    contestantData = contestants.prepforTable();

    /*Code for Swapping Picture and RoundEliminated*/
    if (contestants.getNumContestants() != 0) {
      Object[][] tmpData = contestantData;
      for (int i = 0; i < contestants.getNumContestants(); i++) {
        tmpData[i][4] = contestantData[i][5];
        tmpData[i][5] = contestantData[i][4];
      }
      contestantData = tmpData;
    }

    /*Code which updates the JTable with the new/added/removed data*/
    if (createFromFile.equalsIgnoreCase("y")) {
      contestantDM =
          new DefaultTableModel() {
            @Override
            public boolean isCellEditable(int row, int column) {
              // all cells false
              return false;
            }
          };
      contestantDM.setDataVector(contestantData, contestantHeader);

      listContestantsTable =
          new JTable(contestantDM) {
            public void tableChanged(TableModelEvent e) {
              super.tableChanged(e);
              repaint();
            }
          };

      /*Adds Table to Scroll Pane and set up the Layout*/
      listContestantsscrollPane = new JScrollPane(listContestantsTable);
      listContestantsTable.setFillsViewportHeight(true);
      listContestantsPanel.add(listContestantsscrollPane);
      listContestantsscrollPane.setBounds(10, 10, 600, 210);

      /*Enables Sorting of Rows of the Table*/
      listContestantsTable.setAutoCreateRowSorter(true);
      listContestantsTable.getTableHeader().setReorderingAllowed(false);
    } else {
      contestantDM.setDataVector(contestantData, contestantHeader);
      listContestantsTable = new JTable(contestantDM);
    }
  }
Example #18
0
  @Override
  public void International(int languageFlag) {
    InternationalUtils.languageFlag = languageFlag;
    this.setTitleAt(0, InternationalUtils.getValue("instruction"));
    this.setTitleAt(1, InternationalUtils.getValue("execute"));
    this.setTitleAt(2, InternationalUtils.getValue("code"));

    inputPanel.setBorder(BorderFactory.createTitledBorder((InternationalUtils.getValue("input"))));
    outputPanel.setBorder(
        BorderFactory.createTitledBorder((InternationalUtils.getValue("output"))));
    tableJscroll.setBorder(
        BorderFactory.createTitledBorder(InternationalUtils.getValue("siteList")));

    inputLabel1.setText(InternationalUtils.getValue("confName") + ":");
    inputLabel2.setText(InternationalUtils.getValue("confBeginTime") + ":");
    inputLabel3.setText(InternationalUtils.getValue("confDuration") + ":");
    inputLabel4.setText(InternationalUtils.getValue("confAccessCode") + ":");
    inputLabel9.setText(InternationalUtils.getValue("confPassword") + ":");
    inputLabel11.setText(InternationalUtils.getValue("confChairManPassword") + ":");

    inputLabel12.setText(InternationalUtils.getValue("mediaEncryptType") + ":");

    inputLabel5.setText(InternationalUtils.getValue("auxVideoFormat") + ":");
    inputLabel6.setText(InternationalUtils.getValue("auxVideoProtocol") + ":");

    inputLabel7.setText(InternationalUtils.getValue("cpResouce") + ":");
    inputLabel8.setText(InternationalUtils.getValue("rate") + ":");
    inputLabel10.setText(InternationalUtils.getValue("isRecording") + ":");
    inputLabel13.setText(InternationalUtils.getValue("isLiveBroadcast") + ":");

    inputLabel14.setText(InternationalUtils.getValue("presentation") + ":");

    inputLabel15.setText(InternationalUtils.getValue("billCode") + ":");
    inputLabel16.setText(InternationalUtils.getValue("mainSiteUri") + ":");
    inputLabel17.setText(InternationalUtils.getValue("email") + ":");
    inputLabel18.setText(InternationalUtils.getValue("content") + ":");

    // 国际化成员列表的标题栏
    Vector<String> titles = new Vector<String>();
    titles.add(InternationalUtils.getValue("confSite.uri"));
    titles.add(InternationalUtils.getValue("confSite.name"));
    titles.add(InternationalUtils.getValue("confSite.type"));
    titles.add(InternationalUtils.getValue("confSite.from"));
    titles.add(InternationalUtils.getValue("confSite.dialingMode"));
    titles.add(InternationalUtils.getValue("confSite.rate"));
    titles.add(InternationalUtils.getValue("confSite.videoFormat"));
    titles.add(InternationalUtils.getValue("confSite.videoProtocol"));
    titles.add(InternationalUtils.getValue("confSite.isLockVideoSource"));
    titles.add(InternationalUtils.getValue("confSite.participantType"));
    Vector<Vector<String>> rows = new Vector<Vector<String>>();
    tableMode1.setDataVector(rows, titles);
    addUser.setText(InternationalUtils.getValue("addSite"));
    deleteUser.setText(InternationalUtils.getValue("deleteSite"));

    actionBtn.setText(InternationalUtils.getValue("createConf"));

    outputLabel1.setText(InternationalUtils.getValue("resultCode") + ":");
    outputLabel2.setText(InternationalUtils.getValue("resultData") + ":");

    showOperationStatus(isSuccess);

    if (0 == languageFlag) {
      String htmlDesc = PropertiesUtils.getHtmlFromTxt("scheduleConf_zh.txt");
      descEditPane.setText(htmlDesc);
      String codeDesc = PropertiesUtils.getHtmlFromTxt("scheduleConf_code_zh.txt");
      codeEditPane.setText(codeDesc);
    } else if (1 == languageFlag) {
      String htmlDesc = PropertiesUtils.getHtmlFromTxt("scheduleConf_en.txt");
      descEditPane.setText(htmlDesc);
      String codeDesc = PropertiesUtils.getHtmlFromTxt("scheduleConf_code_en.txt");
      codeEditPane.setText(codeDesc);
    }
  }
 @Override
 public void setDataVector(Object[][] tableData, Object[] colNames) {
   super.setDataVector(tableData, colNames);
 }
    public void actionPerformed(final ActionEvent e) {
      if (readername.getText().length() == 0) {
        JOptionPane.showMessageDialog(null, "销售人员姓名文本框不可为空");
        return;
      }
      if (age.getText().length() == 0) {
        JOptionPane.showMessageDialog(null, "销售人员年龄文本框不可为空");
        return;
      }

      if (zjnumber.getText().length() == 0) {
        JOptionPane.showMessageDialog(null, "证件号码文本框不可为空");
        return;
      }
      if (keepmoney.getText().length() == 0) {
        JOptionPane.showMessageDialog(null, "工资文本框不可为空");
        return;
      }
      if (zy.getText().length() == 0) {
        JOptionPane.showMessageDialog(null, "毕业文本框不可为空");
        return;
      }
      if (ISBN.getText().length() == 0) {
        JOptionPane.showMessageDialog(null, "销售人员条形码文本框不可为空");
        return;
      }
      if (ISBN.getText().length() != 13) {
        JOptionPane.showMessageDialog(null, "销售人员条形码文本框为13位");
        return;
      }
      if (bztime.getText().length() == 0) {
        JOptionPane.showMessageDialog(null, "办证时间文本框不可为空");
        return;
      }
      if (tel.getText().length() == 0) {
        JOptionPane.showMessageDialog(null, "电话号码文本框不可为空");
        return;
      }
      if (tel.getText().length() > 11 || tel.getText().length() < 0) {
        JOptionPane.showMessageDialog(null, "电话号码位数小于11位");
        return;
      }
      if (maxnumber.getText().length() == 0) {
        JOptionPane.showMessageDialog(null, "最大调货量文本框不可为空");
        return;
      }
      if (maxnumber.getText().length() > 2 || tel.getText().length() < 0) {
        JOptionPane.showMessageDialog(null, "最大调货量为两位数字");
        return;
      }
      String sex = "1";
      if (!JRadioButton1.isSelected()) {
        sex = "2";
      }
      String zj = String.valueOf(comboBox.getSelectedIndex());
      System.out.println(comboBox.getSelectedIndex());

      int i =
          Dao.UpdateSalesman(
              id,
              readername.getText().trim(),
              sex,
              age.getText().trim(),
              zjnumber.getText().trim(),
              Date.valueOf(date.getText().trim()),
              maxnumber.getText().trim(),
              tel.getText().trim(),
              Double.valueOf(keepmoney.getText().trim()),
              zj,
              zy.getText().trim(),
              Date.valueOf(bztime.getText().trim()),
              ISBN.getText().trim());
      System.out.println(i);
      if (i == 1) {
        JOptionPane.showMessageDialog(null, "修改成功");
        Object[][] results = getFileStates(Dao.selectSalesman());
        model.setDataVector(results, columnNames);
        table.setModel(model);
      }
    }
 @Override
 public void setDataVector(Vector dataVector, Vector columnIdentifiers) {
   super.setDataVector(dataVector, columnIdentifiers);
 }
  public SalesmanModiAndDelIFrame() {
    super();
    setIconifiable(true);
    setClosable(true);
    setTitle("销售人员信息修改与删除");
    setBounds(100, 100, 600, 420);

    final JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.setPreferredSize(new Dimension(400, 80));
    getContentPane().add(panel, BorderLayout.NORTH);

    final JLabel logoLabel = new JLabel();
    ImageIcon readerModiAndDelIcon = CreatecdIcon.add("readerModiAndDel.jpg");
    logoLabel.setIcon(readerModiAndDelIcon);
    logoLabel.setBackground(Color.CYAN);
    logoLabel.setOpaque(true);
    logoLabel.setPreferredSize(new Dimension(400, 80));
    panel.add(logoLabel);
    logoLabel.setText("销售人员信息修改logo(400*80)");

    final JPanel panel_1 = new JPanel();
    panel_1.setLayout(new BorderLayout());
    getContentPane().add(panel_1);

    final JScrollPane scrollPane = new JScrollPane();
    scrollPane.setPreferredSize(new Dimension(0, 100));
    panel_1.add(scrollPane, BorderLayout.NORTH);

    final DefaultTableModel model = new DefaultTableModel();
    Object[][] results = getFileStates(Dao.selectSalesman());
    model.setDataVector(results, columnNames);

    table = new JTable();
    table.setModel(model);
    scrollPane.setViewportView(table);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.addMouseListener(new TableListener());

    final JPanel panel_2 = new JPanel();
    final GridLayout gridLayout = new GridLayout(0, 4);
    gridLayout.setVgap(9);
    panel_2.setLayout(gridLayout);
    panel_2.setPreferredSize(new Dimension(0, 200));
    panel_1.add(panel_2, BorderLayout.SOUTH);

    final JLabel label_1 = new JLabel();
    label_1.setText("  姓    名:");
    panel_2.add(label_1);

    readername = new JTextField();
    readername.setDocument(new MyDocument(10));
    panel_2.add(readername);

    final JLabel label_2 = new JLabel();
    label_2.setText("  性    别:");
    panel_2.add(label_2);

    final JPanel panel_3 = new JPanel();
    final FlowLayout flowLayout_1 = new FlowLayout();
    flowLayout_1.setVgap(0);
    panel_3.setLayout(flowLayout_1);
    panel_2.add(panel_3);

    JRadioButton1 = new JRadioButton();
    JRadioButton1.setSelected(true);
    buttonGroup.add(JRadioButton1);
    panel_3.add(JRadioButton1);
    JRadioButton1.setText("男");

    JRadioButton2 = new JRadioButton();
    buttonGroup.add(JRadioButton2);
    panel_3.add(JRadioButton2);
    JRadioButton2.setText("女");

    final JLabel label_3 = new JLabel();
    label_3.setText("  年    龄:");
    panel_2.add(label_3);

    age = new JTextField();
    age.setDocument(new MyDocument(2));
    age.addKeyListener(new NumberListener());
    panel_2.add(age);

    final JLabel label_5 = new JLabel();
    label_5.setText("  专    业:");
    panel_2.add(label_5);

    zy = new JTextField();
    zy.setDocument(new MyDocument(30));
    panel_2.add(zy);

    final JLabel label = new JLabel();
    label.setText("  有效证件:");
    panel_2.add(label);

    comboBox = new JComboBox();

    comboBox.setModel(new DefaultComboBoxModel(array));
    for (int i = 1; i < array.length; i++) {
      comboBox.setSelectedIndex(i);
      comboBox.setSelectedItem(array);
    }
    panel_2.add(comboBox);

    final JLabel label_6 = new JLabel();
    label_6.setText("  证件号码:");
    panel_2.add(label_6);

    zjnumber = new JTextField();
    zjnumber.setDocument(new MyDocument(13));
    zjnumber.addKeyListener(new NumberListener());
    panel_2.add(zjnumber);

    final JLabel label_7 = new JLabel();
    label_7.setText("  办证日期:");
    panel_2.add(label_7);

    SimpleDateFormat myfmt = new SimpleDateFormat("yyyy-MM-dd");

    bztime = new JFormattedTextField(myfmt.getDateInstance());

    panel_2.add(bztime);

    final JLabel label_9 = new JLabel();
    label_9.setText("  最大调货量:");
    panel_2.add(label_9);

    maxnumber = new JTextField();
    maxnumber.addKeyListener(new NumberListener());
    panel_2.add(maxnumber);

    final JLabel label_13 = new JLabel();
    label_13.setText("  证件有效日期:");
    panel_2.add(label_13);

    date = new JFormattedTextField(myfmt.getDateInstance());

    panel_2.add(date);

    final JLabel label_8 = new JLabel();
    label_8.setText("  电    话:");
    panel_2.add(label_8);

    tel = new JFormattedTextField();
    tel.addKeyListener(new TelListener());
    tel.setDocument(new MyDocument(11));
    panel_2.add(tel);

    final JLabel label_14 = new JLabel();
    label_14.setText("  工    资:");
    panel_2.add(label_14);

    keepmoney = new JTextField();
    keepmoney.addKeyListener(new KeepmoneyListener());
    panel_2.add(keepmoney);

    final JLabel label_4 = new JLabel();
    label_4.setText("  销售人员编号:");
    panel_2.add(label_4);

    ISBN = new JTextField();
    ISBN.setEditable(false);
    ISBN.setDocument(new MyDocument(13));
    panel_2.add(ISBN);

    final JPanel panel_4 = new JPanel();
    panel_4.setMaximumSize(new Dimension(0, 0));
    final FlowLayout flowLayout = new FlowLayout();
    flowLayout.setVgap(0);
    flowLayout.setHgap(4);
    panel_4.setLayout(flowLayout);
    panel_2.add(panel_4);

    final JButton button = new JButton();
    button.setHorizontalTextPosition(SwingConstants.CENTER);
    panel_4.add(button);
    button.setText("修改");
    button.addActionListener(new ModiButtonListener(model));

    final JButton buttonDel = new JButton();
    panel_4.add(buttonDel);
    buttonDel.setText("删除");
    buttonDel.addActionListener(new DelButtonListener(model));
    setVisible(true);
    //
  }
  /**
   * This method is responsible to represent the potential table as a JTable.
   *
   * @return Returns the JTable representing this potential table. TODO MIGRATE TO A DIFFERENT CLASS
   *     - GUI.TABLE.PROBABILISTICTABLE
   */
  public JTable makeTable() {
    JTable table;
    int nStates = 1;
    // Number of variables
    int nVariables = potentialTable.variableCount();
    Node node = (Node) potentialTable.getVariableAt(0);
    NumberFormat df = NumberFormat.getInstance(Locale.getDefault());
    df.setMaximumFractionDigits(4);

    // calculate the number of states by multiplying the number of
    // states that each father (variables) has. Where variable 0 is the
    // node itself. That is why we divide the table size by the number
    // of states in the node itself.
    /*
     * Ex: states = 12 / 3;
     *
     * |------------------------------------------------------|
     * | Father 2     |      State 1      |      State 2      |
     * |--------------|-------------------|-------------------|
     * | Father 1     | State 1 | State 2 | State 1 | State 2 |
     * |------------------------------------------------------|
     * | Node State 1 |    1    |    1    |    1    |    1    |
     * | Node State 2 |    0    |    0    |    0    |    0    |
     * | Node State 3 |    0    |    0    |    0    |    0    |
     * |------------------------------------------------------|
     *
     */
    nStates = potentialTable.tableSize() / node.getStatesSize();

    // the number of rows is the number of states the node has.
    int rows = node.getStatesSize();

    // the number of columns is the number of states that we calculated
    // before plus one that is the column where the fathers names and
    // the states of the node itself will be placed.
    int columns = nStates + 1;

    // Constructing the data of the data model.
    /*
     * Ex: data[3][4 + 1]
     * |------------------------------------------------------|
     * | Node State 1 |    1    |    1    |    1    |    1    |
     * | Node State 2 |    0    |    0    |    0    |    0    |
     * | Node State 3 |    0    |    0    |    0    |    0    |
     * |------------------------------------------------------|
     */
    String[][] data = new String[rows][columns];

    // Constructing the first header's row
    /*
     * Ex: Following the example above this is the first header's row.
     *
     * |--------------|-------------------|-------------------|
     * | Father 1     | State 1 | State 2 | State 1 | State 2 |
     * |------------------------------------------------------|
     *
     */
    String[] column = new String[data[0].length];
    Node firtHeaderNode;
    // If there is no father, this is going to be the first header's
    // row:
    /*
     * |-----------|---------------|
     * | State     |  Probability  |
     * |---------------------------|
     *
     */
    if (nVariables == 1) {
      column[0] = "State";
      column[1] = "Probability";
    } else {
      firtHeaderNode = (Node) potentialTable.getVariableAt(1);
      /*
       * Ex: Here we get the variable "Father 1" and set its name in
       *     the header.
       *
       * |--------------|
       * | Father 1     |
       * |---------------
       *
       */
      column[0] = firtHeaderNode.getName();
      for (int i = 0; i < data[0].length - 1; i++) {
        if (nVariables > 1) {
          // Reapeats all states in the node until there are cells to
          // fill.
          /*
           * Ex: Following the example above. Here the states go.
           *
           * |-------------------|-------------------|
           * | State 1 | State 2 | State 1 | State 2 |
           * ----------------------------------------|
           *
           */
          column[i + 1] = firtHeaderNode.getStateAt(i % firtHeaderNode.getStatesSize());
        }
      }
    }

    // Filling the data of the data model.
    /*
     * Ex: Fill the data[3][5] constructed above.
     * |------------------------------------------------------|
     * | Node State 1 |    1    |    1    |    1    |    1    |
     * | Node State 2 |    0    |    0    |    0    |    0    |
     * | Node State 3 |    0    |    0    |    0    |    0    |
     * |------------------------------------------------------|
     */
    // The values are arranged in the potential table as a vector.
    /*
     * Ex: This would be the vector in the potential table.
     * |-------------------------------------------------------------------|
     * | Vector Position | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
     * | Vector Value    | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0  | 0  |
     * |-------------------------------------------------------------------|
     */
    // So, for each column we jump the number of values corresponding
    // that column, that is, the number of rows.
    for (int c = 1, n = 0; c < columns; c++, n += rows) {
      for (int r = 0; r < rows; r++) {
        // So, data[0][3] = vector[6 + 0] = 1
        data[r][c] = "" + "" + df.format(potentialTable.getValue(n + r));
      }
    }
    // Now that we filled the values, we are going to put this node's
    // states name.
    /*
     * Ex: Fill the data[i][0] constructed above, that is, its states
     *     name.
     * |---------------
     * | Node State 1 |
     * | Node State 2 |
     * | Node State 3 |
     * |---------------
     */
    for (int i = 0; i < rows; i++) {
      data[i][0] = node.getStateAt(i);
    }

    // Constructing the table so far.
    /*
     * Ex: The table so far, following the example above.
     *
     * |--------------|-------------------|-------------------|
     * | Father 1     | State 1 | State 2 | State 1 | State 2 |
     * |------------------------------------------------------|
     * | Node State 1 |    1    |    1    |    1    |    1    |
     * | Node State 2 |    0    |    0    |    0    |    0    |
     * | Node State 3 |    0    |    0    |    0    |    0    |
     * |------------------------------------------------------|
     *
     */
    DefaultTableModel model = new DefaultTableModel();
    model.setDataVector(data, column);
    table = new JTable();

    // Setup to allow grouping the header.
    table.setColumnModel(new GroupableTableColumnModel());
    table.setTableHeader(
        new GroupableTableHeader((GroupableTableColumnModel) table.getColumnModel()));
    table.setModel(model);

    // Setup Column Groups
    GroupableTableColumnModel cModel = (GroupableTableColumnModel) table.getColumnModel();
    ColumnGroup cNodeGroup = null;
    ColumnGroup cNodeTempGroup = null;
    ColumnGroup cGroup = null;
    List<ColumnGroup> cGroupList = new ArrayList<ColumnGroup>();
    List<ColumnGroup> previousCGroupList = new ArrayList<ColumnGroup>();
    int columnIndex;
    boolean firstNode = true;
    int sizeColumn = 1;
    // Sets default color for parents name in first column.
    /*
     * |---------------
     * | Father 2     |
     * |--------------|
     * | Father 1     |
     * |---------------
     *
     */
    cModel.getColumn(0).setHeaderRenderer(new GroupableTableCellRenderer());
    // Sets default color for node's states
    /*
     * |---------------
     * | Node State 1 |
     * | Node State 2 |
     * | Node State 3 |
     * |---------------
     *
     */
    cModel.getColumn(0).setCellRenderer(new GroupableTableCellRenderer(Color.BLACK, Color.YELLOW));
    // Fill all other headers, but the first (that has already been
    // set). It ignores k = 0 (the node itself) and k = 1 (the fist
    // father).
    for (int k = 2; k < nVariables; k++) {
      Node parent = (Node) potentialTable.getVariableAt(k);
      int nPreviousParentStates = potentialTable.getVariableAt(k - 1).getStatesSize();
      sizeColumn *= nPreviousParentStates;
      // Set the node name as a header in the first column
      if (!firstNode) {
        cNodeTempGroup = cNodeGroup;
        cNodeGroup = new ColumnGroup(new GroupableTableCellRenderer(), parent.getName());
        cNodeGroup.add(cNodeTempGroup);
      } else {
        cNodeGroup = new ColumnGroup(new GroupableTableCellRenderer(), parent.getName());
        cNodeGroup.add(cModel.getColumn(0));
      }
      columnIndex = 1;
      cGroup = null;
      while (columnIndex <= nStates) {
        for (int i = 0; i < parent.getStatesSize(); i++) {
          cGroup = new ColumnGroup(parent.getStateAt(i));
          if (!firstNode) {
            for (int j = 0; j < nPreviousParentStates; j++) {
              ColumnGroup group = previousCGroupList.get(columnIndex - 1);
              cGroup.add(group);
              columnIndex++;
            }
          } else {
            for (int j = 0; j < sizeColumn; j++) {
              cGroup.add(cModel.getColumn(columnIndex++));
            }
          }
          cGroupList.add(cGroup);
        }
      }
      previousCGroupList = cGroupList;
      cGroupList = new ArrayList<ColumnGroup>();
      firstNode = false;
      // Update the number of states
      nStates /= nPreviousParentStates;
    }
    // It adds all parents' node name as header
    if (cNodeGroup != null) {
      cModel.addColumnGroup(cNodeGroup);
    }
    // It adds only the first row (here it is the last parent's states)
    // of the header that has all other headers (all other parent's states)
    // as sub-headers.
    if (previousCGroupList != null) {
      for (ColumnGroup group : previousCGroupList) {
        cModel.addColumnGroup(group);
      }
    }
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    return table;
  }