private void obtenerValorPorcentaje(java.math.BigDecimal valorPorcentaje) {

    java.math.BigDecimal porcentaje =
        new java.math.BigDecimal(
            valorPorcentaje == null ? "0.00" : valorPorcentaje.toString().trim());

    java.math.BigDecimal parcial =
        new java.math.BigDecimal(
            tabla.getValueAt(fila, buscarColumna("Parcial", tabla)).toString().trim().isEmpty()
                ? "1.00"
                : tabla.getValueAt(fila, buscarColumna("Parcial", tabla)).toString().trim());

    java.math.BigDecimal porcentajeFinal =
        (porcentaje
            .multiply(parcial)
            .divide(new java.math.BigDecimal("100.00"), 15, java.math.RoundingMode.HALF_EVEN));

    /// PARA PONER EL VALOR DECIMAL EN EL CAMPO PRECIO
    tabla.setValueAt(porcentajeFinal, fila, buscarColumna("Descuento", tabla));

    /// PARA PONER EL VALOR EN SUBTOTAL
    tabla.setValueAt(parcial.subtract(porcentajeFinal), fila, buscarColumna("Subtotal", tabla));

    //        ///PARA PONER EL VALOR ENTERO EN EL CAMPO CANTIDAD
    //        tabla.setValueAt(cantidad.toString().substring(0, cantidad.toString().indexOf(".")),
    //                fila, buscarColumna("Cantidad", tabla));
    tabla.updateUI();
  }
  private void obtenerPrecio(java.math.BigDecimal valorRetorno) {

    java.math.BigDecimal parcial =
        new java.math.BigDecimal(valorRetorno == null ? "0.00" : valorRetorno.toString().trim());

    java.math.BigDecimal cantidad =
        new java.math.BigDecimal(
            tabla.getValueAt(fila, buscarColumna("Cantidad", tabla)).toString().trim().isEmpty()
                ? "1.00"
                : tabla.getValueAt(fila, buscarColumna("Cantidad", tabla)).toString().trim());

    java.math.BigDecimal precio = parcial.divide(cantidad, 15, java.math.RoundingMode.HALF_EVEN);

    java.math.BigDecimal porcentaje =
        new java.math.BigDecimal(
            tabla.getValueAt(fila, buscarColumna("%", tabla)).toString().trim().isEmpty()
                ? "1.00"
                : tabla.getValueAt(fila, buscarColumna("%", tabla)).toString().trim());

    java.math.BigDecimal valorPorcentaje =
        parcial.multiply(porcentaje).divide(new java.math.BigDecimal("100.00"));
    java.math.BigDecimal valorsubTotal = parcial.subtract(valorPorcentaje);

    tabla.setValueAt(precio, fila, buscarColumna("Precio", tabla));

    tabla.setValueAt(valorPorcentaje, fila, buscarColumna("Descuento", tabla));

    tabla.setValueAt(valorsubTotal, fila, buscarColumna("Subtotal", tabla));
    tabla.updateUI();
  }
  // Monta as Colunas e Linhas da tabela com pontuação
  public void mountTableScore(JTable table) {

    table.setValueAt("Seus Pontos", 1, 0);
    table.setValueAt("Pontos Rival", 2, 0);

    table.setValueAt("Qntd. Tiros", 0, 1);
    table.setValueAt("Acertos", 0, 2);
    table.setValueAt("Restam", 0, 3);
  }
 /** Toggles all check boxes on action occured by "select all" - checkbox */
 private void selectAll() {
   if (selectAll.isSelected())
     for (int i = 0; i < myBranches.length; i++) {
       branchTable.setValueAt(new Boolean(true), i, 0);
     }
   else
     for (int i = 0; i < myBranches.length; i++) {
       branchTable.setValueAt(new Boolean(false), i, 0);
     }
 }
 @Override
 public void reset() {
   idDepartment = 0;
   tableSB32.setValueAt(0, 0, 1);
   tableSB32.setValueAt(0, 0, 3);
   tableSB32.setValueAt(0, 1, 1);
   tableSB32.setValueAt(0, 1, 3);
   tableSB32.setValueAt(" ", 2, 1);
   tableSB32.setValueAt(" ", 2, 3);
 }
 public void displayRoad(JTable table) {
   for (int y = 0; y < roadYLen; y++) {
     for (int x = 0; x < roadXLen; x++) {
       if (road[x][y] != -1) {
         table.setValueAt(road[x][y], y, x);
       } else {
         table.setValueAt("", y, x);
       }
     }
   }
   //            Scanner s = new Scanner(System.in);
   //            String stepToken = s.next();
 }
 @Override
 public void getObject(String id) {
   IDepartmentBN departmentBN = Lookup.getDefault().lookup(IDepartmentBN.class);
   Department department = departmentBN.getByObjectId(id);
   if (department != null) {
     DepartmentExt_W43 bean = dao.getByObjectId(String.valueOf(department.getId()));
     tableSB32.setValueAt(bean.getSumMoneyImport(), 0, 1);
     tableSB32.setValueAt(bean.getSumMoneyExport(), 0, 3);
     tableSB32.setValueAt(bean.getSumprofit(), 1, 1);
     tableSB32.setValueAt(bean.getProportionProfit(), 1, 3);
     tableSB32.setValueAt(" ", 2, 1);
     tableSB32.setValueAt(" ", 2, 3);
   }
 }
Example #8
0
  private void fillInValues() {
    int j = 0;
    int k = 0;
    int l = 0;
    int m = 0;

    // Delete all old stuff
    compareTable.removeAll();
    compareTable.setModel(getDefaultTableModel(true));
    setTableProps();

    // Set base values
    LGFile base = jlft.getBase();
    for (int i = 0; i < base.size(); i++) {
      LGFileSubset subset = (LGFileSubset) base.get(i);
      compareTable.setValueAt(subset, i + k + l, 0);
      for (j = 0; j < subset.size(); j++) {
        if (((LGString) subset.get(j)).getTranslated() != LGString.REMOVED) {
          compareTable.setValueAt(subset.get(j), i + k + j + 1 + l, 0);
          compareTable.setValueAt(subset.get(j), i + k + j + 1 + l, 1);
        } else {
          l--;
        }
      }
      k += j;
    }

    k = 0;
    l = 0;

    // Set compare values
    LGFile compare = jlft.getCompare();
    for (int i = 0; i < compare.size(); i++) {
      if (!((LGFileSubset) compare.get(i)).isRemoved()) {
        LGFileSubset subset = (LGFileSubset) compare.get(i);
        compareTable.setValueAt(subset, i + k + l + m, 2);
        for (j = 0; j < subset.size(); j++) {
          if (((LGString) subset.get(j)).getTranslated() != LGString.REMOVED) {
            compareTable.setValueAt(subset.get(j), i + k + j + 1 + l + m, 2);
            compareTable.setValueAt(subset.get(j), i + k + j + 1 + l + m, 3);
          } else {
            l--;
          }
        }
        k += j;
      } else {
        m--;
      }
    }
  }
Example #9
0
  public static void main(String args[]) {
    String[] columnNames = {"Name", "Lastname", "Id", "Style"};
    mysTable = new JTable(100, 3);
    mysTable.setBounds(20, 10, 300, 300);

    JFrame frame = new JFrame("King Musa Saloon Software");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(null);
    frame.setSize(500, 500);
    frame.setResizable(false);
    frame.setVisible(true);
    frame.add(mysTable);

    // frame.add(mysTable);
    try {
      Class.forName("org.sqlite.JDBC");
      System.out.println("Driver loading success!");
      String url = "jdbc:sqlite:d:/sqlite/testDB.db";
      String name = "";
      String password = "";
      try {

        java.sql.Connection con = DriverManager.getConnection(url, name, password);
        System.out.println("Connected.");
        // pull data from the database
        java.sql.Statement stmts = null;
        String query = "select  date, level, message from Test1 limit 100";
        stmts = con.createStatement();
        ResultSet rs = stmts.executeQuery(query);
        int li_row = 0;
        while (rs.next()) {
          mysTable.setValueAt(rs.getString("date"), li_row, 0);
          mysTable.setValueAt(rs.getString("level"), li_row, 1);
          mysTable.setValueAt(rs.getString("message"), li_row, 2);
          //    int userid = rs.getInt("userid");
          //    String username = rs.getString("username");
          //    String name1     = rs.getString("name");
          //    System.out.println(name1);
          li_row++;
        }

      } catch (SQLException e) {
        e.printStackTrace();
      }

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
  }
  @Action
  public void confirm() {
    String itemName = jTextFieldForOPCItemName.getText();

    if (StringUtils.isBlank(itemName)) {
      JOptionPane.showMessageDialog(this, "请选择OPC项");
      return;
    }

    filter.removeAccessPath();
    filter.removeServerId();
    filter.removeVarType();
    filter.setNameFilter(itemName);

    List<YGOpcItem> opcItems = filter.doFiter(opcItemList);
    if (opcItems == null || opcItems.size() < 1) {
      JOptionPane.showMessageDialog(this, "选择OPC项失败,不存在此编码的OPC项");
      return;
    }

    YGOpcItem selectOpcItem = opcItems.get(0);
    String selectOpcItemName = selectOpcItem.getItemName();

    baseTable.setValueAt(selectOpcItemName, row, col);
    this.setVisible(false);
  }
  public void doPaste() {
    JTable table = editor.getSeriesDataMatrix().myTable;

    int col = table.getSelectedColumn();
    int row = table.getSelectedRow();

    ArrayList<Integer> values = getValuesFromClipboard();

    if (values == null || values.size() == 0) {

      Alert.message(
          App.mainWindow,
          "Paste failed",
          "Paste failed.  Check the data you are pasting is a column list of integers");
      return;
    }

    for (Integer value : values) {
      if (table.isCellEditable(row, col)) {
        table.setValueAt(value, row, col);
      } else {
        log.error("Failed");
        Alert.message(
            App.mainWindow,
            "Paste failed",
            "Paste failed.  Check the data you are pasting is a column list of integers");
        return;
      }

      TableCoords nextCell = ((DecadalModel) table.getModel()).getCoordsOfNextCell(row, col);
      row = nextCell.getRow();
      col = nextCell.getCol();
    }
  }
Example #12
0
 /** Updates current stock amounts from the text file */
 public void update() {
   ArrayList<String> stockFile = new ArrayList<String>();
   stockFile = Stocks.sReadFileData();
   for (int i = 0; i < stockFile.size() / 2; i++) {
     stockTable.setValueAt(stockFile.get(2 * i + 1), i, 1);
   }
 }
    @Override
    protected void editCell(JTable table, int row, int column) {
      String oldValor = (String) table.getValueAt(row, column);
      String newValor = showTextEditDialog("Descripción", table, row, 300, 150, oldValor);

      if (newValor != null) table.setValueAt(newValor, row, column);
    }
 private void statusTabel(JTable tabela) {
   DefaultTableModel modelo = (DefaultTableModel) tabela.getModel();
   if (modelo.getRowCount() == 0) {
     modelo.addRow(new String[1]);
     tabela.setValueAt("Nenhuma Pendência", 0, 0);
   }
 }
  /**
   * fills 'cTable' with the values in confMatrix
   *
   * @param confMatrix Mat - a result from TestingResult 'res'
   */
  public void fillConfTable(double[][] confMatrix) {
    // initialize table header
    JTableHeader header = cTable.getTableHeader();
    for (int i = 0; i < cTable.getColumnCount() - 1; i++) {
      TableColumn column1 = cTable.getTableHeader().getColumnModel().getColumn(i + 1);
      column1.setHeaderValue(wordClasses[i]);
    }
    System.out.println(cTable.getColumnCount());
    // fill the first column with classes

    for (int i = 0; i < wordClasses.length; i++) {
      for (int j = 0; j < wordClasses.length; j++) {
        cTable.setValueAt(wordClasses[i], i, 0);
        cTable.setValueAt(confMatrix[i][j], i, j + 1);
      }
    }
  }
Example #16
0
 /** Inits the input table. */
 private void initTableIn() {
   double dummy = 0.0;
   for (int row = 0; row < tabIn.getRowCount(); ++row) {
     for (int col = 0; col < tabIn.getColumnCount(); ++col) {
       ++dummy;
       tabIn.setValueAt(String.valueOf(dummy), row, col);
     }
   }
 }
Example #17
0
 void Fix_regfile_table(JTable regTable) {
   Register_file regfile = stage_id.getRegfile();
   for (int n = 0; n < 32; n++) {
     int c = 0;
     int r = n % 8;
     if (n <= 7) {
       c = 0;
     } else if (n <= 15) {
       c = 1;
     } else if (n <= 23) {
       c = 2;
     } else {
       c = 3;
     }
     if (n == 31)
       regTable.setValueAt(Integer.toHexString(regfile.getRegfile(n) * 4), r, 2 * c + 1);
     else regTable.setValueAt(regfile.getRegfile(n), r, 2 * c + 1);
   }
 }
 public void accionAgregar(JTable tabla) throws ParseException, SQLException {
   if (tabla.getSelectedRow() >= 0) {
     Date fechaDia = formatoFecha.parse(Conexion.getInstancia().obtenerFechaDia());
     if (txtFecha.getDate().before(fechaDia)) {
       JOptionPane.showMessageDialog(
           this,
           "La fecha no puede ser anterior al día de hoy.",
           "DENEGADO",
           JOptionPane.ERROR_MESSAGE);
     } else {
       String monto = txtMontoAcuerdo.getText();
       date = formatoFecha.format(txtFecha.getDate());
       tabla.setValueAt(monto, tabla.getSelectedRow(), 4);
       tabla.setValueAt(date, tabla.getSelectedRow(), 3);
     }
   } else {
     JOptionPane.showMessageDialog(
         this, "Es necesario seleccionar un campo.", "DENEGADO", JOptionPane.ERROR_MESSAGE);
   }
 }
Example #19
0
 /** Sets the values of the selected cells to the textfield content. */
 private void fillTextIntoTable() {
   if (tblIntermed != null) {
     final int[] x = tblIntermed.getSelectedColumns();
     final int[] y = tblIntermed.getSelectedRows();
     for (final int i : y) {
       for (final int j : x) {
         tblIntermed.setValueAt(jTextField1.getText(), i, j);
       }
     }
   }
 }
Example #20
0
 public static void main(String[] args) {
   /*
   构造函数有很多下面先介绍几个:
   JTable()
   JTable(int numRows, int numColumns)
   JTable(Object[][] rowData, Object[] columnNames)
   */
   JTable example1 = new JTable(); // 看不到但存在
   JTable example2 = new JTable(8, 6);
   final Object[] columnNames = {
     "姓名", "性别", "家庭地址", // 列名最好用final修饰
     "电话号码", "生日", "工作", "收入", "婚姻状况", "恋爱状况"
   };
   Object[][] rowData = {
     {"ddd", "男", "江苏南京", "1378313210", "03/24/1985", "学生", "寄生中", "未婚", "没"},
     {"eee", "女", "江苏南京", "13645181705", "xx/xx/1985", "家教", "未知", "未婚", "好象没"},
     {"fff", "男", "江苏南京", "13585331486", "12/08/1985", "汽车推销员", "不确定", "未婚", "有"},
     {"ggg", "女", "江苏南京", "81513779", "xx/xx/1986", "宾馆服务员", "确定但未知", "未婚", "有"},
     {"hhh", "男", "江苏南京", "13651545936", "xx/xx/1985", "学生", "流放中", "未婚", "无数次分手后没有"}
   };
   JTable friends = new JTable(rowData, columnNames);
   friends.setPreferredScrollableViewportSize(new Dimension(600, 100)); // 设置表格的大小
   friends.setRowHeight(30); // 设置每行的高度为20
   friends.setRowHeight(0, 20); // 设置第1行的高度为15
   friends.setRowMargin(5); // 设置相邻两行单元格的距离
   friends.setRowSelectionAllowed(true); // 设置可否被选择.默认为false
   friends.setSelectionBackground(Color.white); // 设置所选择行的背景色
   friends.setSelectionForeground(Color.red); // 设置所选择行的前景色
   friends.setGridColor(Color.black); // 设置网格线的颜色
   friends.selectAll(); // 选择所有行
   friends.setRowSelectionInterval(0, 2); // 设置初始的选择行,这里是1到3行都处于选择状态
   friends.clearSelection(); // 取消选择
   friends.setDragEnabled(false); // 不懂这个
   friends.setShowGrid(false); // 是否显示网格线
   friends.setShowHorizontalLines(false); // 是否显示水平的网格线
   friends.setShowVerticalLines(true); // 是否显示垂直的网格线
   friends.setValueAt("tt", 0, 0); // 设置某个单元格的值,这个值是一个对象
   friends.doLayout();
   friends.setBackground(Color.lightGray);
   JScrollPane pane1 = new JScrollPane(example1); // JTable最好加在JScrollPane上
   JScrollPane pane2 = new JScrollPane(example2);
   JScrollPane pane3 = new JScrollPane(friends);
   JPanel panel = new JPanel(new GridLayout(0, 1));
   panel.setPreferredSize(new Dimension(600, 400));
   panel.setBackground(Color.black);
   panel.add(pane1);
   panel.add(pane2);
   panel.add(pane3);
   JFrame frame = new JFrame("JTableDemo");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setContentPane(panel);
   frame.pack();
   frame.show();
 }
    private String showTextEditDialog(
        final String dialogTitle,
        JTable table,
        final int row,
        final int width,
        final int height,
        final String textToEdit) {

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

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

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

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

      // Might be good text, might be null
      return result;
    }
Example #22
0
 /**
  * This method is activated on the Keystrokes we are listening to in this implementation. Here it
  * listens for Copy and Paste ActionCommands. Selections comprising non-adjacent cells result in
  * invalid selection and then copy action cannot be performed. Paste is done by aligning the upper
  * left corner of the selection with the 1st element in the current selection of the JTable.
  */
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().compareTo("Copy") == 0) {
     StringBuffer sbf = new StringBuffer();
     // Check to ensure we have selected only a contiguous block of
     // cells
     int numcols = jTable1.getSelectedColumnCount();
     int numrows = jTable1.getSelectedRowCount();
     int[] rowsselected = jTable1.getSelectedRows();
     int[] colsselected = jTable1.getSelectedColumns();
     if (!((numrows - 1 == rowsselected[rowsselected.length - 1] - rowsselected[0]
             && numrows == rowsselected.length)
         && (numcols - 1 == colsselected[colsselected.length - 1] - colsselected[0]
             && numcols == colsselected.length))) {
       JOptionPane.showMessageDialog(
           null, "Invalid Copy Selection", "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE);
       return;
     }
     for (int i = 0; i < numrows; i++) {
       for (int j = 0; j < numcols; j++) {
         sbf.append(jTable1.getValueAt(rowsselected[i], colsselected[j]));
         if (j < numcols - 1) sbf.append("\t");
       }
       sbf.append("\n");
     }
     stsel = new StringSelection(sbf.toString());
     system = Toolkit.getDefaultToolkit().getSystemClipboard();
     system.setContents(stsel, stsel);
   }
   if (e.getActionCommand().compareTo("Paste") == 0) {
     System.out.println("Trying to Paste");
     int startRow = (jTable1.getSelectedRows())[0];
     int startCol = (jTable1.getSelectedColumns())[0];
     try {
       String trstring =
           (String) (system.getContents(this).getTransferData(DataFlavor.stringFlavor));
       System.out.println("String is:" + trstring);
       StringTokenizer st1 = new StringTokenizer(trstring, "\n");
       for (int i = 0; st1.hasMoreTokens(); i++) {
         rowstring = st1.nextToken();
         StringTokenizer st2 = new StringTokenizer(rowstring, "\t");
         for (int j = 0; st2.hasMoreTokens(); j++) {
           value = (String) st2.nextToken();
           if (startRow + i < jTable1.getRowCount() && startCol + j < jTable1.getColumnCount())
             jTable1.setValueAt(value, startRow + i, startCol + j);
           System.out.println(
               "Putting " + value + "at row = " + startRow + i + "column = " + startCol + j);
         }
       }
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
 }
Example #23
0
 /**
  * DOCUMENT ME!
  *
  * @param evt DOCUMENT ME!
  */
 private void jButton1ActionPerformed(
     final java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
   if (tblIntermed != null) {
     final int[] x = tblIntermed.getSelectedColumns();
     final int[] y = tblIntermed.getSelectedRows();
     for (final int i : y) {
       for (final int j : x) {
         tblIntermed.setValueAt(null, i, j);
       }
     }
   }
 } // GEN-LAST:event_jButton1ActionPerformed
    /*
     * When user leaves a cell after editing it, the contents of
     * that cell need to be converted from a string into an
     * object of the appropriate type before updating the table.
     * However, when the call comes from the Popup window, the data
     * has already been converted and validated.
     * We assume that a String being passed in here is a value from
     * a text field that needs to be converted to an object, and
     * a non-string object has already been validated and converted.
     */
    public void setValueAt(Object newValueString, int row, int col) {
      if (!(newValueString instanceof java.lang.String)) {
        // data is an object - assume already validated
        super.setValueAt(newValueString, row, col);
        return;
      }

      // data is a String, so we need to convert to real object
      StringBuffer messageBuffer = new StringBuffer();

      int modelIndex = getColumnModel().getColumn(col).getModelIndex();
      ColumnDisplayDefinition colDef = getColumnDefinitions()[modelIndex];
      Object newValueObject =
          CellComponentFactory.validateAndConvert(
              colDef, getValueAt(row, col), (String) newValueString, messageBuffer);

      if (messageBuffer.length() > 0) {

        // i18n[dataSetViewerTablePanel.textCantBeConverted=The given text cannot be converted into
        // the internal object.\nThe database has not been changed.\nThe conversion error was:\n{0}]
        String msg =
            s_stringMgr.getString("dataSetViewerTablePanel.textCantBeConverted", messageBuffer);

        if (s_log.isDebugEnabled()) {
          s_log.debug("setValueAt: msg from DataTypeComponent was: " + msg);
        }

        // display error message and do not update the table
        JOptionPane.showMessageDialog(
            this,
            msg,
            // i18n[dataSetViewerTablePanel.conversionError=Conversion Error]
            s_stringMgr.getString("dataSetViewerTablePanel.conversionError"),
            JOptionPane.ERROR_MESSAGE);

      } else {
        // data converted ok, so update the table
        super.setValueAt(newValueObject, row, col);
      }
    }
  @Test
  public void variablesProperty() {
    final JTable table = new JTable();
    bindingContext.bind("conditions", new ConditionsTableAdapter(table));
    assertTrue(table.getModel() instanceof DefaultTableModel);

    final DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
    tableModel.addRow((Object[]) null);
    tableModel.addRow((Object[]) null);

    assertEquals(2, table.getRowCount());

    table.setValueAt("a", 0, 0);
    assertEquals("a", table.getValueAt(0, 0));
    table.setValueAt("A", 0, 1);
    assertEquals("A", table.getValueAt(0, 1));
    table.setValueAt(true, 0, 2);
    assertEquals(true, table.getValueAt(0, 2));

    table.setValueAt("b", 1, 0);
    assertEquals("b", table.getValueAt(1, 0));
    table.setValueAt("B", 1, 1);
    assertEquals("B", table.getValueAt(1, 1));
    table.setValueAt(false, 1, 2);
    assertEquals(false, table.getValueAt(1, 2));

    bindingContext
        .getPropertySet()
        .setValue("conditions", new MosaicOp.Condition[] {new MosaicOp.Condition("d", "D", true)});

    assertEquals(1, table.getRowCount());
    assertEquals("d", table.getValueAt(0, 0));
    assertEquals("D", table.getValueAt(0, 1));
    assertEquals(true, table.getValueAt(0, 2));
  }
  public void displayAccuracy(TestingResult res) {
    for (int i = 0; i < wordClasses.length; i++) {
      Object[] row = {
        wordClasses[i],
        res.precisionANN[i],
        res.recallANN[i],
        res.precisionSVM[i],
        res.recallSVM[i],
        res.precisionBN[i],
        res.recallBN[i]
      };
      DefaultTableModel model = (DefaultTableModel) accuracyTable.getModel();
      model.addRow(row);
    }
    summaryTable.setValueAt(res.accuracyANN, 0, 1);
    summaryTable.setValueAt(res.accuracySVM, 0, 2);
    summaryTable.setValueAt(res.accuracyBN, 0, 3);

    summaryTable.setValueAt(res.overallPresicionANN, 1, 1);
    summaryTable.setValueAt(res.overallPresicionSVM, 1, 2);
    summaryTable.setValueAt(res.overallPresicionBN, 1, 3);

    summaryTable.setValueAt(res.overallRecallANN, 2, 1);
    summaryTable.setValueAt(res.overallRecallSVM, 2, 2);
    summaryTable.setValueAt(res.overallRecallBN, 2, 3);
    // System.out.println("results:
    // \nANN:"+res.overallPresicionANN+"\nSVM"+res.overallPresicionSVM+"\nBN"+res.overallPresicionBN);

  }
  private void obtenerValorPorcentaje(java.math.BigDecimal valorDescuento) {

    try {
      //////////////////////////// ESTO ES PARA OBTENER EL PORCENTAJE
      java.math.BigDecimal parcial =
          new java.math.BigDecimal(
              tabla.getValueAt(fila, buscarColumna("Parcial", tabla)) == null
                      || tabla
                          .getValueAt(fila, buscarColumna("Parcial", tabla))
                          .toString()
                          .trim()
                          .isEmpty()
                  ? "0.00"
                  : tabla.getValueAt(fila, buscarColumna("Parcial", tabla)).toString().trim());

      java.math.BigDecimal descuento =
          new java.math.BigDecimal(
              valorDescuento == null ? "0.00" : valorDescuento.toString().trim());

      java.math.BigDecimal multiplicacion = descuento.multiply(new java.math.BigDecimal("100.00"));
      java.math.BigDecimal division = cero;

      if (parcial.compareTo(cero) > 0)
        division = multiplicacion.divide(parcial, 15, java.math.RoundingMode.HALF_UP);
      tabla.setValueAt(division.toPlainString(), fila, buscarColumna("%", tabla));

      /// PARA PONER EL SUBTOTAL
      //            table.setValueAt(parcial.subtract(division), fila, buscarColumna("Subtotal"));
      //            if (division.compareTo(mDIShrimp.getCero()) == 0){
      //                table.setValueAt(parcial.subtract(division), fila,
      // buscarColumna("Subtotal"));
      //            } else {
      //                table.setValueAt(division.subtract(parcial), fila,
      // buscarColumna("Subtotal"));
      //            }

      tabla.repaint();
    } catch (Exception e) {
      shrimp.helper.JDVentanaMensajes.showMessageDialog(
          new javax.swing.JFrame(),
          "Ha ocurrido un error inesperado en el formulario",
          javax.swing.JOptionPane.ERROR_MESSAGE,
          javax.swing.JOptionPane.DEFAULT_OPTION,
          e,
          null);
    }

    //        ///PARA PONER EL VALOR ENTERO EN EL CAMPO CANTIDAD
    //        tabla.setValueAt(cantidad.toString().substring(0, cantidad.toString().indexOf(".")),
    //                fila, buscarColumna("Cantidad", tabla));
    tabla.updateUI();
  }
Example #28
0
  /**
   * The method is responsible for assigning the value returned by the date editor component to the
   * respective cell whose value is being edited.
   */
  protected void assignEditorValue(javax.swing.JTable table) {

    dateFormat = java.text.DateFormat.getDateInstance(java.text.DateFormat.LONG); // MEDIUM);

    java.util.Date dateReturned = ((com.toedter.calendar.JDateChooser) editorComponent).getDate();

    java.lang.String dateString = dateFormat.format(dateReturned);

    table.setValueAt(dateString, table.getSelectedRow(), table.getSelectedColumn());

    //        System.out.println("Editing stopped!");

  }
Example #29
0
 void expressionChanged(String oldValue, String newValue) {
   if (((DefaultListModel) availableExpressions.getModel()).contains(oldValue)) {
     ((DefaultListModel) availableExpressions.getModel()).removeElement(oldValue);
     ((DefaultListModel) availableExpressions.getModel()).addElement(newValue);
   } else {
     for (int i = 0; i < selectedExpressions.getRowCount(); i++) {
       if (selectedExpressions.getValueAt(i, 1).toString().equals(oldValue)) {
         selectedExpressions.setValueAt(newValue, i, 1);
         break;
       }
     }
   }
 }
Example #30
0
 public void buscaProduto() {
   // instancia produto
   Produto p = new Produto();
   // instancia produto da compra
   produtodavenda = new ProdutosDaVenda();
   // cria a tela de busca como modal
   FramePesquisaProduto tela_busca = new FramePesquisaProduto();
   tela_busca.setModal(true);
   // exibe a tela de pesquisa do produto
   tela_busca.setVisible(true);
   // recupera os dados
   p = tela_busca.retornaProduto();
   // seta o produto para o produto da compra
   produtodavenda.setProduto_codigo(p);
   // seta na tela o produto da compra
   if (produtodavenda.getProduto_codigo() != null) {
     Integer linhaSelecionada = jtbVenda.getSelectedRow();
     jtbVenda.setValueAt(p.getCodigo(), linhaSelecionada, 0);
     jtbVenda.setValueAt(p.getDescricao(), linhaSelecionada, 1);
     jtbVenda.setValueAt(p.getPrecoVenda(), linhaSelecionada, 3);
   }
 }