How to filter using ListSelectionModel

Does anyone have any sample code for filtering selections using a ListSelectionModel?
I have a JTable, and I only want certain rows to be 'highlightable/selected" depending on what type of custom object resides in that row.
An example would be if I had a JTable that has rows containing either text files, folders, or mp3s. I only would want the rows containing text files to be highlightable/selectable.
Thank you

ok I figure it out. Here is the code for anyone interested.
public class MyTablePanel
   public static int MODE_CURRENT = 2;
   public static final int MODE_SELECT_ALL = 0;
   public static final int MODE_DESELECT_ALL = 1;
   public static final int MODE_NORMAL = 2;
   protected JTable myTable;
   public MyTablePanel(){
      myTable = new JTable();     
      // add this into your constructor
      ListSelectionModel lsm = table.getSelectionModel();
      lsm.addListSelectionListener( new MySelectionHandler() );
      table.setSelectionModel( lsm );
   public void quickTest(){      
      if ( MODE_CURRENT = MODE_SELECT_ALL){
        myTable.getSelectionModel().setSelectionInterval( 0, tab.getRowCount()-1 );
      else if ( MODE_CURRENT = MODE_DESELECT_ALL){
        myTable.getSelectionModel().clearSelection();
      else{   
   class MySelectionHandler implements ListSelectionListener {
      public void valueChanged( ListSelectionEvent e ) {
         if ( MODE_CURRENT == MODE_SELECT_ALL ) {
            System.out.println( "select all" );
            ListSelectionModel lsm = ( ListSelectionModel ) e.getSource();
            lsm.removeListSelectionListener(this);
            final MyTableModel model = ( MyTableModel ) table.getModel();
            if ( !lsm.isSelectionEmpty() ) {
               lsm.setValueIsAdjusting( true );
               int numRows = model.getRowCount();
               // get value
               // if value ends in .jpg, set to selected
               for ( int i = 0; i <= numRows; i++ ) {
                  if ( lsm.isSelectedIndex( i ) ) {
                     final String s = ( String ) model.getValueAt( i, MyTableModel.TYPE_COL );
                     System.out.println( "Selection(" + i + "): " + s );
                     if ( !s.equals( "MyCriteria" ) ) // Search for your criteria
                        lsm.removeSelectionInterval( i, i );
               lsm.setValueIsAdjusting( false );
            lsm.addListSelectionListener(this);
         else if (MODE_CURRENT == MODE_DESELECT_ALL){
            System.out.println( "deselect all" );
            ListSelectionModel lsm = ( ListSelectionModel ) e.getSource();
            lsm.clearSelection();
         else {
            System.out.println( "normal" );
         MODE_CURRENT = MODE_NORMAL; // reset after executed
}

Similar Messages

  • How to filter using bursting?

    Hi everyone,
    I'm hoping someone can help me out. I want to use the bursting engine to format report data into a PDF file if the EXCEL parameter = 'No' and into a XLS file if EXCEL = 'Yes'.
    Here is a sample of my xml that I am trying to burst on:
    <NI_IND_GLRGNL>
    <LIST_G_PARAMATERS>
    <G_PARAMATERS>
    <EXCEL>Yes</EXCEL>
    <EMAIL>[email protected]</EMAIL>
    <CONC_REQUEST_ID>44574708</CONC_REQUEST_ID>
    <REPORT_TYPE>Line Item</REPORT_TYPE>
    <CURRENCY1>AUD</CURRENCY1>
    <BALANCE_TYPE>Actual</BALANCE_TYPE>
    <PERIOD_LOW>DEC-08</PERIOD_LOW>
    <PERIOD_HIGH>JAN-09</PERIOD_HIGH>
    <ACCOUNT_LOW>75-0000-10000-000-000-000000</ACCOUNT_LOW>
    <ACCOUNT_HIGH>75-0000-11000-000-000-000000</ACCOUNT_HIGH>
    </G_PARAMATERS>
    </LIST_G_PARAMATERS>
    </NI_IND_GLRGNL>
    My bursting file currently looks like this:
    <?xml version="1.0"?>
    <xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi" type="bursting">
    <xapi:request select="/NI_IND_GLRGNL/LIST_G_PARAMETERS/G_PARAMETERS">
    <xapi:delivery>
    <xapi:email server="localhost" port="25" from="[email protected]" reply-to ="">
    <xapi:message id="123" to="${EMAIL}" bcc="" content-type="text/html" attachment="true" subject="NI India General Ledger Report"></xapi:message>
    </xapi:email>
    </xapi:delivery>
    <xapi:document output="NI_IND_GLRGNL_${CONC_REQUEST_ID}.pdf" output-type="pdf" delivery="123">
    <xapi:template type="rtf" location="xdo://NIGL.NI_IND_GLRGNL.en.US?getSource=true" filter="${EXCEL}='No'" />
    </xapi:document>
    </xapi:request>
    </xapi:requestset>
    This file sends me an email regardless of the value in the EXCEL tag. Can someone please tell me how to reference the value of the EXCEL tag properly in the filter?
    Thanks,
    Michael

    filter=".//G_PARAMETERS{Excel='Yes'}"
    Excel='Yes' should be in square bracket. I am not sure why I am unable to print this in brackets, so replace { bracket with square bracket [
    Edited by: SureshV on Apr 14, 2009 3:39 PM

  • How can I use a report as a filter that accepts a prompt value in R18?

    In R17 the following setup worked properly. 1) have a main report that uses another report as a filter report. 2) In the filter report, add a criteria statement which is prompted. 3) pass an argument from a web link or embedded web applet on the report URL using the field reference from the filter report criteria prompt. However, in R18 this no longer works. The filter report does not bring back a set of id's that is used for filtering the main report. The main report just displays all records as if there is no filter criteria supplied. Has anyone else encountered this behavior in R18?

    I'm trying to figure out how I can use a simple class
    I have written with methods and properties in Sutdio
    Creator.
    I have been looking around, but I've only found how
    to use an EJB directly from Creator. We would like to
    use a bean that handles all the connections to the
    app server and only returns the result to the JSP.
    I know there has to be a way to do this, if anybody
    has any ideas please help!I'm not sure I follow 100%, but you can use POJOs via Spring integration. Do a search on this forum for Spring and you should find a tutorial I wrote on it a while back.

  • How do i use PL/SQL function in filter operator

    Hi,
    i want to use one pl/sql function in filter operator. how do i use it in filter condition.
    error i am getting is
    " error occured during expression validatation.
    my filter condition is
    INOUTGRP1.LAST_UPDATE_DATE > "GET_LAST_UPDATE_DATE"()
    can any one suggest me what is the problem for this error.
    Regards,
    Jyothy

    I tried and getting the same error. don't know why!!
    However, There is another way of accomplishing it.
    You can add a "Mapping Input Parameter" to your mapping and in the default value field call the function "Get_Last_Update_date". Then add the output field from this operator to the filter operator. Then edit the filter condition to replace the function call with output value from the Input parameter operator.
    This should work...

  • How to filter emails using sender email adapter

    Hi,
    Does any one know how to filter emails of mail server using Sender email adapter(POP3 protocol ) in PI .
    To make it more clear let us assume that there are 10 emails in the email server then 3 emails should be fetched for Interface A , 3 emails Should be fetched for Interface B and remaining 4 emails should be ignored and left in the email server as it is ,  the reason for this is that it is not related with the Interface A or Interface B. Any suggestion or solution will be much appreciated.
    Thanks & Regards
    Prabhat

    Hi,
    I guess you didnt get my requirement clearly. My requirement is how to filter emails from email server using sender Email adapter in POP3 protocl and pass it to relevant Interface.
    For ex: suppose email no.1 is related to Interface A then it should go to Interface A
                   or         email no. 2 is related to Interface B then it should go to Interface B
                   or         if  email no. 3 is junk mail then it should avoid deleting that email and leave that email as it is
    The problem/challenge here is that email adapter of Interface A or B reads it first and deletes the email message so it is not available for the Interface A or B.
    So I just want that sender email adapter should filter it before deleting email from the email server.
    Can you provide some solution for this?
    Thanks & Regards
    Prabhat

  • How to filter Key Figures - not using the GUIDs

    An example How to filter Key Figures may look like this:
    http://XXX.com:8000/sap/bw/BEx?sap-language=DE&bsplanguage=DE&CMD=LDOC&TEMPLATE_ID=XXX&FILTER_IOBJNM=41F68RV4ZB5VYSARODYU70CAQ&FILTER_VALUE=41F68SAI18DB01DO023IR49QA
    The GUIDs consume the space in the URl. Is there a way to work with an alias.
    To use the technical name of a Key Figure defined in the Query does not work.

    Hi Cherie,
    This is exactly the type of problem that I'm currently trying to figure out. I'm trying to following your solution but I'm not clear on how you actually achieved this in you last note. I want to dynamically select actuals/budget column fields based on what period I enter. I thought about creating 12 separate RKF fields for actuals and 12 separate RKF fields for the budget reforecast and outputting these all and then doing some VBA to hide the fields not required based on which period was selected... how is your variable ZFYAPER7 defined and calculated?
    Cheers

  • How to filter values using presentation varible if it is using a multiselec

    Hi Gurus,
    Could you pls suggest me here.
    I have a requirement like my OBIEE 10G version report is not filtering the values when we select any value in Dashboard prompt.
    I tried to create a presentation varible in prompt for filtering but for prompt under control it is given an MULTI SELECT.
    i need to filter the values .now though we select any value in prompt ,it is not picking any value.
    How to filter the values using MULTI SELECT Here.Please suggest me here .
    Regards,
    SK

    Hi User,
    In, the physical layer go that column and change datatype from double to int and save the rpd.
    This should resolve your issue.
    Even, it is not required to modify or use cast function to change datatype.
    Else,
    Change the datatype of column in the Business layer.
    This should resolve your issue.
    Assign some points if this helps you :)

  • How can I use the "Correct camera distortion" filter and process multiple files in PSE 11?

    How can I use the "Correct camera distortion" filter and process multiple files in PSE 11?

    Did you check the help page for Correct Camera Distortion and Process multiple file
    Correct Camera Distortion: http://helpx.adobe.com/photoshop-elements/using/retouching-correcting.html#main-pars_headi ng_5
    Process multiple files: http://help.adobe.com/en_US/photoshopelements/using/WS287f927bd30d4b1f89cffc612e28adab65-7 fff.html#WS287f927bd30d4b1f89cffc612e28adab65-7ff6

  • Filter using 2 input images (Flash). How to implement?

    Hi. I know how to implement filters that process single image as it was described in Pixel Benders Developer's Guide, but how can I apply filter using 2 input images one of which is computed? I wrote a filter that coppies alpha channel of one picture and applies it to another, but flash implementation is quite a puzzle for me... Any help appreciated

    In our tutorial from last year's MAX, I showed how to use a two-input pixel bender kernel as a blend filter for two images on the stage. that is posted here:http://blogs.adobe.com/kevin.goldsmith/2008/12/materials_from_1.html
    In one of my recent blog postings, I showed how to use a ShaderJob with multiple inputs. I was doing it for audio processing, but it works almost identically for images: http://blogs.adobe.com/kevin.goldsmith/2009/08/pixel_bender_au.html
    Hopefully one of these should help, but if you have specific questions, don't hesitate to ask...

  • [EWS][Java] How can I use the Search Filter only mails with attachments?

    Hey,
    I'm trying to search a folder ( doesn't matter  which ) for ONLY mails with attachments.
    How can I use the search filter for that purpose? 
    Thanks!

    You can drag the attachment collumn from settings and sort on that collumn
    In the main Outlook window, on the View menu, point to
    Current View, and then click Customize Current View.
    Click Fields. In the Available fields list, click the field that you want to add, and then click
    Add.
    Come back and mark replies as answer if they help, and help others with the same problem. If this post is helpful please vote it as Helpful on the left side.

  • How to use FILTER -- USING    in rpd???

    Can we use FILTER USING in rpd ?

    Yes in the 'use existing logical columns as the source' window of a measure.
    Its under Functions - Display Functions in the expression builder.

  • How do i use my own image with keying (or green screen)

    how do i use my own image witrh keying (or green screen)

    Put your sky clip on a layer below the clip you want to key. One or the other will be a connected clip. Apply  the Keying filter to foreground clip (the one with the green screen). The green will be seen as transparent and the sky will show through as the BG. Adjust as necessary in the Inspector.
    Good luck.
    Russ

  • How do I use different Layouts?

    I am trying to make a program that runs in a window like this:
    http://www.exyt-web.com/Window.gif
    The problem I'm having is with the layout.
    How do I have more than one layout ?
    For example - as you can see in the image (hyperlink above) I wish to have a border layout with a JFrame at the North position and then in the South position I want to have buttons laid out in a FlowLayout.
    Also with my radio buttons I want these in a GridLayout(3, 0) layout.
    I made up some example code to test using different layouts - but it seems one layout always overrides the other...
    import java.awt.*;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class LayoutTest extends JFrame
        public LayoutTest()
            setTitle("Hello World");
            Container contents = getContentPane();
            Container contents2 = getContentPane();
            contents.setLayout(new FlowLayout());
            contents.add(new JLabel("<FILTER [Type a th|    ]>"));
            contents.add(contents2);
            contents.add(new JLabel("< Filter Button >"));
            contents.add(new JLabel("<  Add Button   >"));
            contents2.setLayout(new GridLayout());
            contents2.add(new JLabel("< Button 1 >"));
            contents2.add(new JLabel("< Button 2 >"));
            contents2.add(new JLabel("< Button 3 >"));
            contents2.add(new JLabel("< Button 4 >"));
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            pack();
        } // HelloWorld
        public static void main(String [] args)
            LayoutTest theLayoutTest = new LayoutTest();
            theLayoutTest.show();
        } // main
    } // class HelloWorldI know this obviously doesn't work but I hoped it would show what I was trying to do.
    I also tried creating a new 'contents2' and then adding it into 'contents'
    e.g. contents.add(contents2); My current code for the window I'm trying to create so far is:
    import java.awt.*;
    import javax.swing.*;
    public class Menus extends JFrame
        public static void Menus()
            // Creates a new JFrame, with the title specified in quotation marks.
            JFrame frame = new JFrame("Film Database");
            // Sets the default close operation of the frame.
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            // Creates a new menu bar for the frame.
            JMenuBar menuBar = new JMenuBar();
            // Creates a new menu for the menu bar.
            JMenu menu = new JMenu("File");
            addFrameContents(frame, menuBar, menu);
            // Sets the new menu bar on the frame
            frame.setJMenuBar(menuBar);
            frame.pack();
            frame.setVisible(true);
        } // HelloWorld
        public static void addFrameContents(JFrame frame, JMenuBar menuBar, JMenu menu)
            // Adds the menu to the menu bar.
            menuBar.add(menu);
            // Creates a new item for the menu with a small icon.
            JMenuItem menuLoad = new JMenuItem("Load", new ImageIcon("C:/load.gif"));
            // Adds the new item to the menu.
            menu.add(menuLoad);
            JMenuItem menuSave = new JMenuItem("Save", new ImageIcon("C:/save.gif"));
            menu.add(menuSave);
            JMenuItem menuQuit = new JMenuItem("Quit", new ImageIcon("C:/quit.gif"));
            menu.add(menuQuit);
            // Creates a new container.
            Container contents = frame.getContentPane();
            // Sets a new layout for contents, in this case FlowLayout.
            contents.setLayout(new GridLayout(2, 0));
            // Adds new JLabels to the container.
            contents.add(new JLabel("< JLabel 1 >"));
            contents.add(new JLabel("< JLabel 2 >"));
            contents.add(new JLabel("< JLabel 3 >"));
            contents.add(new JLabel("< JLabel 4 >"));
            JLabel thisLabel = new JLabel("Hello");
            thisLabel.setLayout(new FlowLayout());
            JLabel thisLabel2 = new JLabel("Hello2");
            thisLabel2.setLayout(new FlowLayout());
            contents.add(thisLabel);
            contents.add(thisLabel2);
        public static void main(String [] args)
            Menus();
        } // main
    } // class HelloWorldAny help on how I can use two separate layouts in the same frame would be great!
    Regards,
    Tom

    doing this:
    Container contents = getContentPane();
    Container contents2 = getContentPane();
    does not create 2 different containers. It's just creating 2 variables that refer to the same container. There is only 1 content pane in a window/frame. A container can only have 1 layout.
    If you want to have 2 layouts, you create 2 panels with separate layouts and put what you want in each panel, and put both panels in the content page.

  • How do I use the internal hidden column ows_LikedBy

    I am surprised there isn't much on the web about this column. I am hoping I can figure out how to filter a view where ows_LikedBy=[ME]
    So I can have a view of My Favorites setup in a report library.
    Thanks,
    Phil

    Hi Phil,
    According to your description, my understanding is that you want to filter a view where ows_LikedBy is equaled to the current user.
    You can try to create a managed property mapped to the ows_LikedBy, and use a Content Search web part to find the items then add a query variable in KQL to filter the items, like <the managed property>:{User.Name}.
    Some articles for your reference:
    http://www.sharepointnutsandbolts.com/2012/10/using-content-search-web-part-and.html (Add additional filters)
    http://technet.microsoft.com/en-us/library/jj683123(v=office.15).aspx
    http://gai3kannan.wordpress.com/2013/07/17/query-transforms-sharepoint-2013-search/
    Best Regards,
    Wendy
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Wendy Li
    TechNet Community Support

  • In BI how to filter the selection options based on inputs on top field

    Hi Friends,
    In BI, How to filter the selection options based on inputs on top field.
    The system should automatically filter the lower level drop downs based on the selection of a higher level.
    For e.g. :
    If a user selects a Country then the States drop down should only display the State's belongs to the Country. Similarly when a State is selected, the District drop down should display only those District's belongs to the State.
    Thanks in Advance.
    Regards
    Jayaram M

    Hi Anil,
    Thanks for reply but I couldn't use Compounding Characteristic here. Need some other solution.
    Regards
    Jayaram M

Maybe you are looking for