Example usage for javax.swing.table DefaultTableModel addRow

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

Introduction

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

Prototype

public void addRow(Object[] rowData) 

Source Link

Document

Adds a row to the end of the model.

Usage

From source file:grupob.TipoProceso.java

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

    ArrayList<Distrito> listaBuscada = new ArrayList<Distrito>();
    String busc = textDistrito.getText();
    if (busc.compareTo("") == 0) {
        listaBuscada = Manager.queryAllDistrito();
    } else {/*from w ww  .  j  av  a  2s  .  c o  m*/
        listaBuscada = Manager.queryByNameDistrito(busc);
    }
    DefaultTableModel modelo2 = (DefaultTableModel) jTableDistritos.getModel();
    modelo2.setRowCount(0);
    String datos[] = new String[3];
    for (int i = 0; i < listaBuscada.size(); i++) {
        datos[0] = listaBuscada.get(i).getNombre();
        if (listaBuscada.get(i).getCantidadVotantesRegistrados() == 0) {
            datos[1] = "";
        } else {
            datos[1] = Long.toString(listaBuscada.get(i).getCantidadVotantesRegistrados());
        }
        Distrito s = listaBuscada.get(i);
        String n = Manager.queryByIdRegion(s.getIdRegion()).getNombre();
        datos[2] = "" + n;
        modelo2.addRow(datos);
    }
    TableColumn colum1 = null;
    colum1 = jTableDistritos.getColumnModel().getColumn(0);
    colum1.setPreferredWidth(60);
    TableColumn colum2 = null;
    colum2 = jTableDistritos.getColumnModel().getColumn(1);
    colum2.setPreferredWidth(5);
    TableColumn colum3 = null;
    colum3 = jTableDistritos.getColumnModel().getColumn(2);
    colum3.setPreferredWidth(5);
    TableColumn colum4 = null;
    colum4 = jTableDistritos.getColumnModel().getColumn(3);
    colum4.setPreferredWidth(40);
    colum4.setPreferredWidth(10);
    listaDistritos = listaBuscada;
}

From source file:br.com.atmatech.sac.view.ViewAtendimento.java

private void consultaAjuda() {
    List<AtendimentoBeans> lab = new ArrayList<>();
    String sql = "";
    int count2 = 0;

    if (!jTajuda.getText().equals("")) {
        String[] sqlt = jTajuda.getText().split(" ");
        for (int i = 0; i < sqlt.length; i++) {
            if (!sqlt[i].equals("")) {
                //if (sql.equals("")) {
                sql = sql + " and solicitacao like('%" + sqlt[i] + "%') ";
                //}
            }//  w  ww.java2 s .c  o  m

        }
        if (!sql.equals("")) {
            sql = sql + "or(";
        }
        for (int i = 0; i < sqlt.length; i++) {
            if (!sqlt[i].equals("")) {
                if (count2 == 0) {
                    sql = sql + " realizado like('%" + sqlt[i] + "%') ";
                } else {
                    sql = sql + " and realizado like('%" + sqlt[i] + "%') ";
                }
                count2++;
            }

        }
        if (!sql.equals("")) {
            sql = sql + ")";
        }

    }
    lab = new AtendimentoDao().getAjuda(sql);
    if (lab != null) {
        DefaultTableModel tabel = (DefaultTableModel) jTbajuda.getModel();
        tabel.setNumRows(0);
        jTbajuda.setRowHeight(100);
        for (AtendimentoBeans lab1 : lab) {
            try {
                tabel.addRow(new Object[] { adcQuebraPagina(lab1.getSOLICITACAO()),
                        adcQuebraPagina(lab1.getREALIZADO()) });
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, "Erro \n" + ex);
            }
        }
    }
}

From source file:gtu._work.etc.EnglishTester.java

private void initGUI() {
    try {/*from  w ww  . j av a2s .  com*/
        JCommonUtil.defaultToolTipDelay();
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            jTabbedPane1.setPreferredSize(new java.awt.Dimension(462, 259));

            jTabbedPane1.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent evt) {
                    // XXX
                    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
                    jTabbedPane1.requestFocus();// FOCUS TODO
                    // XXX
                    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
                }
            });
            jTabbedPane1.addKeyListener(new KeyAdapter() {
                public void keyPressed(KeyEvent evt) {
                    System.out.println("2===" + evt.getKeyCode());
                    if (evt.getKeyCode() == 49) {// 0
                        jTabbedPane1.setSelectedIndex(0);
                    }
                    if (evt.getKeyCode() == 50) {// 1
                        jTabbedPane1.setSelectedIndex(1);
                    }
                    if (evt.getKeyCode() == 10) {// enter
                        skipBtnAction();
                    }
                    if (evt.getKeyCode() == 32) {// 
                        removeBtnAction();
                    }
                }
            });
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("english", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(420, 141));
                    {
                        englishArea = new JTextArea();
                        jScrollPane1.setViewportView(englishArea);
                        englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, 22));
                    }
                }
                {
                    jPanel5 = new JPanel();
                    jPanel1.add(jPanel5, BorderLayout.SOUTH);
                    jPanel5.setPreferredSize(new java.awt.Dimension(402, 65));
                    {
                        skipBtn = new JButton();
                        jPanel5.add(skipBtn);
                        skipBtn.setText("skip");
                        skipBtn.setPreferredSize(new java.awt.Dimension(187, 24));
                        skipBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                skipBtnAction();
                            }
                        });
                    }
                    {
                        removeBtn = new JButton();
                        jPanel5.add(removeBtn);
                        removeBtn.setText("remove");
                        removeBtn.setPreferredSize(new java.awt.Dimension(180, 24));
                        removeBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                removeBtnAction();
                            }
                        });
                    }
                    {
                        questionCountLabel = new JLabel();
                        jPanel5.add(questionCountLabel);
                        questionCountLabel.setPreferredSize(new java.awt.Dimension(47, 21));
                        questionCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
                        questionCountLabel.setToolTipText("");
                    }
                    {
                        propCountLabel = new JLabel();
                        jPanel5.add(propCountLabel);
                        propCountLabel.setPreferredSize(new java.awt.Dimension(45, 21));
                        propCountLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
                        propCountLabel.setToolTipText("");
                    }
                    {
                        googleSearchBtn = new JButton();
                        jPanel5.add(googleSearchBtn);
                        googleSearchBtn.setText("<html>GPic</html>");
                        googleSearchBtn.setPreferredSize(new java.awt.Dimension(58, 24));
                        googleSearchBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    String word = currentWordIndex.trim();
                                    ClipboardUtil.getInstance().setContents(word);
                                    word = word.replace(" ", "%20");
                                    URI uri = new URI(
                                            "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q="
                                                    + word);
                                    //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + word);
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        yahooDicBtn = new JButton();
                        jPanel5.add(yahooDicBtn);
                        yahooDicBtn.setText("<html>Dict</html>");
                        yahooDicBtn.setPreferredSize(new java.awt.Dimension(57, 24));
                        yahooDicBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    // URI uri = new
                                    // URI("http://tw.dictionary.yahoo.com/dictionary?p="
                                    // + currentWord.trim());
                                    URI uri = new URI("http://www.dreye.com/axis/ddict.jsp?ver=big5&dod=0102&w="
                                            + currentWordIndex.trim() + "&x=0&y=0");
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        pickBtn = new JButton();
                        jPanel5.add(pickBtn);
                        pickBtn.setText("<html>+Pick</html>");
                        pickBtn.setPreferredSize(new java.awt.Dimension(60, 24));
                        pickBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    String key = currentWordIndex;
                                    String value = englishProp.getProperty(currentWordIndex);
                                    if (StringUtils.isEmpty(value)) {
                                        JCommonUtil._jOptionPane_showMessageDialog_error(
                                                "add pick failed : no such word => " + key);
                                    } else {
                                        pickProp.setProperty(key, value);
                                        JCommonUtil._jOptionPane_showMessageDialog_info(
                                                "key=" + key + "\nvalue=" + value + "\nsize=" + pickProp.size(),
                                                "??");
                                    }
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        scanPicBtn = new JButton();
                        scanPicBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                            }
                        });
                        jPanel5.add(scanPicBtn);
                        scanPicBtn.setPreferredSize(new java.awt.Dimension(46, 24));
                        scanPicBtn.addMouseListener(new MouseAdapter() {

                            public void mouseClicked(MouseEvent evt) {
                                if (picDir == null) {
                                    JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null");
                                    return;
                                }

                                if (picSet != null && picSet.size() > 0) {
                                    try {
                                        Desktop.getDesktop().open(picSet.iterator().next());
                                    } catch (IOException e) {
                                        JCommonUtil.handleException(e);
                                    }
                                    return;
                                }

                                try {
                                    String text = currentWordIndex.trim().toLowerCase();
                                    ClipboardUtil.getInstance().setContents(text);
                                    text = text.replace(" ", "%20");
                                    URI uri = new URI(
                                            "https://www.google.com.tw/search?num=10&hl=zh-TW&site=imghp&tbm=isch&source=hp&biw=1280&bih=696&q="
                                                    + text);
                                    //URI uri = new URI("http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" + text);
                                    Desktop.getDesktop().browse(uri);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                    {
                        showChineseOption = new JCheckBox();
                        showChineseOption.setSelected(true);
                        jPanel5.add(showChineseOption);
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("chinese", null, jPanel2, null);
                jPanel2.setPreferredSize(new java.awt.Dimension(420, 211));
                {
                    showEnglishText = new JTextField();
                    jPanel2.add(showEnglishText, BorderLayout.NORTH);
                    showEnglishText.setEditable(false);
                }
                {
                    jPanel10 = new JPanel();
                    jPanel2.add(jPanel10, BorderLayout.CENTER);
                }
                {
                    answerBtn[0] = new JButton();
                    jPanel10.add(answerBtn[0]);
                    answerBtn[0].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[0].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[0]);
                        }
                    });
                }
                {
                    answerBtn[1] = new JButton();
                    jPanel10.add(answerBtn[1]);
                    answerBtn[1].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[1].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[1]);
                        }
                    });
                }
                {
                    answerBtn[2] = new JButton();
                    jPanel10.add(answerBtn[2]);
                    answerBtn[2].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[2].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[2]);
                        }
                    });
                }
                {
                    answerBtn[3] = new JButton();
                    jPanel10.add(answerBtn[3]);
                    answerBtn[3].setPreferredSize(new java.awt.Dimension(190, 110));
                    answerBtn[3].addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            answerBtnClick(answerBtn[3]);
                        }
                    });
                }
                {
                    for (int ii = 0; ii < 4; ii++) {
                        answerBtn[ii].setFont(new java.awt.Font("", 0, 14));
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jTabbedPane1.addTab("word", null, jPanel3, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel3.add(jScrollPane3, BorderLayout.CENTER);
                    jScrollPane3.setPreferredSize(new java.awt.Dimension(420, 187));
                    {
                        propTable = new JTable();
                        jScrollPane3.setViewportView(propTable);
                        JTableUtil.defaultSetting(propTable);
                        propTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JPopupMenuUtil.newInstance(propTable)
                                        .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems())
                                        .applyEvent(evt).show();
                            }
                        });
                    }
                }
                {
                    saveBtn = new JButton();
                    jPanel3.add(saveBtn, BorderLayout.SOUTH);
                    saveBtn.setText("save table");
                    saveBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            DefaultTableModel model = JTableUtil.newInstance(propTable).getModel();
                            for (int ii = 0; ii < model.getRowCount(); ii++) {
                                String key = (String) model.getValueAt(ii, 0);
                                String value = (String) model.getValueAt(ii, 1);
                                if (!englishProp.containsKey(key)) {
                                    englishProp.setProperty(key, value);
                                }
                            }
                            try {
                                englishProp.store(new FileOutputStream(englishFile), "comment");
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            JCommonUtil._jOptionPane_showMessageDialog_info("save file ok!  \n" + englishFile);
                        }
                    });
                }
                {
                    queryText = new JTextField();
                    jPanel3.add(queryText, BorderLayout.NORTH);
                    queryText.getDocument()
                            .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                @Override
                                public void process(DocumentEvent event) {
                                    String text = JCommonUtil.getDocumentText(event);
                                    Pattern pattern = Pattern.compile(text);
                                    Matcher matcher = null;
                                    DefaultTableModel propTableModel = JTableUtil.createModel(false, "english",
                                            "chinese");
                                    for (Enumeration<?> enu = englishProp.propertyNames(); enu
                                            .hasMoreElements();) {
                                        String key = (String) enu.nextElement();
                                        String value = englishProp.getProperty(key);
                                        if (key.contains(text)) {
                                            propTableModel.addRow(new Object[] { key, value });
                                            continue;
                                        }
                                        matcher = pattern.matcher(key);
                                        if (matcher.find()) {
                                            propTableModel.addRow(new Object[] { key, value });
                                            continue;
                                        }
                                    }
                                    propTable.setModel(propTableModel);
                                }
                            }));
                }
            }
            {
                jPanel4 = new JPanel();
                jTabbedPane1.addTab("config", null, jPanel4, null);
                {
                    savePickBtn = new JButton();
                    jPanel4.add(savePickBtn);
                    savePickBtn.setText("save pick");
                    savePickBtn.setPreferredSize(new java.awt.Dimension(116, 40));
                    savePickBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            if (englishFile == null) {
                                File file = new File(//
                                        PropertiesUtil.getJarCurrentPath(EnglishTester.class),
                                        "temp.properties");
                                englishFile = file;
                            }
                            if (pickProp.isEmpty()) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("?!");
                                return;
                            }
                            String fileName = englishFile.getName().replaceAll("\\.properties",
                                    "_bak.properties");
                            File jarWhereFile = PropertiesUtil.getJarCurrentPath(EnglishTester.class);
                            fileName = JCommonUtil._jOptionPane_showInputDialog("save target properties",
                                    fileName);
                            if (StringUtils.isEmpty(fileName)) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("can't save!");
                                return;
                            }
                            if (fileName.equalsIgnoreCase(englishFile.getName())) {
                                JCommonUtil._jOptionPane_showMessageDialog_error(
                                        "??englishFile???");
                                return;
                            }
                            if (!fileName.endsWith(".properties")) {
                                fileName += ".properties";
                            }
                            File newFile = new File(jarWhereFile, fileName);
                            Properties oldProp = new Properties();
                            if (newFile.exists()) {
                                try {
                                    oldProp.load(new FileInputStream(newFile));
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            oldProp.putAll(pickProp);
                            try {
                                oldProp.store(new FileOutputStream(newFile), "comment");
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            JCommonUtil._jOptionPane_showMessageDialog_info("save file ok!  \n" + newFile);
                        }
                    });
                }
                {
                    saveConfigBtn2 = new JButton();
                    jPanel4.add(saveConfigBtn2);
                    saveConfigBtn2.setText("save config");
                    saveConfigBtn2.setPreferredSize(new java.awt.Dimension(108, 40));
                    saveConfigBtn2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            saveConfigBtnAction();
                        }
                    });
                }
                {
                    startAllBtn = new JButton();
                    jPanel4.add(startAllBtn);
                    startAllBtn.setText("start all");
                    startAllBtn.setPreferredSize(new java.awt.Dimension(101, 40));
                    startAllBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            Object[] files = fileList.getSelectedValues();
                            if (files == null || files.length == 0) {
                                JCommonUtil
                                        ._jOptionPane_showMessageDialog_error("?properties");
                                return;
                            }
                            Properties allProp = new Properties();
                            Properties prop = new Properties();
                            for (Object ff : files) {
                                try {
                                    prop.load(new FileInputStream((File) ff));
                                } catch (Exception e) {
                                    JCommonUtil.handleException(e);
                                }
                                allProp.putAll(prop);
                            }
                            englishProp = allProp;
                            System.out.println("englishProp = " + englishProp.size());
                            startNow();
                        }
                    });
                }
                {
                    startNow = new JButton();
                    jPanel4.add(startNow);
                    startNow.setText("start now");
                    startNow.setPreferredSize(new java.awt.Dimension(101, 40));

                    startNow.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            startNow();
                        }
                    });
                }
                {
                    picOnly = new JCheckBox();
                    jPanel4.add(picOnly);
                    picOnly.setText("picOnly");
                }
                {
                    sortChkBox = new JCheckBox();
                    jPanel4.add(sortChkBox);
                    sortChkBox.setText("sort");
                }
                {
                    showPicChkBox = new JCheckBox();
                    showPicChkBox.setSelected(true);
                    jPanel4.add(showPicChkBox);
                    showPicChkBox.setText("showPic");
                }
                {
                    JCommonUtil.defaultToolTipDelay();
                    fontSizeSliber = new JSlider(JSlider.HORIZONTAL);
                    jPanel4.add(fontSizeSliber);
                    fontSizeSliber.setPreferredSize(new java.awt.Dimension(419, 35));
                    fontSizeSliber.setValue(22);
                    fontSizeSliber.setMinimum(22);
                    fontSizeSliber.setMaximum(300);
                    fontSizeSliber.setMajorTickSpacing(30);
                    fontSizeSliber.setMinorTickSpacing(5);
                    fontSizeSliber.setCursor(new Cursor(Cursor.HAND_CURSOR));
                    fontSizeSliber.setPaintTicks(false);
                    fontSizeSliber.setPaintLabels(true);
                    {
                        picFolderDirText = new JTextField();
                        JCommonUtil.jTextFieldSetFilePathMouseEvent(picFolderDirText, true);
                        jPanel4.add(picFolderDirText);
                        picFolderDirText.setColumns(20);
                    }
                    fontSizeSliber.addChangeListener(new ChangeListener() {
                        @Override
                        public void stateChanged(ChangeEvent e) {
                            int size = fontSizeSliber.getValue();
                            fontSizeSliber.setToolTipText("" + size);
                            englishArea.setFont(new java.awt.Font("Microsoft JhengHei", 0, size));
                        }
                    });

                }
            }
            {
                jPanel6 = new JPanel();
                jTabbedPane1.addTab("files", null, jPanel6, null);
                BorderLayout jPanel6Layout = new BorderLayout();
                jPanel6.setLayout(jPanel6Layout);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel6.add(jScrollPane4, BorderLayout.CENTER);
                    jScrollPane4.setPreferredSize(new java.awt.Dimension(420, 211));
                    {
                        fileList = new JList();
                        reloadFileList();
                        jScrollPane4.setViewportView(fileList);
                        fileList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                final File file = JListUtil.getLeadSelectionObject(fileList);
                                if (JMouseEventUtil.buttonRightClick(1, evt)) {
                                    JPopupMenuUtil.newInstance(EnglishTester.this.fileList).applyEvent(evt)//
                                            .addJMenuItem("reload", new ActionListener() {
                                                @Override
                                                public void actionPerformed(ActionEvent e) {
                                                    reloadFileList();
                                                }
                                            })//
                                            .addJMenuItem("delete : " + file.getName(), new ActionListener() {
                                                @Override
                                                public void actionPerformed(ActionEvent e) {
                                                    boolean result = JCommonUtil
                                                            ._JOptionPane_showConfirmDialog_yesNoOption(
                                                                    "delete : " + file.getName() + " ?",
                                                                    "confirm");
                                                    if (result) {
                                                        file.delete();
                                                        reloadFileList();
                                                    }
                                                }//
                                            }).show();
                                    return;
                                }
                                if (evt.getClickCount() == 1) {
                                    return;
                                }
                                if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                        "?,?\n" + file.getName(),
                                        "")) {
                                    loadEnglishFile(file);
                                }
                            }
                        });
                        fileList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                JListUtil.newInstance(fileList).defaultJListKeyPressed(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel9 = new JPanel();
                jTabbedPane1.addTab("pic", null, jPanel9, null);
                {
                    picCheckText = new JTextField();
                    jPanel9.add(picCheckText);
                    picCheckText.setPreferredSize(new java.awt.Dimension(177, 39));
                }
                {
                    picCheckBtn = new JButton();
                    jPanel9.add(picCheckBtn);
                    picCheckBtn.setText("check");
                    picCheckBtn.setPreferredSize(new java.awt.Dimension(98, 43));
                    {
                        jPanel11 = new JPanel();
                        jTabbedPane1.addTab("", null, jPanel11, null);
                        jPanel11.setLayout(new BorderLayout(0, 0));
                        {
                            inputTestArea2 = new JTextArea();
                            inputTestArea2.setFont(new Font("", Font.PLAIN, 12));
                            inputTestArea2.addKeyListener(new KeyAdapter() {
                                @Override
                                public void keyReleased(KeyEvent e) {
                                    inputTestTrainer.keyin(e);
                                }
                            });
                            jPanel11.add(inputTestArea2, BorderLayout.SOUTH);
                        }
                        {
                            inputTestArea1 = new JTextArea();
                            JTextAreaUtil.setWrapTextArea(inputTestArea1);
                            inputTestArea1.setFont(new Font("", Font.PLAIN, 22));
                            jPanel11.add(inputTestArea1, BorderLayout.CENTER);
                        }
                        {
                            panel = new JPanel();
                            jPanel11.add(panel, BorderLayout.NORTH);
                            {
                                inputTestLabel = new JLabel("");
                                panel.add(inputTestLabel);
                            }
                            {
                                inputTestChk = new JCheckBox("");
                                inputTestChk.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent e) {
                                        inputTestTrainer.initQuestion();
                                    }
                                });
                                panel.add(inputTestChk);
                            }
                        }
                    }
                    picCheckBtn.addActionListener(new ActionListener() {
                        void scanPic(String searchWord, File file, Set<File> findFile) {
                            if (file.isDirectory()) {
                                File[] list = null;
                                if ((list = file.listFiles()) != null) {
                                    for (File f : list) {
                                        scanPic(searchWord, f, findFile);
                                    }
                                }
                            } else {
                                String text = searchWord;
                                String name = file.getName().toLowerCase();
                                if (isMatch(name, text)) {
                                    findFile.add(file);
                                }
                            }
                        }

                        public void actionPerformed(ActionEvent evt) {
                            picDir = new File(picFolderDirText.getText());
                            if (picDir == null) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("picDir is null");
                                return;
                            }
                            if (!picDir.exists() || !picDir.isDirectory()) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("picDir ");
                                return;
                            }

                            picCheckBtn.setText("search..");

                            String searchWord = picCheckText.getText().toLowerCase().trim();

                            Set<File> picSet2 = new HashSet<File>();
                            scanPic(searchWord, picDir, picSet2);

                            if (picSet2 != null && picSet2.size() > 0) {
                                picCheckBtn.setText("" + picSet2.size());

                                try {
                                    Desktop.getDesktop().open(picSet2.iterator().next());
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                }
                            } else {
                                picCheckBtn.setText("0");
                            }
                        }
                    });
                }
            }
        }

        JCommonUtil.setJFrameIcon(this, "resource/images/ico/english_tester.ico");

        pack();
        this.setSize(423, 314);

        configHelper.init();
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}

From source file:grupob.TipoProceso.java

private void btnBuscarInstitucionalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarInstitucionalActionPerformed
    // TODO add your handling code here:
    // TODO add your handling code here:
    if (!txtNombreInstitucional.getText().isEmpty()) {
        listaInstituciones.clear();//  w w w  .  j  a v  a2  s .c  om
        listaInstituciones = Manager.queryByNameInstitucion(txtNombreInstitucional.getText());

        DefaultTableModel modelo = (DefaultTableModel) tblInstitucional.getModel();
        tblInstitucional.getColumn("Eliminar").setCellRenderer(new ButtonRenderer());
        modelo.setRowCount(0);
        String datos[] = new String[4];

        for (int i = 0; i < listaInstituciones.size(); i++) {
            datos[0] = listaInstituciones.get(i).getNombre();
            if (listaInstituciones.get(i).getCantidadVotantesRegistrados() == 0) {
                datos[1] = "0";
            } else {
                datos[1] = Integer.toString(listaInstituciones.get(i).getCantidadVotantesRegistrados());
            }
            String n = Manager.queryLocalById(listaInstituciones.get(i).getIdLocal()).getNombre();
            datos[2] = "" + n;
            datos[3] = "ELIMINAR";
            modelo.addRow(datos);
        }

    } else
        JOptionPane.showMessageDialog(null, "El campo buscar no puede estar vacio");

}

From source file:userInterface.HospitalAdminRole.ManagePatientsJPanel.java

public void populateTable(Person person) {
    DefaultTableModel model = (DefaultTableModel) vitalSignjTable.getModel();
    TableColumnModel tcm = vitalSignjTable.getColumnModel();
    CustomTableCellRenderer customCellRenderer = new CustomTableCellRenderer();
    model.setRowCount(0);/*  w  w w.  j  a v a  2  s. c o m*/
    //if(houseOrg.getPersonDir().getPersonDir()!=null){
    //for(Person person:houseOrg.getPersonDir().getPersonDir()){
    if (person.getMemberDir().getMemberDirectory() != null) {
        for (Member member : person.getMemberDir().getMemberDirectory()) {
            int patientAge = member.getAge();
            if (member.getVitalSignList().getVitalSignList() != null) {
                for (VitalSign vs : member.getVitalSignList().getVitalSignList()) {
                    Object[] row = new Object[8];
                    //            vitalSignjTable.getColumnModel().getColumn(7).setMinWidth(0);
                    //            vitalSignjTable.getColumnModel().getColumn(7).setMaxWidth(0);
                    //            vitalSignjTable.getColumnModel().getColumn(7).setWidth(0);
                    row[0] = member;
                    row[1] = vs;
                    row[2] = vs.getRespiratoryRate();
                    row[3] = vs.getHeartRate();
                    row[4] = vs.getBloodPressure();
                    row[5] = vs.getTemperature();
                    row[6] = member.getVitalSignList().VitalSignStatus(patientAge, vs);
                    row[7] = vs.getAlertStatus();
                    model.addRow(row);
                    tcm.getColumn(6).setCellRenderer(customCellRenderer);
                }
            }
        }
    }
}

From source file:GUI.MainWindow.java

public void addAffectedHost() {

    System.out.println("==addAffectedHost");

    DefaultMutableTreeNode node = (DefaultMutableTreeNode) this.VulnTree.getLastSelectedPathComponent();
    if (node == null) {
        return;/*from  w w  w  .  j a  v a  2s.  c  om*/
    }

    Vulnerability vuln = (Vulnerability) node.getUserObject();
    //ManageAffectedHosts.setVisible(true) ;

    // Old way of doing it
    JTextField ip_address = new JTextField();
    JTextField hostname = new JTextField();
    JTextField port_number = new JTextField();
    port_number.setText("0");
    JTextField protocol = new JTextField();
    protocol.setText("tcp");

    Object[] message = { "IP Address:", ip_address, "Hostname:", hostname, "Port Number:", port_number,
            "Protocol:", protocol };

    String new_ip = null;
    String new_hostname = null;
    String new_port_number = null;
    String new_protocol = null;

    while (new_ip == null || new_hostname == null || new_port_number == null || new_protocol == null) {
        int option = JOptionPane.showConfirmDialog(null, message, "Add affected host",
                JOptionPane.OK_CANCEL_OPTION);
        if (option == JOptionPane.OK_OPTION) {

            new_ip = ip_address.getText();
            new_hostname = hostname.getText();
            new_port_number = port_number.getText();
            new_protocol = protocol.getText();
            Host host = new Host();
            host.setIp_address(new_ip);
            host.setHostname(new_hostname);
            host.setPortnumber(new_port_number);
            host.setProtocol(new_protocol);
            vuln.addAffectedHost(host);
            DefaultTableModel dtm = (DefaultTableModel) this.VulnAffectedHostsTable.getModel();
            dtm.addRow(host.getAsVector());
            dtm.fireTableDataChanged();

        } else {
            return; // End the infinite loop
        }

    }

}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowserAdvancedFilter.java

public void loadSelections() {
    DefaultTableModel contentSearchModel = ((DefaultTableModel) contentSearchTable.getModel());
    DefaultTableModel metaDataSearchModel = ((DefaultTableModel) metaDataSearchTable.getModel());
    ItemSelectionTableModel<Integer, String> connectorModel = ((ItemSelectionTableModel<Integer, String>) connectorTable
            .getModel());//  w  w w. j  a v a 2s  .  co  m
    messageIdLowerField.setText((String) cachedSettings.get("messageIdLowerField"));
    messageIdUpperField.setText((String) cachedSettings.get("messageIdUpperField"));
    originalIdLowerField.setText((String) cachedSettings.get("originalIdLowerField"));
    originalIdUpperField.setText((String) cachedSettings.get("originalIdUpperField"));
    importIdLowerField.setText((String) cachedSettings.get("importIdLowerField"));
    importIdUpperField.setText((String) cachedSettings.get("importIdUpperField"));
    serverIdField.setText((String) cachedSettings.get("serverIdField"));
    sendAttemptsLower.setValue(cachedSettings.get("sendAttemptsLower"));
    sendAttemptsUpper.setValue(cachedSettings.get("sendAttemptsUpper"));
    attachmentCheckBox.setSelected((Boolean) cachedSettings.get("attachment"));
    errorCheckBox.setSelected((Boolean) cachedSettings.get("error"));

    contentSearchModel.setNumRows(0);
    Object[][] contentSearchData = (Object[][]) cachedSettings.get("contentSearchTable");
    for (int row = 0; row < contentSearchData.length; row++) {
        contentSearchModel.addRow(contentSearchData[row]);
    }

    metaDataSearchModel.setNumRows(0);
    Object[][] metaDataSearchData = (Object[][]) cachedSettings.get("metaDataSearchTable");
    for (int row = 0; row < metaDataSearchData.length; row++) {
        metaDataSearchModel.addRow(metaDataSearchData[row]);
    }

    Boolean[] connectorData = (Boolean[]) cachedSettings.get("connectorTable");
    for (int row = 0; row < connectorModel.getRowCount(); row++) {
        connectorModel.setValueAt(connectorData[row], row, ItemSelectionTableModel.CHECKBOX_COLUMN);
    }

    cachedSettings.clear();
}

From source file:de.tor.tribes.ui.views.DSWorkbenchReTimerFrame.java

private void buildResults(Hashtable<Village, Date> pTimings, Village pTarget, UnitHolder pUnit) {
    DefaultTableModel resultModel = new javax.swing.table.DefaultTableModel(new Object[][] {},
            new String[] { "Herkunft", "Einheit", "Ziel", "Startzeit" }) {

        Class[] types = new Class[] { Village.class, UnitHolder.class, Village.class, Date.class };

        @Override/* w w  w.  j av a 2s . c o  m*/
        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }

        @Override
        public boolean isCellEditable(int row, int col) {
            return false;
        }
    };
    jResultTable.setModel(resultModel);
    jResultTable.setRowHeight(20);
    jResultTable.setHighlighters(
            HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jResultTable.setDefaultRenderer(UnitHolder.class, new UnitCellRenderer());
    jResultTable.setDefaultRenderer(Date.class, new DateCellRenderer());
    jResultTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());

    if (pTimings == null || pTarget == null || pUnit == null) {
        return;
    }

    Enumeration<Village> keys = pTimings.keys();
    while (keys.hasMoreElements()) {
        Village key = keys.nextElement();
        resultModel.addRow(new Object[] { key, pUnit, pTarget, pTimings.get(key) });
    }

    jideRetimeTabbedPane.setSelectedIndex(1);
}

From source file:com.SE.myPlayer.MusicPlayerGUI.java

public void tableReferesh(JTable songData_Table, String tableName, String columName) {
        int emptyResultSet = 0;

        try {//from  ww w . j a  v  a 2 s . c o m
            con = db.getCon();
            stmt = con.createStatement();
            ResultSet rs;

            switch (tableName) {
            case "library":
                rs = stmt.executeQuery("select * from library order by " + columName + "");
                break;
            case "playlist":
                rs = stmt.executeQuery("select * from library order by " + columName + "");
                break;
            default:
                rs = stmt.executeQuery(
                        "Select library.id_songs, library.song_location, library.song_name, library.song_album, library.song_artist, library.genre, library.year, library.time, library.comment from playlist INNER JOIN library ON library.id_songs = playlist.id_songs AND playlist.playlist_name = '"
                                + tableName + "' order by " + columName + "");
                break;
            }

            DefaultTableModel myModel = new DefaultTableModel() {

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

            String[] songsColumnsName = { "Location", "Name", "Album", "Artist", "Genre", "Year", "Time",
                    "Comment" };
            myModel.setColumnIdentifiers(songsColumnsName);

            ResultSetMetaData rsmd = rs.getMetaData();
            int colNumbers = rsmd.getColumnCount();

            Object[] objects = new Object[colNumbers];

            while (rs.next()) {
                emptyResultSet = 1;
                for (int i = 0; i < colNumbers - 1; i++) {
                    objects[i] = rs.getObject(i + 2);
                }
                myModel.addRow(objects);
            }

            if (emptyResultSet == 0) {
                myModel.addRow(objects);
            }

            songData_Table.setModel(myModel);

            rs = stmt.executeQuery("select col_name from col_name where col_status = 0");

            while (rs.next()) {
                songData_Table.removeColumn(songData_Table.getColumn(rs.getString(1)));
            }

            songData_Table.getTableHeader().removeMouseListener(ma);
            songData_Table.getTableHeader().addMouseListener(ma);
            songData_Table.setDragEnabled(true);
            songData_Table.setDropTarget(new DropTarget() {
                @Override
                public synchronized void drop(DropTargetDropEvent dtde) {

                    dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
                    Transferable t = dtde.getTransferable();

                    try {
                        if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                            Object fileList = t.getTransferData(DataFlavor.javaFileListFlavor);
                            String files = fileList.toString();
                            finalString = convertFileString(files);
                            if (dropControl == 0 && lastOpen.equals("library")) {
                                songAddDB(finalString);
                            } else if (dropControl == 0 && !lastOpen.equals("library")) {
                                songAddPlaylistFromLibrary(lastOpen, finalString);
                                getSongTable(lastOpen);
                            } else {
                                songAddPlaylistFromLibrary(tableName, finalString);
                            }
                        } else if (dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                            Object fileList = t.getTransferData(DataFlavor.stringFlavor);
                            String fileListString = fileList.toString();

                            fileListString = Arrays.toString(fileListString.split("\\n"));

                            String[] splitLocations = fileListString.split(",\\s");

                            for (int i = 0; i < splitLocations.length; i++) {
                                if (i == 0) {
                                    splitLocations[i] = splitLocations[i].substring(1,
                                            splitLocations[i].indexOf(".mp3") + 4);
                                } else {
                                    splitLocations[i] = splitLocations[i].substring(0,
                                            splitLocations[i].indexOf(".mp3") + 4);
                                }
                            }

                            for (int i = 0; i < splitLocations.length; i++) {
                                splitLocations[i] = sd.getLocations(splitLocations[i]);
                            }
                            finalString = Arrays.asList(splitLocations);
                            if (dropControl == 0 && lastOpen.equals("library")) {
                                songAddDB(finalString);
                            } else if (dropControl == 0 && !lastOpen.equals("library")) {
                                songAddPlaylistFromLibrary(lastOpen, finalString);
                                getSongTable(lastOpen);
                            } else {
                                songAddPlaylistFromLibrary(tableName, finalString);
                            }
                        }
                    } catch (UnsupportedFlavorException | IOException | InvalidDataException
                            | UnsupportedTagException ex) {
                        System.out.println("Error in second drop flavour............" + ex);
                    }
                }
            });

            if (con != null) {
                stmt.close();
                con.close();
            }
        } catch (SQLException e) {
            System.out.println("Error in Stmt " + e);
        }
    }

From source file:hw.java

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

    //        ResultSet rs1;
    //         //from  w  w w .  j  a  v  a  2s  .  c  o  m
    //        try {
    MongoCollection<Document> coll = db.getCollection("business");
    //MongoCollection<Document> catcollection = db.getCollection("catout");
    MongoCollection<Document> rcoll = db.getCollection("review");
    //final DBCollection collection = db.getCollection("review");
    MongoCollection<Document> ccoll = db.getCollection("checkin");
    String from_dropdown = jComboBox3.getSelectedItem().toString();
    String to_dropdown = jComboBox6.getSelectedItem().toString();

    String from_value = jTextField9.getText();
    String to_value = jTextField10.getText();
    String check_count_value = jTextField11.getText();

    String check_count_dropdown = jComboBox8.getSelectedItem().toString();
    String fromdate_value = jTextField1.getText();
    String todate_value = jTextField3.getText();
    String stars_value = jTextField12.getText();
    String votes_value = jTextField13.getText();
    String stars_dropdown = jComboBox4.getSelectedItem().toString();
    String votes_dropdown = jComboBox12.getSelectedItem().toString();
    String select = jComboBox1.getSelectedItem().toString();
    List<String> category_value = jList2.getSelectedValuesList();
    String poi = jComboBox5.getSelectedItem().toString();
    String proximity = jComboBox2.getSelectedItem().toString();
    BasicDBObject qryBusiness = new BasicDBObject();
    BasicDBObject qryReview = new BasicDBObject();
    BasicDBList BusinessList = new BasicDBList();
    BasicDBList ReviewList = new BasicDBList();
    FindIterable<Document> cursor;
    FindIterable<Document> cursor1;
    List<String> catout = new ArrayList<String>();
    List<String> proout = new ArrayList<String>();
    List<String> checkinout = new ArrayList<String>();
    List<String> reviewout = new ArrayList<String>();
    List<String> finalout = new ArrayList<String>();

    if (category_value.isEmpty())//&& poi == null && proximity == null && from_value == null && fromdate_value == null)
    {
        BasicDBObject nu = new BasicDBObject();
        FindIterable<Document> fi;
        fi = coll.find(nu);
        jTextField8.setText("db.business.find()");
        String Columnames[] = { "business_id", "state", "city", "stars" };
        DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
        dtm.setColumnCount(0);
        dtm.setRowCount(0);
        int numberOfColumns = Columnames.length;

        for (int i = 0; i < numberOfColumns; i++) {
            String name = Columnames[i];
            dtm.addColumn(name);

        }

        fi.forEach(new Block<Document>() {
            @Override
            public void apply(final Document document) {

                Object rowData[] = new Object[numberOfColumns];

                rowData[0] = document.get("business_id");
                rowData[1] = document.get("state");
                rowData[2] = document.get("city");
                rowData[3] = document.get("stars");

                dtm.addRow(rowData);
                rowData = null;
            }
        });

        jTable1.setRowSelectionAllowed(true);
        jTable1.setModel(dtm);

        jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        dtm.fireTableDataChanged();

    } else {

        Object[] l = jList2.getSelectedValues();
        //BasicDBList subcat = new BasicDBList();
        BasicDBList clist = new BasicDBList();
        BasicDBObject qrycategory;
        if (l.length > 0) {
            for (int i = 0; i < l.length; i++) {
                BasicDBObject buinessop = new BasicDBObject("categories", l[i]);
                clist.add(buinessop);
            }
        }
        qrycategory = new BasicDBObject("$or", clist);
        //               subcatquery = new BasicDBObject("$out","subcat");
        //               subcat.add(qrycategory);
        //               subcat.add(subcatquery);
        //               System.out.println(subcat);
        cursor = coll.find(qrycategory);

        System.out.println(qrycategory);
        //BasicDBObject category = new BasicDBObject();
        cursor.forEach(new Block<Document>() {
            @Override
            public void apply(final Document document) {

                System.out.println(document.get("business_id"));
                //category.put((String)document.get("business_id"), db);

                catout.add((String) document.get("business_id"));
                //                                System.out.println(document.get("state"));
                //                                System.out.println(document.get("city"));
                //                                System.out.println(document.get("stars"));
                //                               

            }
        });

        MongoCollection<Document> collecttest = db.getCollection("test");
        String[] addresses5 = { "", "4840 E Indian School Rd\\nSte 101\\nPhoenix, AZ 85018",
                "631 S Main St\\nDe Forest, WI 53532", "5813 Main St\\nMc Farland, WI 53558",
                "2039 Allen Blvd\\nMiddleton, WI 53562", "6230 University Ave\\nMiddleton, WI 53562" };
        String[][] latLong = { { "33.499313000000001", "-111.98375799999999" },
                { "43.2408748", "-89.343721700000003" }, { "43.014164000000001", "-89.288567" },
                { "43.090642000000003", "-89.485168999999999" }, { "43.0910607", "-89.487486700000005" } };

        BasicDBObject queryBusiness = new BasicDBObject();
        BasicDBList businessinputlist = new BasicDBList();

        String selectedAddress = jComboBox5.getSelectedItem().toString();
        String selectedProximity = jComboBox2.getSelectedItem().toString();
        Double pro = Double.parseDouble(selectedProximity) / 3963.2;
        int index = Arrays.asList(addresses5).indexOf(selectedAddress);
        Double Latitude = Double.parseDouble(latLong[index][0]);
        Double Longitude = Double.parseDouble(latLong[index][1]);
        System.out.println("lat" + Latitude);
        System.out.println("longi" + Longitude);
        //BasicDBObject lat = new BasicDBObject(Latitude.toString(),Longitude);
        BasicDBList c1 = new BasicDBList();
        BasicDBList cs = new BasicDBList();
        cs.add(Latitude);
        cs.add(Longitude);
        c1.add(cs);
        c1.add(pro);
        BasicDBObject c = new BasicDBObject("$centerSphere", c1);
        BasicDBObject bq = new BasicDBObject("loc", new BasicDBObject("$geoWithin", c));
        FindIterable<Document> fi;
        fi = collecttest.find(bq);
        System.out.println(bq);
        jTextField8.setText("db.test.find(" + bq + ")");
        fi.forEach(new Block<Document>() {
            @Override
            public void apply(final Document document) {

                System.out.println(document.get("business_id"));

                proout.add((String) document.get("business_id"));

                //System.out.println(document.get("loc"));
            }
        });
        int checkinempty = 0;
        if (from_value == null || to_value == null || check_count_value.equals("0")) {
            checkinempty = 1;
            List<String> pr = new ArrayList<String>(catout);
            System.out.println(pr.size());
            pr.retainAll(proout);
            System.out.println(pr.size());
            String Columnames[] = { "Business_id", "state", "city", "stars" };
            DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
            dtm.setColumnCount(0);
            dtm.setRowCount(0);
            int numberOfColumns = Columnames.length;
            Object rowData[] = new Object[numberOfColumns];

            for (int i = 0; i < numberOfColumns; i++) {
                String name = Columnames[i];
                dtm.addColumn(name);

            }
            for (int i = 0; i < pr.size(); i++) {

                rowData[0] = pr.get(i);
                BasicDBObject c11 = new BasicDBObject("business_id", pr.get(i));
                FindIterable<Document> f1;
                f1 = coll.find(c11);
                f1.forEach(new Block<Document>() {
                    @Override
                    public void apply(final Document document) {

                        Object rowData[] = new Object[numberOfColumns];
                        rowData[0] = document.get("business_id");
                        rowData[1] = document.get("state");
                        rowData[2] = document.get("city");
                        rowData[3] = document.get("stars");
                        dtm.addRow(rowData);
                        rowData = null;

                    }
                });

                //                                
                //                                
                //                              

            }

            jTable1.setRowSelectionAllowed(true);
            jTable1.setModel(dtm);

            jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            dtm.fireTableDataChanged();

        }
        if (checkinempty != 1) {

            BasicDBList checkinputlist = new BasicDBList();
            //               
            ArrayList<String> list1;
            list1 = new ArrayList<String>();
            list1.add("0");
            list1.add("1");
            list1.add("2");
            list1.add("3");
            list1.add("4");
            list1.add("5");
            list1.add("6");

            int from = list1.indexOf(from_dropdown);
            int to = list1.indexOf(to_dropdown);
            int count = to - from;
            int hoursfrom1 = Integer.parseInt(from_value);
            int hoursto1 = Integer.parseInt(to_value);
            int count1 = hoursto1 - hoursfrom1;

            FindIterable<Document> iterable = ccoll.find();

            iterable.forEach(new Block<Document>() {
                @Override
                public void apply(final Document document) {
                    //System.out.println(document.get("checkin_info"));

                    String s = document.toJson();
                    s.replace("Document", "");
                    // System.out.println(s);
                    JSONParser parser = new JSONParser();
                    try {
                        Object obj = parser.parse(s);
                        JSONObject doc = (JSONObject) obj;

                        //System.out.println(doc.get("checkin_info"));
                        JSONObject cinfo = (JSONObject) doc.get("checkin_info");
                        if (count >= 0) {
                            long num_checkin = 0;
                            for (int i = from; i <= to; i++) {
                                if (count1 >= 0) {
                                    for (int j = hoursfrom1; j <= hoursto1; j++) {
                                        //System.out.println(cinfo.get(j+"-"+i));
                                        if (cinfo.containsKey(j + "-" + i)) {
                                            num_checkin = num_checkin + (long) cinfo.get(j + "-" + i);
                                            //                              System.out.println(document.get("checkin_info."+j+"-"+i));

                                        }

                                    }
                                }
                            }
                            if (num_checkin != 0) {
                                if (jComboBox8.getSelectedItem().equals(">")
                                        && num_checkin > Long.parseLong(check_count_value)) {
                                    System.out
                                            .println(num_checkin + " checkins into " + doc.get("business_id"));
                                    checkinout.add((String) document.get("business_id"));

                                }
                                if (jComboBox8.getSelectedItem().equals("<")
                                        && num_checkin < Long.parseLong(check_count_value)) {
                                    System.out
                                            .println(num_checkin + " checkins into  " + doc.get("business_id"));
                                    checkinout.add((String) document.get("business_id"));

                                }
                                if (jComboBox8.getSelectedItem().equals("=")
                                        && num_checkin == Long.parseLong(check_count_value)) {
                                    System.out
                                            .println(num_checkin + " checkins into  " + doc.get("business_id"));
                                    checkinout.add((String) document.get("business_id"));

                                }
                            }

                            num_checkin = 0;

                        }
                    } catch (Exception e) {
                        System.out.println(e);
                    }
                }
            });

            if (fromdate_value != null && todate_value != null) {
                BasicDBObject fdv = new BasicDBObject("date", new BasicDBObject("$gte", fromdate_value));
                ReviewList.add(fdv);
                BasicDBObject tdv = new BasicDBObject("date", new BasicDBObject("$lte", todate_value));
                ReviewList.add(tdv);
            }
            if (stars_value != null) {
                if (stars_dropdown == ">") {
                    BasicDBObject sv = new BasicDBObject("stars",
                            new BasicDBObject("$gt", Integer.parseInt(stars_value)));
                    ReviewList.add(sv);
                }
                if (stars_dropdown == "<") {
                    BasicDBObject sv = new BasicDBObject("stars",
                            new BasicDBObject("$lt", Integer.parseInt(stars_value)));
                    ReviewList.add(sv);
                }
                if (stars_dropdown == "=") {
                    BasicDBObject sv = new BasicDBObject("stars", Integer.parseInt(stars_value));
                    ReviewList.add(sv);
                }
            }

            if (votes_value != null) {
                if (votes_dropdown == ">") {
                    BasicDBObject vv = new BasicDBObject("votes",
                            new BasicDBObject("$gt", Integer.parseInt(votes_value)));
                    //ReviewList.add(vv);
                }
                if (votes_dropdown == "<") {
                    BasicDBObject vv = new BasicDBObject("votes",
                            new BasicDBObject("$lt", Integer.parseInt(votes_value)));
                    //ReviewList.add(vv);
                }
                if (votes_dropdown == "=") {
                    BasicDBObject vv = new BasicDBObject("votes", Integer.parseInt(votes_value));
                    //ReviewList.add(vv);
                }
            }
            qryReview = new BasicDBObject("$and", ReviewList);
            if (qryReview == null) {
                //jTextField8.setText("db.review.find()");
                cursor1 = rcoll.find();

            } else {

                //jTextField8.setText("db.review.find("+qryReview.toString()+")");
                cursor1 = rcoll.find(qryReview);
            }

            cursor1.forEach(new Block<Document>() {
                @Override
                public void apply(final Document document) {
                    System.out.println(document.get("business_id"));
                    reviewout.add((String) document.get("business_id"));

                }
            });
            if ("AND".equals(jComboBox1.getSelectedItem().toString())) {
                //jTextField8.setText("db.checkin.find("+"{}"+","+"{business_id"+":1}"+")");
                List<String> fin = new ArrayList<String>(catout);
                System.out.println(fin.size());
                fin.retainAll(proout);
                System.out.println(fin.size());

                fin.retainAll(checkinout);

                System.out.println(fin.size());

                fin.retainAll(reviewout);

                //
                System.out.println(fin.size());
                String Columnames[] = { "Business_id", "state", "city", "stars" };
                DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
                dtm.setColumnCount(0);
                dtm.setRowCount(0);
                int numberOfColumns = Columnames.length;
                Object rowData[] = new Object[numberOfColumns];

                for (int i = 0; i < numberOfColumns; i++) {
                    String name = Columnames[i];
                    dtm.addColumn(name);

                }
                for (int i = 0; i < fin.size(); i++) {

                    rowData[0] = fin.get(i);
                    BasicDBObject c11 = new BasicDBObject("business_id", fin.get(i));
                    FindIterable<Document> f1;
                    f1 = coll.find(c11);
                    f1.forEach(new Block<Document>() {
                        @Override
                        public void apply(final Document document) {

                            Object rowData[] = new Object[numberOfColumns];
                            rowData[0] = document.get("business_id");
                            rowData[1] = document.get("state");
                            rowData[2] = document.get("city");
                            rowData[3] = document.get("stars");
                            dtm.addRow(rowData);
                            rowData = null;

                        }
                    });

                    //                                
                    //                                
                    //                              

                }

                jTable1.setRowSelectionAllowed(true);
                jTable1.setModel(dtm);

                jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                dtm.fireTableDataChanged();

            }
            if ("OR".equals(jComboBox1.getSelectedItem().toString())) {
                //MongoCollection<Document> = db.getCollection("business");
                //jTextField8.setText("db.checkin.find("+"{}"+","+"{business_id"+":1}"+")");
                List<String> fin = new ArrayList<String>(catout); //create a Set with all the elements in a
                fin.addAll(proout);
                System.out.println(fin.size());
                fin.addAll(checkinout);
                System.out.println(fin.size());
                fin.addAll(reviewout);
                System.out.println(fin.size());

                String Columnames[] = { "Business_id", "state", "city", "stars" };
                DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
                dtm.setColumnCount(0);
                dtm.setRowCount(0);
                int numberOfColumns = Columnames.length;
                //Object rowData[] = new Object[numberOfColumns];
                //Object rd1,rd2,rd3; 

                for (int i = 0; i < numberOfColumns; i++) {
                    String name = Columnames[i];
                    dtm.addColumn(name);

                }
                for (int i = 0; i < fin.size(); i++) {

                    Object rowData[] = new Object[numberOfColumns];

                    rowData[0] = fin.get(i);

                    BasicDBObject c11 = new BasicDBObject("business_id", fin.get(i));
                    FindIterable<Document> f1;
                    f1 = coll.find(c11);
                    f1.forEach(new Block<Document>() {
                        @Override
                        public void apply(final Document document) {

                            Object rowData[] = new Object[numberOfColumns];
                            rowData[0] = document.get("business_id");
                            rowData[1] = document.get("state");
                            rowData[2] = document.get("city");
                            rowData[3] = document.get("stars");
                            dtm.addRow(rowData);
                            rowData = null;
                        }
                    });

                }
                //                       });

                //Object rowData[] = new Object[numberOfColumns];

                //                                
                //                                
                //                              

                jTable1.setRowSelectionAllowed(true);
                jTable1.setModel(dtm);

                jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                dtm.fireTableDataChanged();

            }
            if (qryBusiness == null) {
                //jTextField8.setText("db.business.find()");
                cursor = coll.find();

            } else {

                //jTextField8.setText("db.business.find("+qryBusiness.toString()+")");
                cursor = coll.find(qryBusiness);
            }

            //         } catch (SQLException ex) {
            //             Logger.getLogger(hw.class.getName()).log(Level.SEVERE, null, ex);
            //         }
            //             
            //             
            //         
            //     

        }

    }
}