1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

help me on this code please!!

Discussion in 'Java' started by student123, Dec 9, 2009.

  1. student123

    student123 New Member

    Oct 20, 2009
    Likes Received:
    Trophy Points:
    dear brothers
    i want some help on this code
    i have java database, and this code search in the database forthe intered values
    i want to check the input and reteive error message if the intered values not found ...
    i will be glad if you give me some hint


    package trainingsectionv1;
    import javax.swing.JTable;
    import javax.swing.RowFilter;
    import javax.swing.table.TableRowSorter;
    import org.jdesktop.beansbinding.Converter;
     * Binding converter between String and regex RowFilter (encapsulated by RowSorterToStringConverter).
     *  */
    public class RowSorterToStringConverter extends Converter {
        private JTable table;
        public JTable getTable() {
            return table;
        public void setTable(JTable table) {
            this.table = table;
        public Object convertForward(Object value) {
            return value.toString();
        public Object convertReverse(Object mask) {
            TableRowSorter sorter = new TableRowSorter(table.getModel());
            // The following statement makes the filter case-sensitive. If you want
            //filter to work in a case-insensitive way, uncomment the line below, comment
            //the 7 code lines below
            //sorter.setRowFilter(RowFilter.regexFilter(".*" + mask + ".*"));
            //The following 7 lines create a case-insensitive filter. If you want
            //the filter to be case-sensitive, comment them out and uncomment the
            //line above
            String m = mask.toString();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m.length(); i++) {
                char c = m.charAt(i);
           sorter.setRowFilter(RowFilter.regexFilter(".*" + sb + ".*"));
            return sorter;
    Last edited by a moderator: Dec 10, 2009

Share This Page