Question about Filters in Java.

Hello ,
I want to make a filter over a JTable , so that data that appears in the JTable is filetered with the characters that are typed in the Field , each time a new character is entered the table is filtered. What can I use to make that happen?
Thanks.

hii,
if you're defining SomeTableModel, already, then
global def.
private final JTextField someTextField = new JTextField();
//private JButton refreshButton = new JButton("Refresh Data");
private JTable someTable = new JTable();
private  SomeTableModel tableModel;somewhere in class definition (for jtable)
            someTextField.setText("");
            final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel);
            someTable.setRowSorter(sorter);
            someTextField.getDocument().addDocumentListener(new DocumentListener() {
                private void searchFieldChangedUpdate(DocumentEvent evt) {
                    String text = someTextField.getText();
                    if (text.length() == 0) {
                        sorter.setRowFilter(null);
                        //someTable.clearSelection();
                    } else {
                        try {
                            sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); // hack for ignore CaseSensitive
                            //someTable.clearSelection();
                        } catch (PatternSyntaxException pse) {
                            JOptionPane.showMessageDialog(null, "Bad regex pattern", "Bad regex pattern", JOptionPane.ERROR_MESSAGE);
                public void insertUpdate(DocumentEvent evt) {
                    searchFieldChangedUpdate(evt);
                public void removeUpdate(DocumentEvent evt) {
                    searchFieldChangedUpdate(evt);
                public void changedUpdate(DocumentEvent evt) {
                    searchFieldChangedUpdate(evt);
            }); any changes from someTextField set filter/change result from/to SomeTableModel
... kopik

Similar Messages

  • A question about design of Java Application on java card.

    Hi every one,
    I have a question about design of Java applet on java card,
    There is an application on my card that it is not java card, it include a DF and some EF under DF, I would like to know if I want to have this application on java card ,how can I design DF and EF on java card ,I mean is there any relation between DF,EF with applet and file? for example can I say DF is same as applet and EF is same as file?
    I'll appreciate for any help .
    yours sincerely,
    orchid

    hi
    you can write a java class for DF.
    an instance of DF class have some EF objects.
    for example,
    samples/com/sun/javacard/samples/JavaPurse/CyclicFile.java
    implements ISO 7816 CyclicFile ( EF )
    see also:
    http://forum.java.sun.com/thread.jspa?threadID=673745&messageID=3936272
    best regards,
    siavash

  • Question about the new JAVA Update J2SE 5.0 Release 3

    Here is some info about this update:
    Java 2 Platform, Standard Edition (J2SE) 5.0 Release 3 allows applications and applets developed for the J2SE 5.0 platform to run on Mac OS X v 10.4.2 and later.
    This update does NOT CHANGE the DEFAULT VERSION of Java on your Mac from Java 1.4.2 to J2SE 5.0, though Java applications that require J2SE 5.0 may specifically request it. You can change the preferred Java version for applications and applets by using the new Java Preferences utility. This utility is installed by the J2SE 5.0 update at /Applications/Utilities/Java/J2SE 5.0/.
    http://docs.info.apple.com/article.html?artnum=302412
    HERE IS MY QUESTION---
    This update makes me nervous cause I don't know much about Java. IF I change my default version to this new 5.0 will it mean that some of the older Java stuff on the web won't work? Should I just download this and ignore it? What should I do about this update?
    Thanks for the help!
    Renée

    I too seem to be suffering issues with loading web pages after the 10.4.3/Java 5.0 update. I have reinstalled both updates, changed the java settings, emptied all the caches, and tried various combinations thereof, and I still have problems with web pages loaded. most of the problems appear to be related to rendering frames and images - In fact a couple of web sites I navigate to (upon looking at the source for the page" state "It appears your browser does not support frames." I think this is something broken in the latest release. Unfortunately, I cannot reinstall the latest copy of Safari, because the installer states "This version of Safari cannot be installed. It requires version 10.4.2." I guess I am in a pickle until Apple comes out with another update. BTW I have some pages that Safari will not render but IE running on the same box will. I also noticed that the problem propagated to other applications that use Java....For instance the Dashboard widget from google (Google Maps) no longer renders the tiled (framed?) map pieces...instead you get the ubiquitous "?" icon.

  • Question about privacy in Java

    hi, i have a question about privacy practices in Java. I always thought it was bad form to program with too many global variable. However, when I program in Java i find that most of the time I am making my variables global. Is the fact that they are in a class supposed to make up for that fact? With subclasses you can also have 3rd parties working on your data. It seems a bit suspicious to me, like the data should be maintained more strictly, or is it my job to do that? I am just curious, but it seems java promotes global variables, which I find to be bad programming practice since anything can operate on them. I appreciate any input...

    However, when I program in Java
    i find that most of the time I am making my variables
    global. (meaning public)Sounds like you are writing bad code. Public variables should be extrememly rare except static final 'constants'.
    Is the fact that they are in a class supposed
    to make up for that fact? Absolutely not.
    With subclasses you can also
    have 3rd parties working on your data. It seems a bit
    suspicious to me, like the data should be maintained
    more strictly, or is it my job to do that? Yes, it's your job.
    I am just
    curious, but it seems java promotes global variables,
    which I find to be bad programming practice since
    anything can operate on them. I appreciate any
    input...Java does not promote public variables. You have to explicitly make them public.

  • Question about filtered index

    I am looking over database for the SQL objects having SET QUOTED_IDENTIFIER OFF and SET ANSI_NULLS OFF
    For filtered index both needs to be ON so what about the objects that dont have quoted_identifier and ansi_nulls code line?
    do i need to add SET QUOTED_IDENTIFIER ON and SET ANSI_NULLS ON for those objects as well?

    Following article solved my question
    http://blogs.msdn.com/b/sqlprogrammability/archive/2009/06/29/interesting-issue-with-filtered-indexes.aspx
    I tried creating proc without quoted_identifier and ansi_nulls code line and proc still executes

  • Questions About Printing in Java

    Alright, I've been looking at the Java printing API. I like it, it's nice. I've got a drag-and-drop workspace that the user wants to print, so I just use m_workspace.paint(Graphics) on the print Graphics object to paint the workspace onto the page. Very nice.
    Here's the issue. I want to fit as many workspaces on a page as is possible. Now, with a Graphics2D object, I can call a couple of methods to get its height and width. I need to be able to determine the height and width of the Graphics object that the printer hands me. Here are the questions as best as I can describe them:
    * Is it possible to find the height and width of a Graphics object? How else can you determine a Graphics object's coordinate range?
    * When the Printable interface is given a Graphics object on which to print, does the Graphcis object represent the whole page or just the printable area of the page?
    * The PageFormat class provides methods for determining the height and width as well as the printable height and width of a page in 72nds of an inch. How does one determine the intended printing resolution (dpi) of the print job? If this cannot be done, how is it possible to determine the size of the page in pixels?
    I'd really appreciate help with this as fast as it can be mustered. This program needs to be completed by Friday morning and I'm clueless as to the Java printing interface.
    Thanks for any time you've spent reading this and the time you may spend answering it. :) Best wishes!

    After perusing the many books of one of my coworkers, I think I have good reason to believe the following:
    * Printing with the Printable interface is always at a resolution of 72dpi (1 pixel per point).
    * The Graphics object passed to print(...) represents a pixel space equal to the number of points of each dimension of the imageable area of the page.
    Can anyone with experience with Java printing confirm these conclusions?

  • Question about SSO (for Java Dialog instance) for Portal EP 6.0 SP 20

    Hi All
    I have following question.
    We are running Portal 6.0 SP 20. We have JAVA (Portal) CI+DB running on single host SAPQP1 and Two JAVA Dialog Instances (J2EE Application servers) running on separate host namely SAPAP35 and SAPAP36.
    I was able to configure SSO between SAPQP1 (CI+DB) and ECC R/3 system (QC1). SSO is working fine. Users can access all ESS/MSS data in portal when they use Portal URL running on SAPQP1 (http://sapqp1.xxxxx.com:50000/irj).
    But when users try to access ESS/MSS data via portal (URL) running on SAPQP35 (http://sapap35.xxxxx.com:50000/irj) and SAPAP36 ((http://sapap36.xxxxx.com:50000/irj) SSO does not work, i.e it system asks user id and password.
    So , how I can configure SSO between SAPAP35 and SAPAP36 JAVA Dialog instances and ECC R/3?

    Hi Sandip,
    obviously you already configured QC1 to accept Tickets issued by the Java Engine on SAPQP1. Did you imported the public (java) certificates from SAPAP35 and SAPAP36 into your ECC System? The certicficates need to be added in client 000 to your System PSE and in your production client to your ACL.
    Regards,
    Enno

  • Question about VB6 (no Java)

    Maybe someone can help me...if I wante to compile and run Java programs, I download JDK...but what do I do if I want to download a VB6 compiler? Is it free? How can I download it? Please don't say do a google, cos I did and was confused with all the information given back...all this stuff about runtime and controls and have you what...
    someone please answer me if you know the answer to this...

    My brother is a phycisist. He has no use for Java.I don't see why a physicist would look down his nose at Java. They write code, too.
    He's just got into VB recently cos he's been using a bit of Excel lately.If your brother is that smart, he doesn't need your help to figure out how to get ahold of and learn VB.
    He is a very nice guy. He is very unargumentative. So do not speak ill of him.Your brother sounds like a better person than you. Can you shove off and send him over to the forum?
    Honestly, I don't understand how you could think this behavior would ingratiate you with forum regulars.
    Why don't you follow annie's example? She offers good technical bits when she can and fine craic the rest of the time. She's obviously got some brains and manners. Why are you so lacking in both?
    %

  • Question about Technologies in JAVA

    Hi all,
    I'm starting my final project for Computer Science in University and I pretend to develop an integrated e-learning environment for my faculty. I want to develop this by using JAVA WEB START within a JNLP, as a stand-alone application (not within a web-server as in JSP or so).
    I would like to connect this application to a database server (oracle or posgres) to retrieve some data, might use also some connections to a NFS server and may use som cryptographic utilities to ensure some security on the application.
    Would anyone recommend me some IDE to develop such application? I would also ask for some ideas about the techonologies to use, since there are so many that I cannot find myself on this mess ;-)
    Thanks in advance to everyone,
    Fernando Mart�n
    [email protected]

    However, when I program in Java
    i find that most of the time I am making my variables
    global. (meaning public)Sounds like you are writing bad code. Public variables should be extrememly rare except static final 'constants'.
    Is the fact that they are in a class supposed
    to make up for that fact? Absolutely not.
    With subclasses you can also
    have 3rd parties working on your data. It seems a bit
    suspicious to me, like the data should be maintained
    more strictly, or is it my job to do that? Yes, it's your job.
    I am just
    curious, but it seems java promotes global variables,
    which I find to be bad programming practice since
    anything can operate on them. I appreciate any
    input...Java does not promote public variables. You have to explicitly make them public.

  • Question about method calling (Java 1.5.0_05)

    Imagine for example the javax.swing.border.Border hierarchy.
    I'm writing a BorderEditor for some gui builder, so I need a function that takes a Border instance and returns the Java code. Here is my first try:
    1 protected String getJavaInitializationString() {
    2     Border border = (Border)getValue();
    3     if (border == null)
    4         return "null";
    5
    6     return getCode(border);
    7 }
    8
    9 private String getCode(BevelBorder border) {...}
    10 private String getCode(EmptyBorder border) {...}
    11 private String getCode(EtchedBorder border) {...}
    12 private String getCode(LineBorder border) {...}
    13
    14 private String getCode(Border border) {
    15     throw new IllegalArgumentException("Unknown border class " + border.getClass());
    16 }This piece of code fails. Because no matter of what class is border in line 6, this call always ends in String getCode(Border border).
    So I replaced line 6 with:
    6     return getCode(border.getClass().cast(border));But with the same result. So, I try with the asSubClass() method:
    6     return getCode(Border.class.asSubClass(border.getClass()).cast(border));And the same result again! Then i try putting a concrete instance of some border, say BevelBorder:
    6     return getCode(BevelBorder.class.cast(border));Guess what! It worked! But this is like:
    6     return getCode((BevelBorder)border);And I don't want that! I want dynamic cast and correct method calling.
    After all tests, I give up and put the old trusty and nasty if..else if... else chain.
    Too bad! I'm doing some thing wrong?
    Thank in advance
    Quique.-
    PS: Sorry about my english! it's not very good! Escribo mejor en espa�ol!

    Hi, your spanish is quite good!
    getCode(...) returns the Java code for the given border.
    So getCode(BevelBorder border) returns a Java string that is something like this "new BevelBorder()".
    I want Java to resolve the method to call.
    For example: A1, A2 and A3, extends A.
    public void m(A1 a) {...}
    public void m(A2 a) {...}
    public void m(A3 a) {...}
    public void m(A a) {...}
    public void p() {
        A a = (A)getValue();
        // At this point 'a' could be instance of A1, A2 or A3.
        m(a); // I want this method call, to call the right method.
    }This did not work. So, i've used instead of m(a):
        m(a.getClass().cast(a));Didn't work either. Then:
        m(A.class.asSubClass(a.getClass()).cast(a));No luck! But:
        m(A1.class.cast(a)); // idem m((A1)a);Woks for A1!
    I don't know why m(A1.class.cast(a)) works and m(a.getClass().cast(a)) doesn't!
    thanks for replying!
    Quique

  • Question about filtering mail

    At present I tidy most of my Mail inbox automatically (mostly) by writing rules to send some posts to their respective mailboxes. These are generally routine messages that are not immediately important, but sometimes they might be important. When I first started doing this, I realised that Mail quietly filters the messages in the background and unless I opened the mailboxes to look I wouldn't know if I had received a new message. Therefore I created a smart mailbox that would show all messages for a week. I take a look every now and then.
    Because this doesn't work on iphone, and also because there is no longer the option to synch rules and mailboxes between Mail apps on different computers, I really have to consider doing my filtering on icloud.
    However, on iCloud there are no smart mailboxes. If I filter a message into a mailbox on iCloud, it'll disappear into that mailbox and I won't see it unless I search through the mailboxes. So, my question is, does anybody know of a way that one can filter messages on iCloud so that one can see easily all the messages that have arrived, in the same way that I can do with Mail? I do not want all of these messages, from various forums, shopping sites, etc, cluttering up my inbox, but I do want to be able to keep an eye on what has arrived.

    Thanks for taking the time to respond guys.  Both of your answers have been helpful.
    To clarify, I did have junk filtering on (which created a junk mailbox) and I did have the box checked to show all junk main in my regular inbox (highlighted as suspected junk).  My problem was they all were't going to my inbox at all, but straight to my junk box.  So there's a flaw with the junk mail option.  I will check all of my other devices to make sure I have the same option set for all machines though!
    Currently I have junk mail filtering off (which takes away the junk mail folder), and my question was, will I now get all mail, including junk, in my inbox.  The obvious answer seems like a yes, but I just wanted to make sure that is indeed the case as nothing in mail help says you will get all of your mail or not (wasn't sure if there's some sort of junk mail filter at the iCloud server level that would simply ignore what it thinks is junk and not even send it to me).
    Based on what you guys have said, my suspision that I will get all mail now, regardless of if it's junk or not, in my inbox, is pretty much confirmed.

  • Question about Flash and Java in OS X 10.6.6...

    I am about to get a MacBook Pro this weekend (after having numerous problems with Windows and getting it to work with my hardware - that led to me thinking of buying a Mac. Nothing to do with viruses actually ;))
    Anyhow - does Snow Leopard 10.6.6 ship with Adobe Flash, or do I need to install Flash myself? I'm not too concerned with doing that (I prefer to as I know I'm installing the latest version - just like Windows!)
    Secondly - does Apple provide updates for Java as well? Do I need to install Java myself, or does Snow Leopard ship with Java pre-installed too?
    Lastly - this is just your opinions, but which out of Safari, Chrome, Opera and FireFox do you consider to be the safest (and securest) browser for Mac?
    Thanks,
    Xavier12.

    It is best to follow Adobe's instructions for updating its software, which varies by the product & versions involved. This usually works well but Adobe is one of those companies big enough to play by its own rules, sometimes ignoring Apple's developer guidelines or inventing its own API's instead of using the Apple provided ones that do the same thing, so there is a small chance things won't go as expected even when you follow the instructions to the letter.
    If this happens it is best to seek advice on a product by product, version by version basis.

  • Question about mapping a JAVA Interface with Flex

    I am using Granite Data Services (Java backend) with my Flex
    client.
    The Java server has an Interface called
    public interface IService {String getServiceName();}
    The flex client makes a remote service call on the server
    POJO which returns any implementation of the specified interface.
    On the flex side I have an interface
    [Bindable]
    [RemoteClass(alias="com.*****.proxy.pojo.IService")]
    public interface IService{function getServiceName():String;}
    As shown i am binding it to the server interface.
    From the client I make a call to the server and handle the
    result as shown below
    var serviceInstance:IService =
    (remoteO.testInterface.lastResult as IService);
    Alert.show("Service Name :
    "+serviceInstance.getServiceName());
    The call reaches the server and the remote method is being
    called however the Alert is not working.
    Please Help !!

    //Start other thread closeT
    System.exit(0)
    //code for thread closeT
    //wait 10 s
    Runtime.getRuntime().halt()
    Gil

  • Question about Dates in java.

    Hello ,
    I have a JTextfield in a swing app. that is supposed to hold date and saves its values to a database column of Date type .
    All I want is when i get the text from the TextField to use it in the prepared statement is to be of Date type not string , and also I want the user not to be able to insert anything but date in that field , I tried this but didnt work :
    Date date = new Date(0000-00-00);
    pstmt.setDate(5, date.valueOf(itemPurchaseDate.getText()));
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException
            at java.sql.Date.valueOf(Date.java:103)
            at omsapplication.AssetsMainPanel$1.actionPerformed(AssetsMainPanel.java:104)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
            at java.awt.Component.processMouseEvent(Component.java:6216)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
            at java.awt.Component.processEvent(Component.java:5981)
            at java.awt.Container.processEvent(Container.java:2041)
            at java.awt.Component.dispatchEventImpl(Component.java:4583)
            at java.awt.Container.dispatchEventImpl(Container.java:2099)
            at java.awt.Component.dispatchEvent(Component.java:4413)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
            at java.awt.Container.dispatchEventImpl(Container.java:2085)
            at java.awt.Window.dispatchEventImpl(Window.java:2475)
            at java.awt.Component.dispatchEvent(Component.java:4413)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)Also how can I force the user to enter only dates ?
    Thanks.

    Im trying to get the the String in the TextField in order to use it in the setDate method of the Prepared Statement but there is something wrong with it :
    String DATE_FORMAT = "MM/dd/yyyy";
    sdf = new SimpleDateFormat(DATE_FORMAT);
    Date sdate = new Date();
    try{
    sdate = sdf.parse(itemPurchaseDate.getText());
    pstmt.setDate(5, sdate); //.............>>  The compiler says here : Cannot find symbol ?
    catch(ParseException pe)
    {pe.printStackTrace(); }

  • Question about filtering a file type on check in?

    I am reading on how to filter file types on check in and I was wondering.  Is it possible to check a file type and pop up a error page in iDoc, or would I have to go the custom component route (and would that need to be java or iDoc)?

    Thanks for the input, but seeing how the setting where I'm going to employ this component for UCM is secure I can't use code I can't read for myself (No offence to the author of that blog or to you).  But yeah I kinda figured making a filter based component would be the best route, but most examples I've found used the intradoc library.  Problem is I can't seem to find the intradoc library to try to write a basic example to see what I'm doing, everything I get is for RIDC (even found a small example on writing a filter for RIDC).  Is this what UCM is using now in 11g?
    Also one thing I felt missing when looking at example code, I get the basic idea of the code itself.  But to employ the componant to work on the check in request would I just include that component in that idoc function for checkin?

Maybe you are looking for

  • Inter company PO's invoice

    how the invoice works for inter-company PO's ( or STO's ) ?? Please help

  • Workbook Displays Data Not Present in the Cube for Non-Cumulative KF

    Hi All, I have a user that is reporting using noncumulative info object 0TOTALSTCK. If I look in the cube, the data starts in October and goes from there. When viewing the data, there are figures that display for the months prior to October even thou

  • Querying Data w PL/SQL - selecting 1 row

    Initial research done at: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#i45320 Querying Data with PL/SQL - Selecting At Most One Row: SELECT INTO Statement I am trying to run a simple SELECT COUNT statement in PL/SQ

  • Levels and Applets

    I'm a newbie with Flash MX2004 Pro, still in the steep part of the learning curve! 2 Questions: 1. I've got a swf file running in level0, and at one point it loads another file at level1. But the buttons on level0 are still active even if they are hi

  • Where to get a MacBook battery? *and another question

    So my used macbook 1,1 had a battery in it that was not apple brand and was getting hot and it was bulging, so i took it out and now i use it without the battery. This has got annoying because sometimes I move the cord and accidentally take it off an