Filtering contents of JComboBox using a Renderer

Hi all,
I'm writing a Swing panel that needs to display two combo boxes (themes and sub-themes), where the contents of the sub-theme combo is dependent on the theme selected in the first combo box.
The subtheme combobox model is initialized with ALL the subthemes that can be displayed and my idea was to filter the subthemes for the selected theme within the getListCellRendererComponent() of my subtheme combo renderer.
The problem I'm having is that the renderer getListCellRendererComponent() method is called for all elements in the subtheme combobox only once, the first time the combo box is displayed. When I update the selected Theme and try to select a SubTheme, the getListCellRendererComponent() method appears to be only called for the set of SubThemes that are being displayed within the scroll area of the combo.
Is there a way to indicate that the getListCellRendererComponent() should be called for ALL elements in the combo, instead of just those that displayed within the viewable scroll area?
Or should I not be attemping to perform this filtering in the renderer class?
Thanks in advance!
public class SubThemeListCellRenderer extends BasicComboBoxRenderer
                      implements  ItemListener
     private Theme selectedTheme = null;
     private JLabel voidLabel = new JLabel();
     public SubTemaListCellRenderer(Theme theme)
          this.theme = theme;
     public Component getListCellRendererComponent(JList list, Object value,
               int index, boolean isSelected, boolean cellHasFocus)
          SubTheme subTheme = (SubTheme) value;
                // Only display subthemes associated with the selected Theme
                if ( subTheme  != null && selectedTheme != null && subTheme.getCodigoTema() == selectedTheme.getCodigo() )
                   return super.getListCellRendererComponent(list, subTheme.getDescription(), index, isSelected,cellHasFocus);
                else
                   return voidLabel;
      * (non-Javadoc)
      * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
     public void itemStateChanged(ItemEvent e)
          Object source = e.getSource();
          if (source instanceof JComboBox)
               Object selectedTheme = ((JComboBox) source).getSelectedItem();
               if (selectedTheme instanceof Theme)
                    this.theme = (Theme) selectedTheme;
     }

Thanks for your response. Actually, before I had the idea of using the renderer, I updated the combo box by doing exactly what you suggested. It worked fine, however I was recommended to move this functionality to the renderer!
After two days of struggling with this, I've reached the conclusion that this operation should not be performed in the renderer and instead by updating the underlying ComboBoxModel (removing and inserting the items as necessary).

Similar Messages

  • Filtering content in Bridge using more than one keyword.

    Hi,
    I have thousands of images in one master folder on an external hard-drive. I have applied many keywords to the images but I cannot find a way to filter the images any more than one layer deep. Some images have more than one keyword applied and I would like to be able to exclude one of those keywords from the search to reveal the other.
    For example, I have 300 images that all have the keyword "Arroway" (Arroway is the content provider FYI). 150 of these images have the keyword "Concrete" assigned, the other 150 have "wood" applied. I would like to be able to sort by Arroway, and then by material type. Is this possible?

    Not by filtering but doable with  Edit  > Find
    Or you could make a Smart Collection.

  • How to use filters on ios mobile devices (iPhone/iPad) using GPU rendering (Solved)

    Many moons ago I asked a question here on the forums about how to use filters (specifically a glow filter) on a mobile devices (specifically the iPhone) when using GPU rendering and high resolution.
    At the time, there was no answer... filters were unsupported. Period.
    Well, Thanks to a buddy of mine, this problem has been solved and I can report that I have gotten a color matrix filter for desaturation AND a glow filter working on the iPhone and the iPad using GPU rendering and high resolution.
    The solution, in a nut shell is as follows:
    1: Create your display object... ie: a sprite.
    2. Apply your filter to the sprite like you normally would.
    3. Create a new bitmapdata and then draw that display object into the bitmap data.
    4. Put the new bitmapdata into a bitmap and then put it on the stage or do what you want.
    When you draw the display object into the bitmapdata, it will draw it WITH THE FILTER!
    So even if you put your display object onto the stage, the filter will not be visible, but the new bitmapdata will!
    Here is a sample app I created and tested on the iphone and ipad
    var bm:Bitmap;
    // temp bitmap object
    var bmData:BitmapData;
    // temp bitmapData object
    var m:Matrix;
    // temp matrix object
    var gl:GlowFilter;
    // the glow filter we are going to use
    var sprGL:Sprite;
    // the source sprite we are going to apply the filter too
    var sprGL2:Sprite;
    // the sprite that will hold our final bitmapdata containing the original sprite with a filter.
    // create the filters we are going to use.
    gl = new GlowFilter(0xFF0000, 0.9, 10, 10, 5, 2, false, false);
    // create the source sprite that will use our glow filter.
    sprGL = new Sprite();
    // create a bitmap with any image from our library to place into our source sprite.
    bm = new Bitmap(new Msgbox_Background(), "auto", true);
    // add the bitmap to our source sprite.
    sprGL.addChild(bm);
    // add the glow filter to the source sprite.
    sprGL.filters = [gl];
    // create the bitmapdata that will draw our glowing sprite.
    sprGL2 = new Sprite();
    // create the bitmap data to hold our new image... remember, with glow filters, you need to add the padding for the flow manually. Should be double the blur size
    bmData = new BitmapData(sprGL.width+20, sprGL.height+20, true, 0);
    // create a matrix to translate our source image when we draw it. Should be the same as our filter blur size.
    m = new Matrix(1,0,0,1, 10, 10);
    // draw the source sprite containing the filter into our bitmap data
    bmData.draw(sprGL, m);
    // put the new bitmap data into a bitmap so we can see it on screen.
    bm = new Bitmap(bmData, "auto", true);
    // put the new bitmap into a sprite - this is just because the rest of my test app needed it, you can probably just put the bitmap right on the screen directly.
    sprGL2.addChild(bm);
    // put the source sprite with the filter on the stage. It should draw, but you will not see the filter.
    sprGL.x = 100;
    sprGL.y = 50;
    this.addChild(sprGL);
    // put the filtered sprite on the stage. it shoudl appear like the source sprite, but a little bigger (because of the glow padding)
    // and unlike the source sprite, the flow filter should acutally be visible now!
    sprGL2.x = 300;
    sprGL2.y = 50;
    this.addChild(sprGL2);

    Great stuff dave
    I currently have a slider which changes the hue of an image in a movieclip, I need it to move through he full range -180 to 180.
    I desperately need to get this working on a tablet but cant get the filters to work in GPU mode. My application works too slow in cpu mode.
    var Mcolor:AdjustColor = new AdjustColor();   //This object will hold the color properties
    var Mfilter:ColorMatrixFilter;                           //Will store the modified color filter to change the image
    var markerSli:SliderUI = new SliderUI(stage, "x", markerSli.track_mc, markerSli.slider_mc, -180, 180, 0, 1);   //using slider from http://evolve.reintroducing.com
    Mcolor.brightness = 0;  Mcolor.contrast = 0; Mcolor.hue = 0; Mcolor.saturation = 0;            // Set initial value for filter
    markerSli.addEventListener(SliderUIEvent.ON_UPDATE, markerSlider);                          // listen for slider changes
    function markerSlider($evt:SliderUIEvent):void {
        Mcolor.hue = $evt.currentValue;                        
        updateM();
    function updateM():void{
        Mfilter = new ColorMatrixFilter(Mcolor.CalculateFinalFlatArray());
        all.marker.filters = [Mfilter];
    how would I use your solution in my case
    many thanks.

  • Should the Cisco Content Engines be used as a proxy appliance

    Should the Cisco Content Engine be use as a proxy appliance like a Blue Coat appliance, Squid cache engine, ISA server, etc...
    I am pretty sure it is but just need some feedback on past experiences. Customer would like to by a Cisco product for Web filtering/proxy.
    or is it strictly used to help with web base applications.

    HI,
    the CE is basically able to check every request it supports. If you are using 3rd level products like smartfilter, websense or webwasher you can use the features of those products to supress/forbid certain requests(i.e MSN etc.)
    Kind Regards,
    Joerg

  • Filtering Content on a Page?

    Hey guys, I've found myself in a bit of a quandary.
    A client wanted me to design a responsive (Though he didn't know that was the word at the time) website for his new restaurant. He wanted the user to be able to do things such as order their food online, contact us and book the restaurant as a venue. There were other elements of course but those were the three main features he wanted.
    I accepted the job as it seemed easy enough.
    What I didn't realise though was the size of his menu. He did of course mention that he had a larger than average menu but that he managed to split it up into a "Few" different sections (Such as "Starters", "Salads", "Breads".
    It turns out that a "Few" sections turned out to be over a dozen, meaning over a hundred different pieces of food. When he told me that his menu was larger than average I thought about having the button "Order Online" on the navigation bar with a drop down menu leading to different pages, each contain one section of the menu. Of course, I can't do that when there are over 12 different sections because then it looks completely stupid.
    I now need some way to actually display it on the webpage. So I decided on like a mini navigation bar within the page itself located to the left of the main body. This navigation bar (Vertical and taking up less than a fifth of the screen) should control what is shown on the right side.
    The page itself shouldn't have to reload, rather only the small section on the right.
    Thanks for the help guys.

    ashton knight wrote:
    Hey guys, I've found myself in a bit of a quandary.
    A client wanted me to design a responsive (Though he didn't know that was the word at the time) website for his new restaurant. He wanted the user to be able to do things such as order their food online, contact us and book the restaurant as a venue. There were other elements of course but those were the three main features he wanted.
    I accepted the job as it seemed easy enough.
    What I didn't realise though was the size of his menu. He did of course mention that he had a larger than average menu but that he managed to split it up into a "Few" different sections (Such as "Starters", "Salads", "Breads".
    It turns out that a "Few" sections turned out to be over a dozen, meaning over a hundred different pieces of food. When he told me that his menu was larger than average I thought about having the button "Order Online" on the navigation bar with a drop down menu leading to different pages, each contain one section of the menu. Of course, I can't do that when there are over 12 different sections because then it looks completely stupid.
    I now need some way to actually display it on the webpage. So I decided on like a mini navigation bar within the page itself located to the left of the main body. This navigation bar (Vertical and taking up less than a fifth of the screen) should control what is shown on the right side.
    The page itself shouldn't have to reload, rather only the small section on the right.
    Thanks for the help guys.
    Humm you mention responisve. How do you propose to allocate room for these menus on small screen if you think it looks stupid on a large screen. Fair enough it looks like you have decided to have a vertcial menu to the left of the page - where are you going to put that on a small screen?
    Also I'm a bit concerned about the term 'filtering content on a page'. You may or may not be using th incorrect terminology heer which confuses people into thinking youre using a database to store the products?
    I read it as though youre just going to have a menu list down the left side of your page ie Starters, Mains, Desserts etc then you are just going to build a flat pages containing the products for each menu category and want to bring this page into the box on the right hand side of your main page onClick, but maybe not?

  • Content query webpart use a part of the URL as filter

    Hey,
    I have on root site in the site collection a list. Now I like to build up a site template (from which the user can create sub sites form the root site in the site collection.
    In this site template I like to bring on the homepage a content query webpart. The content query webpart has to show one item from the list on the start site.
    How can I configure that the content query webpart use a part of the URL as filter?
    Url is like:
    http://Server/SiteCollection/ID/home.aspx
    The ID must be the filter criterion in the content query webpart. How can I do this?
    Thanks for your help
    Stefan
    Viele Grüße Stefan
    Kontakt unter [email protected]

    Hi Stefan,
    You can create your own CQWP by subclassing the default one.
    Then you can override the CAML query to add criteria found in the URL.
    Here is more information and sample:
    http://www.andrewconnell.com/blog/archive/2008/02/18/Subclassing-the-Content-Query-Web-Part-Adding-Dynamic-Filtering.aspx
    http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx
    Regards,
    Ludovic Caffin

  • My table of contents does not use the entry style I select for words in the paragraph that have character styles applied to them in the chapter, so some of the letters are showing up as green, which is fine in the chapter but not in the TOC.

    My table of contents does not use the entry style I select for words in the paragraph that have character styles applied to them in the chapter, so some of the letters, specifically parameters, are showing up green, which is fine in the chapter but not in the TOC. I can manually fix this in the TOC by changing the character style to none after the toc  has been generated, but I don't want to do this.

    What application are you running? Please ask this in the forum of the product you're using.

  • Converting xml file with arabic content to pdf using FOP

    Hello all
    I am trying to convert a dynamically generated xml file in which most of the data comes from the oracle database with arabic content, to pdf using FOP. I have used "Windows-1256" encoding for the xml. If i open the xml generated with the internet explorer the arabic content displays properly but the pdf is not generated and the acrobat reader shows the file as corrupted or not supported. Please help me. Its very urgent.
    Thanks & Regards
    Gurpreet Singh

    There is no direct support for importing RTF from an XML extract. Perhaps feature 1514 "Mapping formatted XML data into multiline field" will be of some use. This was released in 11.0, I believe.
    Essentially you can establish paragraph and certain text formatting like bold and underline when you include the proper token information in the data. I believe this is similar to simple HTML tokens.
    Example: <FIELD><P>First paragraph of data.</P><P>New paragraph with <B><U>bold and underline text</U></B>. Rest of paragraph normal.</P></FIELD>
    The result is something like this:
    <P>First paragraph of data.</P><P>New paragraph with <B><U>bold and underline text</U></B>. Rest of paragraph normal.</P>

  • JTable Renderer-Promblem when using custom renderer

    Hi. i've just started studying Swing component.
    So i'm about to ask for help to solve the problem during using custom TableCellRenderer.
    Here is my own Renderer which extends JLable and implements TableCellRenderer
    public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected,boolean hasFocus,int row,int column)
         if (isSelected) {
         setForeground(table.getSelectionForeground());
         super.setBackground(table.getSelectionBackground());
         else {
         setForeground(table.getForeground());
         setBackground(table.getBackground());
         JLabel right=new JLabel("LEFT");
         JLabel left=new JLabel("RIGHT");
         this.setLayout(new BorderLayout());
         this.add(left,BorderLayout.WEST);
         this.add(right,BorderLayout.EAST);
         return this;
    note: There are 3 JLabel components. Two components are added to the component will be returned.
    This code works fine.
    but whenever try to resize the column display using above renderer, The " Text " runs in resizing.(making traces)
    Please anybody try to run this code, show me some solution.
    thank you

    A renderer will have its getTableCellRendererComponent method called repeatedly, every time a cell is to be repainted, and its the renderer associated with that cell. Therefore, avoid doing things in this method that should only be done once, for example:
    JLabel right=new JLabel("LEFT");
    JLabel left=new JLabel("RIGHT");
    this.setLayout(new BorderLayout());
    this.add(left,BorderLayout.WEST);
    this.add(right,BorderLayout.EAST);Can you do that in the renderer's constructor?

  • Cannot connect to camera when using gpu rendering

    Hi, anyone know why I can't connect to the camera when I use gpu rendering. I can use the camera when I use direct. Thanks!

    Is this mobile or desktop, or both? Direct is a very preferable option anyhow, FYI. It's required to use Stage3D in many engines as they make clear in all their requisites. 

  • Mass upload of contents in KM using WEBDAV

    hi all,
    plz do help me out with mass upload of contents in KM using WEBDAV .
    its urgent

    hi shailesh,
    1.If you want to transfer documents to KM,go to the folder "/documents",open its Detail dialog box.
    2.Go to Settings->Properties.Click on 'Access Links' tab.
    3.Copy the WebDAV url and paste it in your browser.Open your KM Folder as a Web Folder after authentication for your credentials is done.
    4.Copy the folders from your file system to the server just as you would copy folders in Windows File System.
    Also transfering of contents using WebDav only transfers the content,metadata is lost in the process
    Hope it helps,
    Srinath

  • Choose which content type to use in sharepoint 2013 list using InfoPath 2013

    So, in my head it seems pretty simple and a feature that might be standard to InfoPath so much in fact I can't find anything on it... My goal is to a have one list where you can do a drop down or buttons to choose which content type to use.
    I will be royally disappointed if this is not possible. =(
    So, c'mon you giants of MS Support. Give me a happy answer.

    Hi Lincoln,
    According to your description, my understanding is that you want to use multiple content types in a list.
    For achieving it, you can do as the followings:
    Open the list.
    Go to List Settings->Advanced Settings.
    Under ‘Allow management of content type’, select ‘Yes’, click OK.
    In the Content Types section, click ‘Add from existing site content types’
    Then add the content types that you want to add, click OK
    Go back to the list, click ITEMS->New Item, then all content types are displayed in the drop-down list
    When you click an item, you can select the new item is created based on one of these content types
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Dynamically load content by date using xml

    i would like to load content by date using xml. meaning if i
    have 5 upcoming social events listed, i want them to dynamically
    drop off from my webpage as the event date passes. i would like to
    use the built in spry xml dataset functionality, but don't have to.
    i can't seem to find a way to get the server date and then compare
    it to a date in a xml node. this seems simple, but i can't seem to
    find a tutorial that does not get crazy with all kinds of
    code.

    Have the column headings (which the user clicks to sort by
    that column) as
    links back to the main page, with the sort as a url parameter
    eg
    www.mysite.com/mypage.php?sort=name
    www.mysite.com/mypage.php?sort=date
    etc
    Then in your recordset, change the code from
    $sql = "SELECT * FROM table ";
    to
    switch($_GET['sort']){
    case "date":
    $sql = "SELECT * FROM table ORDER BY date DESC";
    break;
    case "name":
    $sql = "SELECT * FROM table ORDER BY name DESC";
    break;
    You`ll need to change the above to suit your needs obviously,
    but the above
    shows the principles that you need to use.
    So you use the same page for each sort, but the SQL to
    retrieve the records
    in the order you want changes dynamically.
    Gareth
    http://www.phploginsuite.co.uk/
    PHP Login Suite V2 - 34 Server Behaviors to build a complete
    Login system.

  • Regarding mass upload of contents in KM using WEBDAV

    hi all,
    plz do help me out with mass upload of contents in KM using WEBDAV .
    its urgent

    Hi,
    check this out.
    http://help.sap.com/saphelp_nw70/helpdata/en/42/e6753939033ee5e10000000a1553f7/frameset.htm
    You can install an application an upload files and folders.
    Regards
    Ismail

  • Background Rendering - Any way to curb the percentage of processor that Final Cut uses when rendering?

    When Final Cut X tires to render something on my machine it literally maxes out all 8 cores, sometimes it takes 15-20 mins to process edits I make to the frames, making my wholemachine freez up. Is there a way to cap the amount of processor the FCX is using for rendering? It wiould be ideal if I could set this at 50% or something, so i could at least work on other projects while my machine is rendering. I made global edits to the whole video I am working on that involve keying and transforms on the frames, so everytime i make an edit early on in the movie, it seems to be re-rendering the transform and key effects through the whole movie. Its a pain!
    Next time, I'm going to have to use proxy media. Hopefully that will help.

    If your system can handle native rendering, then turn off background rendering and only render when you need to.
    If you system is stuggling with native rendering, convert to Pro Res, again keeping background rendering off.

Maybe you are looking for