Icon in front of the JList items?

Hola a todos,
I am rendering a JList to a JTextArea and I want to add a icon in front of each of the items. First it can be the same icon later each one should become its own one.
I am using this little piece of code to render the JList:
JList lista_libros = new JList();
lista_libros.setCellRenderer(new mirenderer());
class mirenderer extends JTextArea implements ListCellRenderer
          public Component getListCellRendererComponent ( JList lista_libros, Object valor,
          int indice,     boolean seleccionado,boolean conFoco)
               setBorder(new BevelBorder ( BevelBorder.RAISED));
               setText (valor.toString());
               //setIcon(new ImageIcon("libro1.gif"));
               if (seleccionado)
                    setBackground (Color.blue);
                    setForeground (Color.white);
               else
                    setBackground (Color.white);
                    setForeground (Color.black);
               return this;
          } // getListCellRendererComponent()
     } // class mirenderer
When I am using a JLabel instead of a JTextArea it is easy to add an icon, but the text is to long for only one line.
Is it possible to add an icon to each item of the JList in the JTextArea?
Chao
Juergen

Or is it possible to write a JLabel over moore than only one line?
Chao
Juergen

Similar Messages

  • Itunes 11.1.3.8 shows a speaker icon in front of the seclection but it is not playing. the progress bar does not move. there are speakers attached to the system and all other programs do profuce an audio output.

    itunes 11.1.3.8 shows a speaker icon in front of the seclection but it is not playing. the progress bar does not move. there are speakers attached to the system and all other programs do profuce an audio output.

    Go to the Edit -> Preferences-> Playback
    In The bottom section of the page click the drop down menu by Play Audio Using and select Windows Audio Session or something other than "Direct sound" or whatever it displays. Click Okay. This worked for me! I hope it works for you too!
    Thanks,
    John

  • MultiLine tooltip for the JList item

    Hi,
    I did the search for the multiline tooltip in this forum and
    I found the following link which is kind of what I am looking for
    http://www.codeguru.com/java/articles/122.shtml
    Since the item tooltip string could be very long (no limit), I would like to truncate it. The line sepearator cannot be based on the \n of
    the tooltip text. I am thinking to fix size the JTextArea to: row 4
    and columan 40, and put the tooltip text into it (igoring the \n)
    with the setLineWrap(true) and setWrapStyleWord(true).
    If the JTextArea line goes more than 3, the tooltip text should only
    display the first 3 lines of the JTextArea and append "..." at the end
    of the 3rd line. Is is possible? Or someone has better idea? Or if
    there is sample code out there doing similar thing?
    Thanks,
    Pin

    why not just use html?
    return "<html> sometext<br>line2<br>line3</html>";
    Of course you'll have to manually break the line up but it's not all
    that hard to write.
    Mark

  • Custom icon per entry in the AS2 Tree Component (using CS3)

    I have a tree component that loads its data from an XML file and I wonder if I can customize every entry to have its own icon by adding an icon attribute to every entry in the XML and giving the tree an action to read that icon (which would exist in the library of the Flash file). My goal is to reproduce a tree within an application that my company is developing (it's for a training tool related to that application).
    My XML says something like <node label = 'Label' heading = 'LABEL' desc = 'Description' icon = 'icon1' />
    My label is what the tree displays, the heading is what the information dialog in the training tool displays as a title bar, the desc is what the training tool displays within the body of the text for the function description and the icon is what I want to be a reference to the graphic in the library to place as an icon in front of the item rather than use setStyle with the properties for disclosure, leaf, and folder icons.
    Is that possible? I haven't found a solution for it yet.

    I've never used the Tree component, so I'm just guessing here....
    There is a slight delay before the xml file loads and your tree has its data provider.
    Perhaps during that time there is no node at mTree.getTreeNodeAt(0) to open? Try adding this just before the last line of your code:
    trace("the node is: "+mTree.getTreeNodeAt(0));
    What do you get?
    You might need to move that code inside the xml's load event handler.
    Another thing is that the Flash components tend to work on an invalidate-then-wait-one-frame-to-redraw kind of model. So it is possible you will need to wait one frame after the xml has loaded and then tell it to open that node.
    The doLater method might help with that.
    var home:MovieClip=this;
    var xmlTreeData:XML = new XML();
    xmlTreeData.onLoad = function() {
    mTree.dataProvider = this.firstChild;
    mTree.doLater(home,"delay");
    xmlTreeData.ignoreWhite = true;
    xmlTreeData.load("xml/treeValues1.xml");
    mTree.setStyle("fontSize","11");
    mTree.setStyle("selectionColor","0xE0E0E0");
    mTree.setStyle("useRollOver",false);
    function delay(){ 

  • How do I get the website icons to be in the bookmark entry?

    The bookmark sidebar used to automatically insert the website icon in front of the bookmark entry for most sites. I upgraded to Firefox 9 and now it doesn't seem to do this even for sites that used to get the entry. How do I make the icon attach itself to the entry? Maxine r.

    A possible cause is a problem with the file places.sqlite that stores the bookmarks and the history.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.org/kb/Bookmarks+not+saved#w_places-database-file
    You can try the CheckPlaces another time after you've deleted the places files and that still didn't bring the favicons back.

  • HT204400 Light is flashing continueously on the front of the apple tv. No picture and no sound. Does anyone know what is wrong? Everything is plug in correctly. When I disconnect everything and re plug it in the apple icon comes up, but then blank screen

    Light is flashing continueously on the front of the apple tv. No picture and no sound. Does anyone know what is wrong? Everything is plug in correctly. When I disconnect everything and re plug it in the apple icon comes up, but then blank screen with no sound and no picture. Does anyone know what is wrong?
    l have an apple tv  2 generation please help me

    Welcome to the Apple Community.
    If your problem persists get yourself a micro USB cable (sold separately), you can restore your Apple TV from iTunes:
    Remove ALL cables from Apple TV. (if you don't you will not see Apple TV in the iTunes Source list)
    Connect the micro USB cable to the Apple TV and to your computer.
    Reconnect the power cable (only for Apple TV 3)
    Open iTunes.
    Select your Apple TV in the Devices list, and then click Restore.
    (You may already have a micro USB cable if you have a camera or other digital device)

  • How to understand the "New Item" icon at the bottom of the Project window

    I'm trying to understand that small "New Item" box at the bottom of the project window better. I'm aware that when I bring video clips into my project, if I drag them to this box, PPCS5 will add them to the timeline. I partially understand the positive reasons for doing so, primarily that PPCS5 will correctly identify the type of video being brought into the project. I know that if I select all my clips and drag them to the new item box, that all my clips will be added to the timeline at the same time and all together on the timeline. There are many things I don't understand about it. If I add my clips one by one using the "New Item" icon, they will show up as separate sequences on the timeline. If you try to add another clip at a later time, can that clip not be added using the "New Item" box?  One other question is what would be the advantage in putting clips on the timeline as separate sequences? And one further question is do you drag other items to this box besides video clips? Like music, and still images?

    Dragging something to the New Item icon doesn't just add that something to a sequence.  It actually creates the correct sequence for the something to be added to.
    You do this once, when you need a new sequence.  Anything else you want to add to that sequence you do by other means.

  • Is there a way of displaying  the various item in my Downloads folder as icons arranged in order of Date Created, such that the most recent items appear at the bottom, rather than the top?

    Is there a way of displaying  the various item in my Downloads folder as icons arranged in order of Date Created, such that the most recent items appear at the bottom, rather than the top? I know this can be done when they are displayed as a list, but I want icons!

    Hi geezer,
    when you open your 'Downloads' folder choose 'View'  in the Menu bar and choose:
    'as List'
    'Show View Options'
    In 'View options' window you tick:
    'Always open in list view'
    'Date Modified', or
    'Date created'
    Now inside the 'Downloads' folder click on 'Date Created' (or 'Date Modified')
    column to get items alined from oldest to newest date (or reverse)…

  • How to retain the work item in inbox of user if user press the icon cancel?

    HI,
    we  are using a text editor in approval section of workflow where the user needs to enter the reason for apporval or rejection.
    the requirement is how to retain the work item in inbox of user if user press the icon cancel? there are two icons in editor,one is ok(tick marg) and cancel(cross mark).
    so when user dont enter any text in the editor and press on cancel icon,then approval/rejection should not authorize and work item will remain in the user's inbox .unless and untill he enters the text.
    i have tried   LEAVE TO TRANSACTION 'SBWP'.leave program etc but nothing is working.
    please guide me.
    thanks
    prsahu

    Hi,
    Go with Sangvir Singh suggestion.
    It also looks neater from a Business Process Modeling perspective. You continue the process flow only when a change has occurred.
    Kind regards, Rob Dielemans

  • Clicking (and selecting) the same JList item twice

    I have a JList with items (Strings) which should be added to another String when selected (clicked on). My problem is that when a user clicks twice on the same item it should be added to the result String twice. But a ListSelectionListener acts only when the value has changed, so when an other item is selected.
    Does anyone know a neat (as high level as possible) solution for this?
    P.S.: How do you assign duke dollars to a topic? And how do you give someone who replies those?

    Thanks. I also already thought of adding a MouseListener, but I kind of wanted to avoid it. But it seems that it is necessary if I want to keep the selection.
    The solution I have now, by the way, is that I set the selectedIndex back to -1 in valueChanged, so there is never any item selected.

  • Why do the dock items do not enlarge when I position over the icon?

    Why do the dock items do not enlarge when I position over the icon?

    Go to system preferences, click on Dock and then make sure magnification is ticked and the slider bar next to it isnt on minimun.

  • Changing JList non-editable Font color of the selected items

    Hi All,
    I want to change the font color of non-editable JList's selected items which is not clearly visible to user. And I need to change the font color only the selected item in this scenerio.
    Could you please clarify me?
    <img src="file:///C:/DOCUME~1/sgnanasi/LOCALS~1/Temp/moz-screenshot-4.png" alt="" />

    [email protected] wrote:
    ..I want to change the font color of non-editable JList's selected items which is not clearly visible to user. And I need to change the font color only the selected item in this scenerio.Set a custom [cell renderer|http://java.sun.com/javase/6/docs/api/javax/swing/ListCellRenderer.html] *(<- link)* for the JList.

  • HT4623 My app icon shown i have 11 items waiting for updating. But the update is blank. I try to reset, switch my ipad off and reboot it, sync my ipad the 11 items still remain. Can someone please advise me how to clean this up.?

    My ipad 2 app icon show I have 11 items need updating but there is nothing on the app update page. I tried all method to reset my ipad, sycnc my iTunes with ipad connected, reset my ipad but not successful. The 11 items still appear on my app icon. Can someone help me?

    The update server is down; try this temporary workaround
    App Store>Purchased>Select "All"
    Note: Look out for apps that have the word "Update"
    http://i1224.photobucket.com/albums/ee374/Diavonex/9c256282736869f322d4b3071bbb2 a82_zps51a6f546.jpg

  • How do we delete an icon from the front of the pod touch

    I have icons filled on my iPOD touch and want to delete a couple of them How do I do this

    You do realize that you have multiple screens on which to place apps (along with their icons) don't you? To do so, touch & hold an icon until they all start to wiggle. You can then touch and drag the icon/app that you want to move to the right edge of the screen. The screen will slide to a new empty screen which you can now release/drop the icon onto. To simply delete the icon/app, touch & hold the icons until they wiggle, then click the x on the desired icon/app to delete it. To return the touch to standard operation, press the home button.

  • How to center JList  items

    Hi,
    I want to center my Jlist item instead of leave them in the left like usual. My List contains pictures and for the beauty of the design it's better to have the image in the center of each cells. How to do it?
    thanks.

    Do you know how to make a JLabel which contains a centred icon? Now make a ListCellRenderer that uses one of those to render your images in the JList.

Maybe you are looking for

  • OTF/PS fonts have recently stopped rendering in Flash Pro CS3 on Windows 7/64

    Recently, a number of my OTF/PS fonts have stopped rendering when used in Flash Pro CS3. The fonts appear in the fonts menu, render properly in the font preview popup in the font menu, but the fonts fail to render on stage when used, with certain exc

  • Reg Global Variable in PI 7.1

    Dear All We have a scenario where we need to validate contents of variuos fields in an xml file. As the validations are complex we want to store the exceptions inside a global variable so that all the exceptions can be segregated at a single point. C

  • DVI to RCA cable

    Anyone know where I can get hold of a cable for my MacBook Pro (circa 2005) with a DVI port so I can see the output on my TV?

  • How to Embed an SVG From HTTPService?

    Hi,   My SVG file is the ouput generated from a PHP file, because I am trying to use the PHP with parameters that allows me to have further customizations. After reading some of the tutorials on http://www.adobe.com/devnet/flex/quickstart/embedding_a

  • JAVA Builder

    Does Java Builder let you drag and drop objects like visual Basic ?