Example usage for javax.swing.table TableRowSorter TableRowSorter

List of usage examples for javax.swing.table TableRowSorter TableRowSorter

Introduction

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

Prototype

public TableRowSorter(M model) 

Source Link

Document

Creates a TableRowSorter using model as the underlying TableModel.

Usage

From source file:org.fhcrc.cpl.viewer.quant.gui.ProteinQuantSummaryFrame.java

License:asdf

/**
 * Find all the peptides contributing to the ratio for the FIRST OCCURRENCE of a
 * protein in the pepXML file, find all quantitative events for those peptides in the
 * pepXML file, and show them//from  w  w w. j  a v a 2  s  .  com
 * @param pepXmlFile
 * @param proteins
 */
public void displayData(File pepXmlFile, File protXmlFile, List<ProtXmlReader.Protein> proteins) {
    _log.debug("displayData 1***");
    this.protXmlFile = protXmlFile;
    this.pepXmlFile = pepXmlFile;
    Collections.sort(proteins, new Comparator<ProtXmlReader.Protein>() {
        public int compare(ProtXmlReader.Protein o1, ProtXmlReader.Protein o2) {
            return o1.getProteinName().compareTo(o2.getProteinName());
        }
    });

    DefaultTableModel proteinRatiosTableModel = new DefaultTableModel(0, 4) {
        //all cells uneditable
        public boolean isCellEditable(int row, int column) {
            return false;
        }

        public Class getColumnClass(int columnIndex) {
            switch (columnIndex) {
            case 0:
                return String.class;
            case 1:
                return Float.class;
            case 2:
            case 3:
                return Integer.class;
            }
            return String.class;
        }
    };
    proteinRatiosTable.setModel(proteinRatiosTableModel);
    proteinRatiosTable.getColumnModel().getColumn(0).setHeaderValue("Protein");
    proteinRatiosTable.getColumnModel().getColumn(1).setHeaderValue("Ratio");
    proteinRatiosTable.getColumnModel().getColumn(2).setHeaderValue("Quant Peptides");
    proteinRatiosTable.getColumnModel().getColumn(3).setHeaderValue("Events");

    _log.debug("displayData getting protein info");

    this.proteinNames = new ArrayList<String>();
    List<ProtXmlReader.QuantitationRatio> quantRatios = new ArrayList<ProtXmlReader.QuantitationRatio>();
    proteinRatiosTableModel.setRowCount(proteins.size());

    for (int i = 0; i < proteins.size(); i++) {
        String proteinName = proteins.get(i).getProteinName();
        ProtXmlReader.QuantitationRatio quantRatio = proteins.get(i).getQuantitationRatio();
        quantRatios.add(quantRatio);
        proteinNames.add(proteinName);

        //careful -- the 3rd column values are populated below
        proteinRatiosTableModel.setValueAt(proteinName, i, 0);
        proteinRatiosTableModel.setValueAt(Rounder.round(quantRatio.getRatioMean(), 2), i, 1);
    }
    if (proteinNames.size() == 1)
        eventsTable.hideProteinColumn();
    if (proteinGenesMap == null)
        eventsTable.hideGeneColumn();
    else {
        eventsTable.setProteinGenesMap(proteinGenesMap);
    }

    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(proteinRatiosTableModel);
    proteinRatiosTable.setRowSorter(sorter);

    contentPanel.updateUI();

    _log.debug("displayData getting quant events");

    quantEvents = new ArrayList<QuantEvent>();
    Map<String, Set<String>> peptideProteinsQuantMap = new HashMap<String, Set<String>>();
    for (int i = 0; i < proteins.size(); i++) {
        for (String peptide : quantRatios.get(i).getPeptides()) {
            Set<String> proteinsThisPep = peptideProteinsQuantMap.get(peptide);
            if (proteinsThisPep == null) {
                proteinsThisPep = new HashSet<String>();
                peptideProteinsQuantMap.put(peptide, proteinsThisPep);
            }
            proteinsThisPep.add(proteins.get(i).getProteinName());
        }
    }

    _log.debug("peptideProteinsQuantMap has " + peptideProteinsQuantMap.size() + " peptides.");
    System.err.println("Contains the one? " + peptideProteinsQuantMap.containsKey("QCPYCLLYK"));

    proteinEventsMap = new HashMap<String, List<QuantEvent>>();
    Map<String, Set<String>> proteinPeptidesMap = new HashMap<String, Set<String>>();

    try {
        PepXMLFeatureFileHandler.PepXMLFeatureSetIterator fsi = new PepXMLFeatureFileHandler.PepXMLFeatureSetIterator(
                pepXmlFile);
        int numFractions = 0;
        setMessage("Loading all pepXML fractions...");
        _log.debug("Loading all pepXML fractions...");

        while (fsi.hasNext()) {
            boolean thisFracHasEvents = false;
            FeatureSet featureSet = fsi.next();
            setMessage("Checking fraction " + MS2ExtraInfoDef.getFeatureSetBaseName(featureSet));
            _log.debug("Checking fraction " + MS2ExtraInfoDef.getFeatureSetBaseName(featureSet));
            String featureSetBaseName = MS2ExtraInfoDef.getFeatureSetBaseName(featureSet);
            //check all features to see if they're in our list of peptides.  If so, add to quantEvents
            for (Feature feature : featureSet.getFeatures()) {
                String peptide = MS2ExtraInfoDef.getFirstPeptide(feature);
                if (peptideProteinsQuantMap.containsKey(peptide)
                        && IsotopicLabelExtraInfoDef.hasRatio(feature)) {
                    thisFracHasEvents = true;
                    //pick up the labeled residue from the first feature
                    //                        if (labeledResidue == null)
                    //                        {
                    //                            AnalyzeICAT.IsotopicLabel label = IsotopicLabelExtraInfoDef.getLabel(feature);
                    //                            if (label != null)
                    //                            {
                    //                                labeledResidue = "" + label.getResidue();
                    //                                labelMassDiff = label.getHeavy() - label.getLight();
                    //                                _log.debug("Found label: " + labeledResidue + ", " + labelMassDiff);
                    //                            }
                    //                        }
                    QuantEvent quantEvent = new QuantEvent(feature, featureSetBaseName);
                    quantEvent.setProtein(new ArrayList<String>(peptideProteinsQuantMap.get(peptide)).get(0));
                    quantEvents.add(quantEvent);

                    for (String protein : peptideProteinsQuantMap.get(peptide)) {
                        Set<String> peptidesThisProtein = proteinPeptidesMap.get(protein);

                        if (peptidesThisProtein == null) {
                            peptidesThisProtein = new HashSet<String>();
                            proteinPeptidesMap.put(protein, peptidesThisProtein);
                        }
                        peptidesThisProtein.add(quantEvent.getPeptide());

                        List<QuantEvent> eventsThisProtein = proteinEventsMap.get(protein);
                        if (eventsThisProtein == null) {
                            eventsThisProtein = new ArrayList<QuantEvent>();
                            proteinEventsMap.put(protein, eventsThisProtein);
                        }
                        eventsThisProtein.add(quantEvent);
                    }
                }
            }
            if (thisFracHasEvents)
                numFractions++;
        }
        _log.debug("Processed all pepXML fractions ");
        for (int i = 0; i < proteins.size(); i++) {
            String protein = proteinNames.get(i);
            if (proteinPeptidesMap.get(proteinNames.get(i)) != null)
                proteinRatiosTableModel.setValueAt(proteinPeptidesMap.get(protein).size(), i, 2);
            if (proteinEventsMap.get(proteinNames.get(i)) != null)
                proteinRatiosTableModel.setValueAt(proteinEventsMap.get(protein).size(), i, 3);
        }

        if (numFractions < 2) {
            setMessage("Loaded all quantitation events from 1 fraction");
            _log.debug("Loaded all quantitation events from 1 fraction");
        } else {
            setMessage("Loaded all quantitation events from " + numFractions + " separate fractions");
            _log.debug("Loaded all quantitation events from " + numFractions + " separate fractions");

        }
        //            if (labeledResidue == null)
        //                infoMessage("WARNING: unable to determine modification used for quantitation.  " +
        //                        "Cannot collapse light and heavy states or perform assessment.");
        //            else
        //            {
        //                labelType = QuantitationUtilities.inferLabelType(labeledResidue, labelMassDiff);
        //            }
    } catch (Exception e) {
        //check if the file has a .pep.xml extension, in case someone put the wrong file in
        if (pepXmlFile.getName().toLowerCase().endsWith("pep.xml"))
            errorMessage("Failed to load features from pepXML file: " + e.getMessage(), e);
        else {
            infoMessage("Failed to load pepXML file " + pepXmlFile.getName()
                    + ".  Extension is not .pep.xml... did you specify the wrong file?");
            e.printStackTrace(System.err);
        }

        return;
    }

    _log.debug("Done loading quant events. Events: " + quantEvents.size());

    if (quantEvents.isEmpty()) {
        throw new RuntimeException("No quantitation events found!");
    }

    //sort by peptide, then fraction, then charge, then modifications
    Collections.sort(quantEvents, new QuantEvent.ProteinPeptideFractionChargeModificationsRatioAscComparator());
    _log.debug("About to display events...");
    displayEvents();
    if (quantRatios.size() == 1) {
        eventsTable.setLogRatioHeaderRatio(quantRatios.get(0).getRatioMean());
    }

    _log.debug("About to update extreme ratio GUI...");

    updateExtremeRatioGUI();

}

From source file:dataviewer.DataViewer.java

private void cb_tableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_tableActionPerformed
    try {/*from   w  w  w .  java  2  s .  c om*/
        table = cb_table.getSelectedItem().toString();
        DB db = new DB("./db/" + table + ".db");
        db.open();
        String[] cols = db.get_table_columns(table);
        db.close();

        DefaultTableModel model = new DefaultTableModel();
        //model.addColumn("Column Index");
        model.addColumn("Field");
        int i = 1;

        StyleContext sc = StyleContext.getDefaultStyleContext();
        TabSet tabs = new TabSet(new TabStop[] { new TabStop(20) });
        AttributeSet paraSet = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabs);
        tp_sql.setParagraphAttributes(paraSet, false);

        StyledDocument doc = tp_sql.getStyledDocument();

        doc.remove(0, doc.getLength());

        doc.insertString(doc.getLength(), "SELECT", null);
        doc.insertString(doc.getLength(), "\n", null);

        for (int j = 1; j < cols.length; ++j) {
            String s = cols[j];
            //model.addRow(new Object[]{i++, s});
            model.addRow(new Object[] { s });
            doc.insertString(doc.getLength(), "\t", null);
            doc.insertString(doc.getLength(), s, null);
            if (j < cols.length - 1) {
                doc.insertString(doc.getLength(), ",", null);
            }
            doc.insertString(doc.getLength(), "\n", null);
        }

        doc.insertString(doc.getLength(), "FROM", null);
        doc.insertString(doc.getLength(), "\n", null);
        doc.insertString(doc.getLength(), "\t", null);
        doc.insertString(doc.getLength(), table, null);
        /*doc.insertString(doc.getLength(), "\n", null);
         doc.insertString(doc.getLength(), "WHERE", null);
         doc.insertString(doc.getLength(), "\n", null);
         doc.insertString(doc.getLength(), "\t", null);
         doc.insertString(doc.getLength(), "_N_ <= " + N, null);
         doc.insertString(doc.getLength(), ";", null);*/

        tb_columns.setModel(model);

        TableRowSorter trs = new TableRowSorter(model);
        trs.setComparator(0, new IntComparator());
        tb_columns.setRowSorter(trs);

        //highline();
    } catch (Exception e) {
        txt_count.setText(e.getMessage());
    }
}

From source file:library.Form_Library.java

License:asdf

public Form_Library() {
    super("Library Management");
    initComponents();/*from w w  w . ja v a 2 s.  com*/
    setLocationRelativeTo(null);
    setSize(1100, 700);
    jPanel1.setSize(900, 600);
    jPanel2.setSize(900, 600);
    jPanel3.setSize(900, 600);
    jPanel4.setSize(900, 600);
    jPanel5.setSize(900, 600);
    jPanel6.setSize(900, 600);

    //        BufferedImage img = null;
    //        try {
    //            img = ImageIO.read(new File("D:\\CODE\\00. SOFTTECH\\9. JAVA 1\\Project\\Library_Minh\\src\\icon\\BG.jpg"));
    //        } catch (IOException e) {
    //            e.printStackTrace();
    //        }
    //        ImageIcon imageIcon = new ImageIcon(img.getScaledInstance(jLabel20.getWidth(), jLabel20.getHeight(), Image.SCALE_SMOOTH));
    //        jLabel20.setIcon(imageIcon);
    AutoSuggestor autoSuggestor = new Form_Library.AutoSuggestor(tfSearchBook, this, null,
            Color.BLACK.brighter(), Color.WHITE, Color.RED, 1.00f) {
        @Override
        boolean wordTyped(String typedWord) {
            //create list for dictionary this in your case might be done via calling a method which queries db and returns results as arraylist
            ArrayList<String> BookNameList = new ArrayList<String>();
            BookNameList = da.loadBookName("select BookName from book", "BookName");
            setDictionary(BookNameList);
            return super.wordTyped(typedWord);//now call super to check for any matches against newest dictionary
        }
    };
    da.LoadData(sql, tbPhieuQuaHan);
    try {
        String sql1 = "SELECT SUM(Quantity) as BookSum from book";
        String sql2 = "SELECT COUNT(RdID) as ReaderSum FROM reader";
        String sql3 = "SELECT COUNT(BorrowID) as BorrowSum FROM borrowingmanagement";
        String sql4 = "SELECT COUNT(DISTINCT RdID) as ReaderBorrowSum FROM borrowingmanagement";
        String sql5 = "SELECT COUNT(BorrowID) as DatedBorrowSum FROM borrowingmanagement "
                + "where (ReturnDate < CURDATE())";
        ResultSet rs1 = da.getData(sql1);
        ResultSet rs2 = da.getData(sql2);
        ResultSet rs3 = da.getData(sql3);
        ResultSet rs4 = da.getData(sql4);
        ResultSet rs5 = da.getData(sql5);
        if (rs1.next()) {
            this.lbTongSach.setText("Total books : " + Integer.toString(rs1.getInt("BookSum")));
        }
        if (rs2.next()) {
            this.lbTongKhach.setText("Total Readers: " + Integer.toString(rs2.getInt("ReaderSum")));
        }
        if (rs3.next()) {
            this.lbTongPhieu.setText("Total Borrowings: " + Integer.toString(rs3.getInt("BorrowSum")));
        }
        if (rs4.next()) {
            this.lbTongKhachMuon.setText(
                    "Total Readers who borrowing books: " + Integer.toString(rs4.getInt("ReaderBorrowSum")));
        }
        if (rs5.next()) {
            this.lbTongPhieuQuaHan
                    .setText("Total overdue Borrowings: " + Integer.toString(rs5.getInt("DatedBorrowSum")));
        }

    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, e);
    }
    taBaoCao.setText("");
    //        ResultSet rs = null;
    //        rs = da.getData(sql);
    //        List l;
    //        l = DbUtils.resultSetToNestedList(rs);
    //        this.taBaoCao.append(this.lbTongSach.getText() + "\n");
    //        this.taBaoCao.append(this.lbTongKhach.getText() + "\n");
    //        this.taBaoCao.append(this.lbTongPhieu.getText() + "\n");
    //        this.taBaoCao.append(this.lbTongKhachMuon.getText() + "\n");
    //        this.taBaoCao.append(this.lbTongPhieuQuaHan.getText() + "\n\n");
    //        this.taBaoCao.append("|  BorrowID  |  RdID  |  BookID  |  BorrowDate  |  ReturnDate  |\n");
    //        for (int i = 0; i < l.size(); i++) {
    //            this.taBaoCao.append(l.get(i).toString() + "\n");
    //        }

    //Reader
    this.tbReader.setModel(dmReader);
    dmReader.setColumnIdentifiers(tenCotReader);
    ReaderList.load("Select * from reader");
    for (Reader r : ReaderList.getList()) {
        dmReader.addRow(r.toVector());
    }

    //Borrowing Management
    this.tbBorrowingManagement.setModel(dmBorrowing);
    dmBorrowing.setColumnIdentifiers(tenCotBorrowing);

    //Gia hn th ?c
    tbReader.getColumn("Add 1 Year").setCellRenderer(new ButtonRenderer());
    ButtonEditor be = new ButtonEditor(new JCheckBox());
    tbReader.getColumn("Add 1 Year").setCellEditor(be);
    be.button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int donghh = tbReader.getSelectedRow();
            String RdIDhh = tbReader.getValueAt(donghh, 0).toString();
            String RdNamehh = tbReader.getValueAt(donghh, 1).toString();
            String IDcardhh = tbReader.getValueAt(donghh, 2).toString();
            String Sexhh = tbReader.getValueAt(donghh, 3).toString();
            Date Birthdayhh = carBirthday.getDate();
            String Addresshh = tbReader.getValueAt(donghh, 5).toString();
            String Phonehh = tbReader.getValueAt(donghh, 6).toString();
            String Emailhh = tbReader.getValueAt(donghh, 7).toString();
            Date ActiveDatehh = carActivationDate.getDate();

            Reader r = new Reader(RdIDhh, RdNamehh, IDcardhh, Sexhh, Birthdayhh, Addresshh, Phonehh, Emailhh,
                    ActiveDatehh, nextyear);
            Vector vt = r.toVector();

            try {
                ReaderList.suaExpiredDate(donghh, r);
            } catch (Exception ex) {
                Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
            }
            dmReader.removeRow(donghh);
            dmReader.insertRow(donghh, vt);
        }
    });

    //Return
    this.tbReturn.setModel(dmReturn);
    dmReturn.setColumnIdentifiers(tenCotReturn);

    //        "Borrow ID", "Book ID", "Reader Name", "Book Name", "Author Name", "Publisher Name", "Price", "Borrow Date", "Return Date", "Overdue Days", "Penalty", "Delete"
    //Xa phiu mn
    tbReturn.getColumn("Delete").setCellRenderer(new ButtonRenderer());
    ButtonEditor beDel = new ButtonEditor(new JCheckBox());
    tbReturn.getColumn("Delete").setCellEditor(beDel);
    beDel.button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            try {
                int donghh = tbReturn.getSelectedRow();
                String borID = tbReturn.getValueAt(donghh, 0).toString();
                System.out.println(borID);
                int xoaPhieu = ReturnList.xoa(borID);
                dmReturn.removeRow(xoaPhieu);
            } catch (Exception ex) {
                Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    });
    ReturnList.load(
            "select borrowingmanagement.BorrowID, borrowingmanagement.BookID, reader.RdName,book.BookName, author.AuthorName, publisher.PublisherName, book.Price, borrowingmanagement.BorrowDate, borrowingmanagement.ReturnDate\n"
                    + "from borrowingmanagement\n"
                    + "inner join book on borrowingmanagement.BookID = book.BookID\n"
                    + "inner join author on book.AuthorID = author.AuthorID\n"
                    + "inner join reader on borrowingmanagement.RdID = reader.RdID\n"
                    + "inner join publisher on book.PublisherID = publisher.PublisherID\n");
    for (ReturnManagement c : ReturnList.getReturnList()) {
        dmReturn.addRow(c.toVector());
    }

    //Gia hn mn sch
    tbBorrowingManagement.getColumn("Add 10 Days").setCellRenderer(new ButtonRenderer());
    ButtonEditor buttonEditor = new ButtonEditor(new JCheckBox());
    tbBorrowingManagement.getColumn("Add 10 Days").setCellEditor(buttonEditor);
    buttonEditor.button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int donghh = tbBorrowingManagement.getSelectedRow();
            try {
                System.out.println(
                        truNgayThang(df.parse(tbBorrowingManagement.getValueAt(donghh, 4).toString())));
            } catch (ParseException ex) {
                Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
            }
            try {
                if (truNgayThang(df2.parse(tbBorrowingManagement.getValueAt(donghh, 4).toString())) <= 0) {

                    String BrIDhh = tbBorrowingManagement.getValueAt(donghh, 0).toString();
                    String RdIDhh = tbBorrowingManagement.getValueAt(donghh, 1).toString();
                    String BookIDhh = tbBorrowingManagement.getValueAt(donghh, 2).toString();
                    Date BorrowDatehh = carBorrowDate.getDate();

                    BorrowingManagement r = new BorrowingManagement(BrIDhh, RdIDhh, BookIDhh, BorrowDatehh,
                            nextday);
                    Vector vt = r.toVector();

                    try {
                        BorrowingList.suaReturnDate(donghh, r);
                    } catch (Exception ex) {
                        Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    dmBorrowing.removeRow(donghh);
                    dmBorrowing.insertRow(donghh, vt);
                    //                disableCarlendarBorrow();
                } else {
                    JOptionPane.showMessageDialog(null, "Can't renew");
                }
            } catch (ParseException ex) {
                Logger.getLogger(Form_Library.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    BorrowingList.load("Select * from borrowingmanagement");

    for (BorrowingManagement r : BorrowingList.getList()) {
        dmBorrowing.addRow(r.toVector());

    }

    //Book
    this.tbBookAdmin.setModel(dmBook);
    dmBook.setColumnIdentifiers(tenCotBook);
    BookList.load("Select * from book");
    for (Book b : BookList.getList()) {
        dmBook.addRow(b.toVector());
    }
    clist.loadCategory();
    for (Category c : clist.getCategoryList()) {
        this.cbCategoryID.addItem(c.getCategoryID());
    }

    //Author
    this.tbAuthorAdmin.setModel(dmAuthor);
    dmAuthor.setColumnIdentifiers(tenCotAuthor);
    AuthorList.load("Select * from author");
    for (Author b : AuthorList.getList()) {
        dmAuthor.addRow(b.toVector());
    }

    //Category
    this.tbcategory.setModel(dmCategory);
    dmCategory.setColumnIdentifiers(tenCotCategory);
    CategoryList.load("Select * from category");
    for (Category c : CategoryList.getCategoryList()) {
        dmCategory.addRow(c.toVector());
    }

    //Publisher
    this.tbPublisher.setModel(dmPublisher);
    dmPublisher.setColumnIdentifiers(tenCotPublisher);
    PublisherList.load("Select * from publisher");
    for (Publisher c : PublisherList.getPublisherList()) {
        dmPublisher.addRow(c.toVector());
    }

    //Supplier
    this.tbSupplierAdmin.setModel(dmSupplier);
    dmSupplier.setColumnIdentifiers(tenCotSupplier);
    SupplierList.load("Select * from supplier");
    for (Supplier c : SupplierList.getSupplierList()) {
        dmSupplier.addRow(c.toVector());
    }

    //Co dn cc ct
    resizeColumnWidth(tbAuthorAdmin);
    resizeColumnWidth(tbBookAdmin);
    resizeColumnWidth(tbBorrowingManagement);
    resizeColumnWidth(tbPhieuQuaHan);
    resizeColumnWidth(tbPublisher);
    resizeColumnWidth(tbReader);
    resizeColumnWidth(tbReturn);
    resizeColumnWidth(tbSupplierAdmin);
    resizeColumnWidth(tbcategory);

    //Sort Jtable
    TableRowSorter<TableModel> sorter = new TableRowSorter<>(tbBookAdmin.getModel());
    tbBookAdmin.setRowSorter(sorter);
    TableRowSorter<TableModel> sorter2 = new TableRowSorter<>(tbReturn.getModel());
    tbReturn.setRowSorter(sorter2);
    sorter2.setComparator(6, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });
    sorter2.setComparator(9, new Comparator<Long>() {
        @Override
        public int compare(Long o1, Long o2) {
            return o1.intValue() - o2.intValue();
        }
    });
    sorter2.setComparator(10, new Comparator<Long>() {
        @Override
        public int compare(Long o1, Long o2) {
            return o1.intValue() - o2.intValue();
        }
    });

    sorter.setComparator(6, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });
    sorter.setComparator(7, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });
    sorter.setComparator(9, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });
    sorter.setComparator(10, new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    });

    jPopupMenuBook.setName("jPopupMenu");
    tbBookAdmin.setComponentPopupMenu(jPopupMenuBook);
    jMenuItemBook.setText("Copy"); // NOI18N
    jMenuItemBook.setName("jMenuItem"); // NOI18N
    jPopupMenuBook.add(jMenuItemBook);

    jMenuItemBo.setName("jPopupMenu");
    tbBorrowingManagement.setComponentPopupMenu(jPopupMenuBo);
    jMenuItemBo.setText("Copy"); // NOI18N
    jMenuItemBo.setName("jMenuItem"); // NOI18N
    jPopupMenuBo.add(jMenuItemBo);

    jPopupMenuAuthor.setName("jPopupMenu");
    tbAuthorAdmin.setComponentPopupMenu(jPopupMenuAuthor);
    jMenuItemAuthor.setText("Copy"); // NOI18N
    jMenuItemAuthor.setName("jMenuItem"); // NOI18N
    jPopupMenuAuthor.add(jMenuItemAuthor);

    jPopupMenuPub.setName("jPopupMenu");
    tbPublisher.setComponentPopupMenu(jPopupMenuPub);
    jMenuItemPub.setText("Copy"); // NOI18N
    jMenuItemPub.setName("jMenuItem"); // NOI18N
    jPopupMenuPub.add(jMenuItemPub);

    jPopupMenuCate.setName("jPopupMenu");
    tbcategory.setComponentPopupMenu(jPopupMenuCate);
    jMenuItemCate.setText("Copy"); // NOI18N
    jMenuItemCate.setName("jMenuItem"); // NOI18N
    jPopupMenuCate.add(jMenuItemCate);

    jPopupMenuSup.setName("jPopupMenu");
    tbSupplierAdmin.setComponentPopupMenu(jPopupMenuSup);
    jMenuItemSup.setText("Copy"); // NOI18N
    jMenuItemSup.setName("jMenuItem"); // NOI18N
    jPopupMenuSup.add(jMenuItemSup);

    jPopupMenuReader.setName("jPopupMenu");
    tbReader.setComponentPopupMenu(jPopupMenuReader);
    jMenuItemReader.setText("Copy"); // NOI18N
    jMenuItemReader.setName("jMenuItem"); // NOI18N
    jPopupMenuReader.add(jMenuItemReader);

    jLabel20.setIcon(loadImage("src\\icon\\BG.jpg", 1070, 558));

    setCarlendarBorrow();
    setCarlendarReader();
}

From source file:com.sec.ose.osi.ui.frm.main.manage.JPanManageMain.java

/**
 * This method initializes jTablePjtList   
 *    //from  w w w  .  ja  v  a 2 s .c o m
 * @return javax.swing.JTable   
 */
@SuppressWarnings("unchecked")
private JTable getJTablePjtList() {
    if (jTablePjtList == null) {

        jTablePjtList = new JTable(getProjectTableModel());
        getProjectTableModel().setColumnWidth(jTablePjtList);
        getProjectTableModel().setColumnType(jTablePjtList);
        jTablePjtList.addMouseListener(new ProjectTableClickAction());

        TableRowSorter sorter = new TableRowSorter(managedProjectTableModel);
        sorter.setComparator(ManagedProjectTableModel.COL_DELETE, new ProjectTableComparator());
        sorter.setComparator(ManagedProjectTableModel.COL_PROJECT_NAME, new ProjectTableComparator());
        sorter.setComparator(ManagedProjectTableModel.COL_ANALYZE_TARGET, new ProjectTableComparator());
        sorter.setComparator(ManagedProjectTableModel.COL_ANALYZE_STATUS, new ProjectTableComparator());
        sorter.setComparator(ManagedProjectTableModel.COL_SOURCE_LOCATION, new ProjectTableComparator());
        sorter.toggleSortOrder(ManagedProjectTableModel.COL_PROJECT_NAME);
        jTablePjtList.setRowSorter(sorter);
    }
    return jTablePjtList;
}

From source file:com.view.TradeWindow.java

private void TraderRequestsFilterActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(
            TraderIncomingRequestsTable.getModel());
    TraderIncomingRequestsTable.setRowSorter(sorter);
    String text = FilterTextTraderRequests.getText();
    if (text.length() == 0) {
        sorter.setRowFilter(null);/*from w ww . j  a v a 2  s . c  o  m*/
    } else {
        sorter.setRowFilter(RowFilter.regexFilter(text));
    }

}

From source file:com.view.TradeWindow.java

private void clearFilterActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:

    FilterTextTraderRequests.setText("");
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(
            TraderIncomingRequestsTable.getModel());
    TraderIncomingRequestsTable.setRowSorter(sorter);
    sorter.setRowFilter(null);// w  w w .j a va 2  s  .c  o m

}

From source file:com.view.TradeWindow.java

private void clearFilterBlockHistoryActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    FilterTextTraderBlockHistory.setText("");
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(
            TraderBlockHistoryTable.getModel());
    TraderBlockHistoryTable.setRowSorter(sorter);
    sorter.setRowFilter(null);// w ww  . j a  va2  s .  c o m

}

From source file:com.view.TradeWindow.java

private void TraderBlockHistoryFilterActionPerformed(java.awt.event.ActionEvent evt) {
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(
            TraderBlockHistoryTable.getModel());
    TraderBlockHistoryTable.setRowSorter(sorter);
    String text = FilterTextTraderBlockHistory.getText();
    if (text.length() == 0) {
        sorter.setRowFilter(null);/* ww  w. jav a2s.  co m*/
    } else {
        sorter.setRowFilter(RowFilter.regexFilter(text));
    }
}

From source file:com.view.PortfolioManagerWindow.java

private void PMPendingOrderFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PMPendingOrderFilterActionPerformed
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(PMPendingOrdersTable.getModel());
    PMPendingOrdersTable.setRowSorter(sorter);
    String text = FilterTextPMPending.getText();
    if (text.length() == 0) {
        sorter.setRowFilter(null);//from  w  w w  . ja  va2 s. c om
    } else {
        sorter.setRowFilter(RowFilter.regexFilter(text));
    }
}

From source file:com.view.PortfolioManagerWindow.java

private void PMEODFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PMEODFilterActionPerformed
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(PMEODBoughtTable.getModel());
    PMEODBoughtTable.setRowSorter(sorter);
    final TableRowSorter<TableModel> sorter2 = new TableRowSorter<TableModel>(PMEODSoldTable.getModel());
    PMEODSoldTable.setRowSorter(sorter2);
    String text = FilterTextPMEOD.getText();
    if (text.length() == 0) {
        sorter.setRowFilter(null);/*from ww w  . j  a  va2  s  .  co m*/
        sorter2.setRowFilter(null);
    } else {
        sorter.setRowFilter(RowFilter.regexFilter(text));
        sorter2.setRowFilter(RowFilter.regexFilter(text));
    }
}