Example usage for javax.swing.table TableModel getValueAt

List of usage examples for javax.swing.table TableModel getValueAt

Introduction

In this page you can find the example usage for javax.swing.table TableModel getValueAt.

Prototype

public Object getValueAt(int rowIndex, int columnIndex);

Source Link

Document

Returns the value for the cell at columnIndex and rowIndex.

Usage

From source file:app.RunApp.java

/**
 * Get selected metrics in table from multiple datasets tab
 * //from   w  ww  . ja  va  2  s.  c  om
 * @param jtable Table
 * @return List with the selected metrics
 */
private ArrayList<String> getSelectedMetricsMulti(JTable jtable) {
    ArrayList<String> result = new ArrayList();
    TableModel tmodel = jtable.getModel();

    for (int i = 0; i < tmodel.getRowCount(); i++) {
        if ((Boolean) tmodel.getValueAt(i, 1)) {
            String selected = (String) tmodel.getValueAt(i, 0);
            result.add(selected);
        }
    }
    return result;
}

From source file:app.RunApp.java

/**
 * Action for Invert button from principal tab
 * /*  w  w  w .  jav  a2  s.  c o m*/
 * @param evt Event
 * @param jtable Table
 */
private void buttonInvertActionButtonPerformed(java.awt.event.ActionEvent evt, JTable jtable) {
    TableModel tmodel = jtable.getModel();

    for (int i = 0; i < tmodel.getRowCount(); i++) {
        if ((Boolean) tmodel.getValueAt(i, 2)) {
            tmodel.setValueAt(Boolean.FALSE, i, 2);
        } else {
            tmodel.setValueAt(Boolean.TRUE, i, 2);
        }
    }

    jtable.setModel(tmodel);
    jtable.repaint();
}

From source file:app.RunApp.java

/**
 * Action for Invert button from multiple datasets tab
 * //from ww w .j  av  a  2s  .  co m
 * @param evt Event
 * @param jtable Table
 */
private void buttonInvertActionPerformedMulti(java.awt.event.ActionEvent evt, JTable jtable) {
    TableModel tmodel = jtable.getModel();

    for (int i = 0; i < tmodel.getRowCount(); i++) {
        if ((Boolean) tmodel.getValueAt(i, 1)) {
            tmodel.setValueAt(Boolean.FALSE, i, 1);
        } else {
            tmodel.setValueAt(Boolean.TRUE, i, 1);
        }
    }

    jtable.setModel(tmodel);
    jtable.repaint();
}

From source file:app.RunApp.java

/**
 * Action for Calculate button from principal tab
 * // w ww  . j a  v  a2s.  com
 * @param evt Event
 * @param jtable Table
 */
private void buttonCalculateActionPerformedPrincipal(java.awt.event.ActionEvent evt, JTable jtable) {
    ArrayList<String> metricsList = getMetricsSelectedPrincipal(jtable);

    if (dataset == null) {
        JOptionPane.showMessageDialog(null, "You must load a dataset.", "Warning", JOptionPane.ERROR_MESSAGE);
        return;
    } else if (metricsList.isEmpty()) {
        JOptionPane.showMessageDialog(null, "You must select any metric.", "Warning",
                JOptionPane.ERROR_MESSAGE);
        return;
    }

    //ImbalancedFeature[] label_frenquency = MetricUtils.getImbalancedDataByAppearances(dataset);
    //label_frenquency = MetricUtils.sortByFrequency(label_frenquency);// ordena de mayor a menor

    String value;

    progressBar.setMinimum(0);
    progressBar.setMaximum(metricsList.size() + 1);
    progressBar.setValue(0);
    int v = 1;
    for (String metric : metricsList) {
        progressBar.setValue(v);
        //If metric value exists, don't calculate
        if ((tableMetrics.get(metric) == null) || (tableMetrics.get(metric).equals("-"))) {
            value = MetricUtils.getMetricValue(metric, dataset);
            tableMetrics.put(metric, value.replace(",", "."));
        }

        v++;
    }

    TableModel model = jtable.getModel();

    for (int i = 0; i < model.getRowCount(); i++) {
        model.setValueAt(MetricUtils.getValueFormatted(model.getValueAt(i, 0).toString(),
                tableMetrics.get(model.getValueAt(i, 0).toString())), i, 1);
    }

    jtable.repaint();
}

From source file:app.RunApp.java

/**
 * Clear table of metrics from principal tab
 *///from   w w  w  . j av  a2s. co  m
private void clearTableMetricsPrincipal() {
    ArrayList<String> metricsList = MetricUtils.getAllMetrics();

    for (String metric : metricsList) {
        if (metric.charAt(0) != '<') {
            tableMetrics.put(metric, "-");
        } else {
            tableMetrics.put(metric, "");
        }
    }

    TableModel model = jTablePrincipal.getModel();

    for (int i = 0; i < model.getRowCount(); i++) {
        if (metricsList.get(i).charAt(0) != '<') {
            model.setValueAt(tableMetrics.get(model.getValueAt(i, 0).toString()), i, 1);
        }
    }

    jTablePrincipal.repaint();
}

From source file:semaforo.Semaforo.java

public void core() {
    //                    double cfd=0, bull=0, bear=0;
    //                    if(finalcountCfd!=0)cfd = ((finalcountCfd*100)/(finalcountBear+finalcountBull+finalcountCfd));
    //                    if(finalcountBull!=0)bull = ((finalcountBull*100)/(finalcountBear+finalcountBull+finalcountCfd));
    //                    if(finalcountBear!=0)bear = ((finalcountBear*100)/(finalcountBear+finalcountBull+finalcountCfd));
    //                    Semaforo.l1.setText("CFD ("+cfd+"%)");

    if (countCfd > 0 && !cfd) {
        Semaforo.l1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/redL.png")));
        cfd = true;// w  w  w  .j  ava  2  s .c  o  m
    } else if (countBull > 0 && !bull) {
        Semaforo.l2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/redL.png")));
        bull = true;
    } else if (countBear > 0 && !bear) {
        Semaforo.l3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/redL.png")));
        bear = true;
    }

    if (countCfd > 0 && !cfd) {
        Semaforo.l1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blueL.png")));
        cfd = true;
    } else if (countBull > 0 && !bull) {
        Semaforo.l2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blueL.png")));
        bull = true;
    } else if (countBear > 0 && !bear) {
        Semaforo.l3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blueL.png")));
        bear = true;
    }

    if (countCfd > 0 && !cfd) {
        Semaforo.l1
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/greenL.png")));
        cfd = true;
    } else if (countBull > 0 && !bull) {
        Semaforo.l2
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/greenL.png")));
        bull = true;
    } else if (countBear > 0 && !bear) {
        Semaforo.l3
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/greenL.png")));
        bear = true;
    }

    if (countCfd <= 0) {
        Semaforo.l1
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blackL.png")));
    }
    if (countBull <= 0) {
        Semaforo.l2
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blackL.png")));
    }
    if (countBear <= 0) {
        Semaforo.l3
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/blackL.png")));
    }
    //                 
    try {
        refrescarPorcentajeGroups();
    } catch (SQLException ex) {
        Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex);
    }

    Random r = new Random(System.currentTimeMillis());
    //Mcol = r.nextInt(8) + 1;

    while (update == 2) {
        try {
            Thread.sleep(50);
        } catch (InterruptedException ex) {
            Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    synchronized (updateLock) {
        update = 0;
    }

    final Settings settings = Controller.getSettings();
    Hashtable<String, List<Integer>> ht = Controller.getTickersValue();

    while (Controller.isCalculatingColor) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException ex) {
            Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    synchronized (calculateColorLock) {
        Controller.isCalculatingColor = true;
    }

    for (int t = 0; t < settings.getTickers().size(); t++) {
        Controller.calcular_color(settings.getTickers().get(t).getName(),
                settings.getTickers().get(t).getCurrentPrice());
    }

    synchronized (Controller.calculateColorLock) {
        Controller.isCalculatingColor = false;
    }

    //Aqu se aplica el ordenamiento
    final Map<String, List<Integer>> map = sortByValues(ht);
    maP = map;
    TableModel temp = TableTicker.getModel();

    //              
    updatePanelSemaforo();

    //$$$ SE SETEA LAS COLUMNAS DE TICKER
    int capital = 0;
    Object obje = null;

    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -1);
    SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
    String fechaAyer = format1.format(cal.getTime());

    Calendar cal2 = Calendar.getInstance();
    SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
    String fechaHoy = format2.format(cal2.getTime());

    int compradasOld, compradasHoy;

    String columnsTitle[] = { "Ticker", "Price", "To Invest", "CFD", "Bought", "Remain", "LOW DAY",
            "Comprar?" };
    Object rows[][] = new Object[settings.getTickers().size()][9];

    rowsCopy tablaCopia = new rowsCopy(settings.getTickers().size(), 7, 2);
    Object TablaConHedge[][] = new Object[500][8];
    int[] numerosEstado = new int[500];

    TablaConHedge = tablaCopia.retornaCopiaTabla();
    numerosEstado = tablaCopia.retornaNumerosEstado();
    //int size = TableTicker.getRowCount();
    int fila = 0;

    int cuentaTickersBaja = 0;
    int cuentaTickersValidos = 0;
    boolean actualizar = false;
    Iterator iterator = map.entrySet().iterator();
    while (iterator.hasNext()) {
        Entry entry = (Entry) iterator.next();
        for (Ticker ticker : settings.getTickers()) {
            if (ticker.getName().equalsIgnoreCase(entry.getKey().toString())) {
                //$$$ 0 Nombre del Ticker
                rows[fila][0] = ticker.getName();
                //$$$ 1 Valor del Ticker    
                currentSym = rows[fila][0].toString();

                Thread t = new Thread(new Runnable() {

                    public String t = currentSym;

                    @Override
                    public void run() {
                        Curl.jsonDecode(Curl.preciosTicker(t), t);
                    }
                });
                t.start();

                rows[fila][1] = String.format("%.2f", ticker.getCurrentPrice());
                DDBB.updatePriceTicker(rows[fila][0].toString(), rows[fila][1].toString());

                ResultSet resTickers = DDBB.lowHigh(rows[fila][0].toString());
                try {
                    if (resTickers.next()) {
                        //                                       String low=resTickers.getString("low_low").toString().replace(",", ".");
                        //                                       String high=resTickers.getString("high_high").toString().replace(",", ".");
                        rows[fila][6] = resTickers.getString("low_low").toString().replace(",", ".");
                        //                                       String pre=rows[fila][1].toString().replace(",", ".");
                        //                                       if(pre.isEmpty())pre=rows[fila][1].toString();                                      
                        //                                       double precio = Float.parseFloat(pre);
                        //                                       double low_low = Float.parseFloat(low);
                        //                                       double high_high = Float.parseFloat(high);

                        //kobytest.KobyTest.pedir_historico(Settings.getTickerID(rows[fila][0].toString()), rows[fila][0].toString(), kobytest.KobyTest.total_weeks_ago);
                        //                                       if(precio>high_high){
                        //                                           DDBB.updateHighHighTicker(rows[fila][0].toString(), rows[fila][1].toString());
                        //                                       }
                        //                                       if(precio<low_low){
                        //                                           DDBB.updateLowLowTicker(rows[fila][0].toString(), rows[fila][1].toString());
                        //                                       }

                    }
                    //$$$ 2 CAPITAL
                } catch (SQLException ex) {
                    Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex);
                }

                //$$$ rutina para precarga de DDBB
                //int capitalDB = Controller.getSettings().getCapital(ticker.getName());
                //valoresTickerCapital.put(ticker.getName(), capitalDB);
                //System.out.println("***************************** CAPITAL HASHMAP  " + valoresTickerCapital.size() + "  " + valoresTickerCapital.toString());
                int tempFila = getFilaTickerFrontEnd(temp, ticker.getName());
                if (tempFila > -1) {
                    obje = temp.getValueAt(tempFila, 2);
                }

                try {
                    capital = Integer
                            .parseInt((obje == null || obje.toString().isEmpty()) ? "0" : obje.toString());

                    ElementoCapitalDB elemCapitalDB = valoresTickerCapital.get(ticker.getName());

                    if ((elemCapitalDB != null) && !(valoresTickerCapital.get(ticker.getName()).isChequeado)) {

                        if (semaforo.Semaforo.isDebugMode) {
                            System.out.println(
                                    "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Lectura de DDBB  " + elemCapitalDB);
                        }
                        if (semaforo.Semaforo.isDebugMode) {
                            System.out.println("");
                        }
                        if (semaforo.Semaforo.isDebugMode) {
                            System.out.println("");
                        }

                        rows[fila][2] = valoresTickerCapital.get(ticker.getName()).getCapital();
                        valoresTickerCapital.get(ticker.getName()).setIsChequeado(true);

                    } else {
                        rows[fila][2] = (capital == 0) ? "" : capital;
                    }

                    if (semaforo.Semaforo.isDebugMode) {
                        System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ROWS FILA " + fila
                                + " COLUMNA  2 VALE: " + rows[fila][2]);
                    }

                    elemCapitalDB = valoresTickerCapital.get(ticker.getName());
                    if (elemCapitalDB == null) {
                        elemCapitalDB = new ElementoCapitalDB();
                        elemCapitalDB.setCapital(0);
                        elemCapitalDB.setIsChequeado(true);
                    }

                    int capitalDB = elemCapitalDB.getCapital();
                    //rows[fila][2] = capitalDB;

                    if ((capitalDB != capital)) {
                        Controller.getSettings().setCapital(ticker.getName(), capital);
                        elemCapitalDB.setCapital(capital);
                        elemCapitalDB.setIsChequeado(true);
                        valoresTickerCapital.put(ticker.getName(), elemCapitalDB);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                    rows[fila][2] = "";
                }

                //rows[fila][2]
                //.....
                //$$$ 3 CFD                               
                rows[fila][3] = String.format("", Math.round((capital / ticker.getCurrentPrice())));

                if ( /*!rows[fila][2].equals(null) ||*/!rows[fila][2].toString().isEmpty()) {
                    rows[fila][3] = String.format("%.0f", Math.floor(capital / ticker.getCurrentPrice()));
                }
                //$$$ Bought

                Map misPosiciones = Controller.getSettings().getValorPosiciones();
                rows[fila][4] = 0;
                if (misPosiciones != null) {
                    Iterator iterator2 = misPosiciones.keySet().iterator();

                    while (iterator2.hasNext()) {
                        String key = iterator2.next().toString();
                        int value = (Integer) misPosiciones.get(key);

                        if (ticker.getName().equals(key)) {
                            rows[fila][4] = value;
                        }

                        System.out.println(key + " " + value);
                    }

                }

                //rows[fila][4] = ticker.getCurrentPrice();         
                try {
                    //if(rows[fila][3] != "" || rows[fila][4] != ""){
                    if (rows[fila][3] != null && !rows[fila][3].toString().isEmpty()) {
                        if (rows[fila][4] != null && !rows[fila][4].toString().isEmpty()) {

                            //tempStr = TableTicker.getModel().getValueAt(row, 3).toString().replace(",", ".");
                            // Remain
                            rows[fila][5] = Integer.parseInt(rows[fila][3].toString())
                                    - Integer.parseInt(rows[fila][4].toString());

                        } else {
                            rows[fila][5] = rows[fila][3];
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                //                                byte ptext[] = "&#1422".getBytes(ISO_8859_1); 
                //                                String value = new String(ptext, UTF_8); 
                //                                rows[fila][6] = value;

                //rows[fila][6] = "<>";

                rows[fila][7] = "O";

                String compradasDDBB = "0";
                String id_ticker = rows[fila][0].toString();
                String compradasString;

                compradasString = rows[fila][4] + "";

                rows[fila][8] = 1;
                // COMPRADAS HOY SI O NO
                DDBB.deleteComprasFecha(fechaHoy);
                ResultSet resCompras = DDBB.BuscarComprasFecha(id_ticker, fechaHoy);
                try {
                    if (resCompras.next()) {
                        rows[fila][8] = resCompras.getInt("compro");
                        tablaCopia.cambiarCopiaTabla(fila, 8, resCompras.getInt("compro"));
                        //JOptionPane.showMessageDialog(null,resCompras.getInt("compradas")+"", "", JOptionPane.ERROR_MESSAGE);
                        compradasDDBB = resCompras.getString("compradas");
                        if (!compradasDDBB.isEmpty() && !compradasString.isEmpty()) {
                            compradasOld = Integer.parseInt(compradasDDBB);
                            compradasHoy = Integer.parseInt(compradasString);
                            //JOptionPane.showMessageDialog(null,compradasOld+"", "", JOptionPane.ERROR_MESSAGE);
                            //
                            if (compradasHoy > compradasOld) {
                                //                                                JOptionPane.showMessageDialog(null,compradasOld+"-"+compradasHoy+"-"+resCompras.getInt("compro"), "", JOptionPane.ERROR_MESSAGE);
                                //ROJO

                                DDBB.deleteCompras(id_ticker);
                                DDBB.insertCompras(id_ticker, compradasString, fechaHoy, 0);
                                rows[fila][8] = 0;
                                tablaCopia.cambiarCopiaTabla(fila, 8, "0");
                                //  tablaCopia.cambiarNumerosComprar(fila, 0);

                            } else if (compradasHoy == compradasOld) {
                                DDBB.deleteCompras(id_ticker);
                                DDBB.insertCompras(id_ticker, compradasString, fechaHoy, 1);
                                rows[fila][8] = 1;
                                tablaCopia.cambiarCopiaTabla(fila, 8, "1");
                            }
                            //DDBB.insertCompras(id_ticker, compradasString, fechaHoy);
                        } else {

                        }
                    } else {
                        DDBB.insertCompras(id_ticker, compradasString, fechaHoy, 1);
                        rows[fila][8] = 1;
                        tablaCopia.cambiarCopiaTabla(fila, 8, "1");
                        //JOptionPane.showMessageDialog(null,"", "", JOptionPane.ERROR_MESSAGE);
                    }
                } catch (SQLException ex) {
                    Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex);
                }

                //System.out.println("INIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIITTTTT");
                Map misCierres = Controller.getSettings().getValorCierres();

                if (misCierres != null) {

                    try {
                        Double restaCierre = (Double) misCierres.get(ticker.getName())
                                - ticker.getCurrentPrice();
                        //System.out.println("RESTAAAA #################  " + restaCierre);
                        cuentaTickersValidos++;

                        cuentaTickersBaja = cuentaTickersBaja + (restaCierre > 0 ? 1 : 0);

                        //                                        System.out.println("TICKER " + ticker.getName() + " CIERRE " + misCierres.get(ticker.getName()) + " PRECIO: " + ticker.getCurrentPrice() );
                        //                                        System.out.println("#################### PROMEDIO " + ((1.00 * cuentaTickersBaja) / (1.00 * cuentaTickersValidos)) *100 + " VALIDOS " + cuentaTickersValidos + " BAJAS " + cuentaTickersBaja);
                    } catch (Exception e) {
                    }

                    //                                    Iterator iterator3 = misCierres.keySet().iterator();
                    //
                    //                                    while (iterator3.hasNext()) {
                    //                                        String key = iterator3.next().toString();
                    //                                        Double valueDouble =  (Double)misCierres.get(key);
                    //                                        
                    //
                    //                                        
                    //                                        System.out.println(key + " " + valueDouble);
                    //                                    }
                }

                //System.out.println("FIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIINN");
                fila++;
            }
        }
    }

    double promedioBajasTickers;

    promedioBajasTickers = ((1.00 * cuentaTickersBaja) / (1.00 * cuentaTickersValidos) * 100);

    String promedio = Double.toString(promedioBajasTickers);
    promedio = promedio.substring(0, promedio.indexOf(".") + 2);

    if (semaforo.Semaforo.isDebugMode) {
        System.out.println("#################### PROMEDIO " + promedioBajasTickers);
    }

    if (promedioBajasTickers < 50.0) {
        jLabelLuzPrincipal
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/verdep.png")));
        jLabelLuzPrincipal.setText(promedio + "%");
        //                        jLabelSemaphore.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/SemVERDE_HOR.png")));

    } else if (promedioBajasTickers < 70.0) {
        jLabelLuzPrincipal.setIcon(
                new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/amarillop.png")));
        jLabelLuzPrincipal.setText(promedio + "%");
        //                        jLabelSemaphore.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/SemAMARILLO_HOR.png")));

    } else {
        jLabelLuzPrincipal
                .setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/rojop.png")));
        jLabelLuzPrincipal.setText(promedio + "%");
        //                        jLabelSemaphore.setIcon(new javax.swing.ImageIcon(getClass().getResource("/semaforo/resources/SemROJO_HOR.png")));
    }

    // $$$ GENERACION DEL MODELO CON LA MEJORA DE NO EDICION DE LAS OTRAS COLUMNAS                    
    TableModel newModel = new DefaultTableModel(rows, columnsTitle) {
        boolean[] canEdit = new boolean[] { false, false, true, false, false, false, false, false };

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    };

    //$$$ RUTINA ESPECIAL PARA EL MANEJO DEL MODELO QUE SE BORRA Y LA EDICION DEL CAMPO CASH
    if (!TableTicker.isEditing()) {
        TableTicker.setModel(newModel);
        formateaCabeceroTicker();
    }

    int num = Math.min(settings.getTickers().size(), TableWeek1.getModel().getRowCount());
    int[] my_positions = new int[num];
    int[] my_positions_old = new int[500];

    rowsCopy doblePosiciones = new rowsCopy(0, 0, 2);
    my_positions_old = doblePosiciones.getPosiciones();
    doblePosiciones.setPosiciones(my_positions);

    for (int row = 0; row < num; row++) {

        if (map.get(TableTicker.getValueAt(row, 0)) != null) {
            List<Integer> listInt = map
                    .get(TableTicker.getValueAt(row, 0) /*settings.getTickers().get(row).getName()*/);

            my_positions[row] = -1;
            if (!listInt.isEmpty() && settings.getTickers().get(row).isHistory()) {
                //                    int col = ht.get(TableTicker.getValueAt(row, 0)).get(index) + 1;
                int col = map.get(TableTicker.getValueAt(row, 0)).get(0);
                my_positions[row] = col;
                if (my_positions_old.length > 0) {

                    String id_ticker = rows[row][0].toString();
                    //                                    JOptionPane.showMessageDialog(null, id_ticker+"");
                    //if(col == my_positions_old[row]){DDBB.deleteParpadeo(id_ticker);}
                    if (col < my_positions_old[row] && col <= 7) {
                        DDBB.insertParpadeo(id_ticker, 30);
                        try {
                            /*al hacer el ejecutable se debe cambiar a solo notificacion.mp3*/
                            //fis = new FileInputStream("C:\\Users\\maikolleon\\Documents\\NetBeansProjects\\s2m1f4r4\\src\\semaforo\\resources\\notificacion.mp3");
                            fis = new FileInputStream("notificacion.mp3");
                            bis = new BufferedInputStream(fis);
                            player = new Player(bis);
                            player.play();

                            //                                            fis2 = new FileInputStream("notificacion.mp3");
                            //                                            bis2 = new BufferedInputStream(fis2);
                            //                                            player2 = new Player(bis2);
                            //                                            player2.play();
                            //                                            
                            //                                            fis3 = new FileInputStream("notificacion.mp3");
                            //                                            bis3 = new BufferedInputStream(fis3);
                            //                                            player3 = new Player(bis3);
                            //                                            player3.play();

                        } catch (JavaLayerException ex) {
                            Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (FileNotFoundException ex) {
                            Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        hiloParpadeo(id_ticker, row, col);
                    }
                }
            }

        }

    }

    updateTableTickers();

    updateTableWeek(TableWeek1, settings.getVaribable("rango_1"), 17);
    loadTableCells(TableWeek1, WEEK1, map, 17);

    updateTableWeek(TableWeek2, settings.getVaribable("rango_2"), 17);
    loadTableCells(TableWeek2, WEEK2, map, 17);

    updateTableWeek(TableWeek3, settings.getVaribable("rango_3"), 17);
    loadTableCells(TableWeek3, WEEK3, map, 17);

    TableTicker.getColumnModel().getColumn(7).setMaxWidth(0);
    TableTicker.getColumnModel().getColumn(7).setMinWidth(0);
    TableTicker.getColumnModel().getColumn(7).setPreferredWidth(0);
    //                    TableTicker.getColumnModel().getColumn(6).setMaxWidth(0);
    //                    TableTicker.getColumnModel().getColumn(6).setMinWidth(0);
    //                    TableTicker.getColumnModel().getColumn(6).setPreferredWidth(0);

    //Redraw the window
    synchronized (updateLock) {
        update = 1;
    }

    validate();

    repaint();

}

From source file:net.sourceforge.pmd.cpd.GUI.java

private void populateResultArea() {
    int[] selectionIndices = resultsTable.getSelectedRows();
    TableModel model = resultsTable.getModel();
    List<Match> selections = new ArrayList<>(selectionIndices.length);
    for (int i = 0; i < selectionIndices.length; i++) {
        selections.add((Match) model.getValueAt(selectionIndices[i], 99));
    }//from  w  w  w.  j  a va  2  s  .  c o m
    String report = new SimpleRenderer(trimLeadingWhitespace).render(selections.iterator());
    resultsTextArea.setText(report);
    resultsTextArea.setCaretPosition(0); // move to the top
}

From source file:org.apache.metamodel.jdbc.JdbcDataContextTest.java

public void testUsingDataSource() throws Exception {
    Connection con = getTestDbConnection();
    DataSource ds = EasyMock.createMock(DataSource.class);

    CloseableConnectionWrapper con1 = new CloseableConnectionWrapper(con);
    CloseableConnectionWrapper con2 = new CloseableConnectionWrapper(con);
    CloseableConnectionWrapper con3 = new CloseableConnectionWrapper(con);
    CloseableConnectionWrapper con4 = new CloseableConnectionWrapper(con);
    CloseableConnectionWrapper con5 = new CloseableConnectionWrapper(con);

    assertFalse(con1.isClosed());//from   www .j  av  a  2 s  .  c  o  m
    assertFalse(con2.isClosed());
    assertFalse(con3.isClosed());
    assertFalse(con4.isClosed());
    assertFalse(con5.isClosed());

    EasyMock.expect(ds.getConnection()).andReturn(con1);
    EasyMock.expect(ds.getConnection()).andReturn(con2);
    EasyMock.expect(ds.getConnection()).andReturn(con3);
    EasyMock.expect(ds.getConnection()).andReturn(con4);
    EasyMock.expect(ds.getConnection()).andReturn(con5);

    EasyMock.replay(ds);

    JdbcDataContext dc = new JdbcDataContext(ds);
    dc.refreshSchemas();
    dc.refreshSchemas();

    Schema schema = dc.getDefaultSchema();
    Query q = new Query();
    q.from(schema.getTableByName("CUSTOMERS")).select(new SelectItem("COUNT(*)", null));
    DataSet data = dc.executeQuery(q);
    TableModel tableModel = new DataSetTableModel(data);
    assertEquals(1, tableModel.getRowCount());
    assertEquals(1, tableModel.getColumnCount());
    assertEquals(122, tableModel.getValueAt(0, 0));

    EasyMock.verify(ds);

    String assertionFailMsg = "Expected 5x true: " + con1.isClosed() + "," + con2.isClosed() + ","
            + con3.isClosed() + "," + con4.isClosed() + "," + con5.isClosed();

    assertTrue(assertionFailMsg, con1.isClosed());
    assertTrue(assertionFailMsg, con2.isClosed());
    assertTrue(assertionFailMsg, con3.isClosed());
    assertTrue(assertionFailMsg, con4.isClosed());
    assertTrue(assertionFailMsg, con5.isClosed());
}

From source file:org.apache.metamodel.jdbc.JdbcDataContextTest.java

public void testMaxRowsRewrite() throws Exception {
    JdbcDataContext dc = new JdbcDataContext(getTestDbConnection(), new TableType[] { TableType.TABLE }, null);
    IQueryRewriter rewriter = new DefaultQueryRewriter(dc) {
        @Override/*from  w  w  w  . j av  a  2s. c  om*/
        public String rewriteQuery(Query query) {
            return "SELECT COUNT(*) FROM PUBLIC.CUSTOMERS";
        }
    };
    dc = dc.setQueryRewriter(rewriter);
    TableModel tm = new DataSetTableModel(dc.executeQuery(new Query().selectCount()));
    assertEquals(1, tm.getRowCount());
    assertEquals(1, tm.getColumnCount());
    assertEquals("122", tm.getValueAt(0, 0).toString());
}

From source file:org.broad.igv.cbio.FilterGeneNetworkUI.java

/**
 * Export the current table to a tab-delimited file.
 * String exported should be the same as what user sees
 *
 * @param outFile/*from w  ww.  j a  v  a 2  s  .  co m*/
 * @throws IOException
 */
private void saveTable(File outFile) throws FileNotFoundException {
    PrintWriter writer = new PrintWriter(outFile);
    TableModel model = geneTable.getModel();
    String delimiter = "\t";

    //Write header
    String header = model.getColumnName(0);
    for (int col = 1; col < model.getColumnCount(); col++) {
        header += delimiter + model.getColumnName(col);
    }

    writer.println(header);

    for (int row = 0; row < model.getRowCount(); row++) {
        String rowStr = "" + model.getValueAt(row, 0);
        for (int col = 1; col < model.getColumnCount(); col++) {
            rowStr += delimiter + model.getValueAt(row, col);
        }

        writer.println(rowStr);
    }

    writer.flush();
    writer.close();
}