Images like items of Jlist.

Salut,
I would like to make a Jlist who will have images(small size) like items instead of the usual string.
All of your help and advices are welcome.Thanks.

In The API for JList check out:
public void setCellRenderer(ListCellRenderer cellRenderer)also check out
javax.swing
Interface ListCellRenderer
here is a rather dud one I was using:
public class PicListCellRenderer extends JLabel implements ListCellRenderer
     final ImageIcon picIcon = new ImageIcon(this.getClass().getResource("images/Pic16.jpg"));
     final ImageIcon selectedIcon = new ImageIcon(this.getClass().getResource("images/GirlD16.jpg"));
     public Component getListCellRendererComponent( JList list,
                                   Object value,            // value to display
                                   int index,               // cell index
                                   boolean isSelected,      // is the cell selected
                                   boolean cellHasFocus         // the list and the cell have the focus
          String s = value.toString();
          setText(s);
          if( isSelected )
               this.setIcon( selectedIcon );
          else
               this.setIcon( picIcon );
          if (isSelected)
               setBackground(list.getSelectionBackground());
                 setForeground(list.getSelectionForeground());
          else
               setBackground(list.getBackground());
               setForeground(list.getForeground());
          setEnabled(list.isEnabled());
          setFont(list.getFont());
          setOpaque(true);
          return this;          
}Kind of Dud only has 2 Pics, but I guess it shows the idea
then have:
JList Fred = new JList();
Fred.setCellRenderer(new MyListCellRenderer());You can do all sorts of things with these.
I don't think you could just set the ListItems to Images, but here I set them to a JLabel with an ImageIcon on it...

Similar Messages

  • I updated from Windows 8.0 to Windows 8.1 and ever since Firefox has run somewhat strangely. In particular when on sites with a lot of images like Facebook,etc

    Hello, I am writing as I am experiencing some issues with my favorite web browser after updating to Windows 8.1. Here are some details. I updated from Windows 8.0 to Windows 8.1 and ever since Firefox has run somewhat strangely. In particular when on sites with a lot of images like Facebook. It is like there is some kind of Flikr effect between the desktop and the images and between the images and the browser (almost like old 16 bit video games flikering). It is not too bad but it is an issue. I have tried resetting firefox and restarting the computer. I haven't tried a repair, and I haven't done an uninstall yet.

    thank you for helping, the issue seems to have been caused by the hardware accelerator

  • How to create report image like artwork demo

    Dear Pakars
    How to create report image like artwork demo ?
    Thanks
    Imansyah

    Hello,
    Are you asking how to include images in a report? If so, take a look at the declarative blob support documentation -
    http://www.oracle.com/technology/obe/apex/apex31nf/apex31blob.htm
    Hope this helps,
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • How do I create an image like this?

    Completely new to PS. How would I create an image like this with text? https://www.facebook.com/photo.php?fbid=10151570901245020&set=pb.50687255019.-2207520000.1 366989903.&type=3&theater
    A link to a tutorial would be helpful.
    Thanks!

    Hi there,
    Are you referring to the text, the color effect, or both?
    Adding type is very easy - just grab the Type Tool from the tool bar. The article linked above provides some great tips for editing type in Photoshop.
    As is the case with many "how to's" for Photoshop, there are several ways to acheive the colorized effect like the one applied to image you linked to. One method is to use Adjustment Layers, which I have outlined below.
    1. With your image layer active (it will be highlighted in blue in your Layers panel, as shown below), create a selection of the area you'd like to colorize. I'm using the Polygonal Lasso Tool to create a diagonal selection - to do so, I held down the Shift key on my keyboard as a created my diagonal lines. This might take a bit of practice, but you'll get the hang of it quickly.
    2. Then, in your Adjustments panel (if you don't see it, go to Window > Adjustments), click on the Curves adjustment layer, as highlighted below. Now you can play around with the curves to get the effect you'd like. (Here's a quick guide on using the Curve tool)
    3. To select the other areas of your image, command (Mac) / control (PC) click on the adjustment layer thumbnail (highlighted below). Then, go to Select > Inverse.
    4. Now we want to deselect part of our selection. Grab the Quick Selection Tool from the toolbar and set it to Subract from selection. Then, simply drag the selection brush over the area you want to deselect. In my case, I only want to have the upper-left corner of my image selected.
    5. After you have your selection, click on the image layer and add a Curves adjustment layer like before.
    6. Repeat steps 3-5 for the other corner of your image and you should end up with something like this:
    The nice thing about using adjustment layers is that you can always change them - just double click on the Adjustment layer thumbnail (highlighted in step 3).
    Alternatively, you can select areas of your image and fill the selections with flat colors on separate layers. You can then go in a change the Blend Mode and Opacity for each layer.
    Feel free to reply with any questions!
    Kendall

  • How can I save my images like a "wedding photographer" does?

    I have a Pixma PRO-100. . . with a Windows 8.1 PC. . . and printing through Adobe Photoshop Elements 11.
    I just printed some wedding pictures of my daughter - which I got from the "wedding photographer"... when I printed them - they were an exact match to what I saw on my screen (which I've calibrated)... and dead on crisp, great quality.
    I'm wondering what a wedding photographer does to their images to make them so "solid" in printing.  How do they save them?
    when I print something from a my files, (Raw, NEF, or JPEG's) - there always seems to be a color or quality problem? Never a match.  It takes several adjustments and print samples before I get what I want. 
    Is the ICC Profile a problem - or How can I save my images like a wedding photog does?  So they print exact?
    Joe B

    " ... (Raw, NEF, or JPEG's) ... "
    I suspect there are some minor differences you are not seeing and/or noticing on screen.  But right off, no real wedding photographer will shoot in anything except RAW.  You should be using RAW, only, too.  The RAW file to start with has way more info in it than any jpeg does.
    Next I would bet your wedding photographer does some tweaking to highlights and shadows, plus s ome other stuff that you are not.  In other words he is getting the photos ready for printing. Remember printing on paper and "printing for on screen" is two different things.
    EOS 1Ds Mk III, EOS 1D Mk IV, EF 50mm f1.2 L, EF 24-70mm f2.8 L,
    EF 85mm f1.2 L II USM, EF 70-200mm f2.8 L IS II,
    Sigma 120-300mm f2.8 EX APO, Photoshop CS6, ACR 9, Lightroom 6

  • Cant delete or add item to Jlist as nthing happens

    Hi all,
    regarding the first part where pass of string array into object array. I have done it (thanks again for the help). But regarding the add and remove elements from the Jlist cant be done.. below is my code for the delete button when press. I cast it into int for the ManualList.getSelectedIndex();(at part A) but cant display and keep having a error call
    java.lang.NullPointerException at ManualChange&ValueReporter.valueChanged
    code for value reporter is at part B
    Part A
    private void deleteMouseClicked(MouseEvent e)
    int n =(int)ManualList.getSelectedIndex();
    if (!(n < 0) || (n > listModel.size()))
    listModel.remove(n);
    delete.setEnabled(false);
    ManualList.repaint();
    ManualList.revalidate();
    Part B
    private class ValueReporter implements ListSelectionListener {
    public void valueChanged(ListSelectionEvent event) {
    // if (!event.getValueIsAdjusting())
    // gettext.setText(ManualList.getSelectedValue().toString());
    ManualList.repaint();
    ManualList.revalidate();
    Any help is greatly appreciated.
    alright, i redo part A the code is shown below but i still cant get the display out.
    Is there some problem in my code? or is the repaint and revalidate thing wrong usage here ? Need help regarding this. Thanks
    int n =ManualList.getSelectedIndex();
    if (!(n < 0) || (n > listModel.size()))
    listModel.removeElement(arrayObject[n]);
    delete.setEnabled(false);
    ManualList.repaint();
    ManualList.revalidate();

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.event.MouseEvent.*;
    import javax.swing.event.*;
    import java.io.*;
    import javax.swing.DefaultListModel.*;
    import java.util.Properties;
    import java.util.ArrayList;
        public class smallProgram extends JFrame //implements ListSelectionListener
            JPanel p;
        private DefaultListModel listModel;
         JLabel ManualJob = new JLabel();
         JTextField gettext  = new JTextField();
         JScrollPane scrollPane1 = new JScrollPane();
         JButton okButton = new JButton();
         JButton cancelButton = new JButton();
         JButton add = new JButton();
         JButton delete = new JButton();
         JList ManualList;
         int tokenNo;
         String real,ss;
         String[] values;
         Object[] arrayObject;
         java.util.StringTokenizer tokenizer;
         BufferedReader in;
         ArrayList data;
         public static void main(String args[])
             new smallProgram();
          public smallProgram()
                setTitle("Small Program");
                p = (JPanel) this.getContentPane();
                p.setLayout(null);
                setSize(515, 585);
                setVisible(true);
               //---- ManualJob ----
               ManualJob.setText("Manual Jobs Classification");
               ManualJob.setFont(new Font("Times New Roman", Font.BOLD, 14));
               p.add(ManualJob);
               ManualJob.setBounds(10, 435, 190, 35);
               setVisible(true);
               //---- gettext ----
               gettext.setFont(new Font("Times New Roman", Font.PLAIN, 12));
               p.add(gettext);
               gettext.setBounds(365, 435, 115, 25);
               setVisible(true);
               //Buttons for add, del, ok and cancel
               //---- Add ----
               add.setText("Add");
               add.addMouseListener(new MouseAdapter() {
                   @Override
                   public void mouseClicked(MouseEvent e) {
                       addMouseClicked(e);
               p.add(add);
               add.setBounds(355, 485, 60, add.getPreferredSize().height);
              //---- delete ----
               delete.setText("Delete");
               delete.addMouseListener(new MouseAdapter() {
                   @Override
                   public void mouseClicked(MouseEvent e) {
                       deleteMouseClicked(e);
               p.add(delete);
               delete.setBounds(new Rectangle(new Point(430, 485), delete.getPreferredSize()));
               //---- okButton ----
               okButton.setText("OK");
               okButton.addMouseListener(new MouseAdapter() {
                   @Override
                   public void mouseClicked(MouseEvent e) {
                       okButtonMouseClicked(e);
               p.add(okButton);
               okButton.setBounds(335, 520, 75, okButton.getPreferredSize().height);
               //---- cancelButton ----
               cancelButton.setText("Cancel");
               cancelButton.addMouseListener(new MouseAdapter() {
                   @Override
                   public void mouseClicked(MouseEvent e) {
                       cancelButtonMouseClicked(e);
               p.add(cancelButton);
               cancelButton.setBounds(420, 520, 75, cancelButton.getPreferredSize().height);
               ss = ("test1,test2,test3,test4,test5"); //My string ss
               int length = ss.length();
               int asd = (ss.indexOf('_'))+1;
               real = ss.substring(asd, length);
               tokenizer = new java.util.StringTokenizer(real,",");
               tokenNo = tokenizer.countTokens();
               data = new ArrayList();
               values = new String [tokenNo];
    //           Object[] arrayObject = data.toArray();// this is my initial code where arraylist is pass to object
                   for(int i =0; i< tokenNo; i++)   // pass string-ss into arraylist individually
                    data.add((tokenizer.nextToken(",")));
                    //values[i] = tokenizer.nextToken(",");
                    data.trimToSize();
                    //System.out.println("tokenizer"  + values);
    int aaaa = data.size();
    System.out.println("size " + aaaa);
    System.out.println("tokenizer" + tokenNo);
    System.out.println("arraylist "+ i + data.get(i));
    //JLIST
    //======== scrollPane1 ========
    //---- ManualList ---- This is my Jlist // copy arraylist into Object[] then pass it into JList
    listModel = new DefaultListModel();
    /* listModel = new DefaultListModel(); Part A also continue from above
    * for (int i = 0; i< arrayObject.length;i ++)
    * listModel.addElement(objectArray[i].toString());
    * JList ManualList = new JList(listModel); //tried using listModel.method() to remove item in Jlist but return nullException
    arrayObject = data.toArray();
    JList ManualList=new JList(arrayObject);
    ManualList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ManualList.setSelectedIndex(0);
    ManualList.setVisibleRowCount(5);
    ManualList.setFont(new Font("Times New Roman", Font.PLAIN,12));
    ManualList.setBorder(new MatteBorder(1, 1, 1, 1,Color.black));
    ManualList.setLayoutOrientation(JList.VERTICAL_WRAP);
    values = new String[tokenNo];
    ManualList.addListSelectionListener(new ValueReporter());
    // JScrollPane listPanel = new JScrollPane(ManualList);
    scrollPane1.setViewportView(ManualList);
    p.add(scrollPane1);
    scrollPane1.setBounds(210, 435, 130, 75);
    setVisible(true);
    { // compute preferred size
    Dimension preferredSize = new Dimension();
    for(int i = 0; i < p.getComponentCount(); i++) {
    Rectangle bounds = p.getComponent(i).getBounds();
    preferredSize.width = Math.max(bounds.x + bounds.width,preferredSize.width);
    preferredSize.height = Math.max(bounds.y +bounds.height, preferredSize.height);
    Insets insets = p.getInsets();
    preferredSize.width += insets.right;
    preferredSize.height += insets.bottom;
    p.setMinimumSize(preferredSize);
    p.setPreferredSize(preferredSize);
    private void addMouseClicked(MouseEvent e)
    private void deleteMouseClicked(MouseEvent e) //nthing happen here
    int n =ManualList.getSelectedIndex();
    if (!(n < 0) || (n > listModel.size()))
    listModel.removeElement(arrayObject[n]);
    delete.setEnabled(false);
    ManualList.repaint();
    ManualList.revalidate();
    /* int n =ManualList.getSelectedIndex(); //tried using this but failed
    if (!(n < 0) || (n > listModel.size()))
    listModel.remove(n);
    delete.setEnabled(false);
    ManualList.repaint();
    ManualList.revalidate();
    private void okButtonMouseClicked(MouseEvent e) {
    private void cancelButtonMouseClicked(MouseEvent e) {
    private class ValueReporter implements ListSelectionListener {
    public void valueChanged(ListSelectionEvent event) {
    // if (!event.getValueIsAdjusting())
    // gettext.setText(ManualList.getSelectedValue().toString());
    //String name=(String) ManualList.getSelectedValue();
    //System.out.println(name);
    private void ManualListMouseClicked(MouseEvent e) {
    // int n = (int)ManualList.getSelectedIndex();
    // if (!(n < 0) || (n > listModel.size()))
    // delete.setEnabled(true);
    ok this is a small complete program
    Thanks for the time to read this

  • And another issue - using : column like :item in a select in a cursor

    i use column like :item frequently but now i'm thinking that it slows down the select making it run much more slowly . any suggestions or documentation I might use ? Do you think that it would be better to use column = :item or not to use :item at all ? Thanks a lot !

    Like in Select is used as
    WHERE col1 LIKE 'aaa%'
    and disable the index on col1 (Sure exists Index-Function)
    as it's better writing
    WHERE account_name LIKE 'CAPITAL%'in comparison to
    WHERE SUBSTR(account_name,1,7) = 'CAPITAL'Sure is better if you can use col1 = :item but I don't know your goal.
    Regards

  • Email Link... and Email Image menu items don't work.

    Suddenly, about a week ago, the Email Link... and Email Image menu items stopped working. Problem seems to be on only one login on one of my three machines. The rest seem to be OK.
    Using FF 19.0 and TB 17.0.3 under Windows 7.
    Any ideas?

    Thank you. Although I had already checked the MailTo: application and found it set to "Use Thunderbird (default)", clearing that association and setting it to "Always Ask" jarred things loose. When I set it back to T-Bird, it worked again.
    Again, thanks for the nudge.

  • Image in Item master

    Hi,
    Is there any way to print the image of item in item master data. This is requirement of client so that he can print image of item on paper and present it to their customers. Any solution pls suggest.
    Regards
    swapnil

    Thanks for the reply
    Hi
    In our Item master, each item has an drawing  of the respective item which is attached to these items in master with help of image file.
    Our client normaly uses prinout of this drawing when they give quotation to their customers.
    what i want to know is whether it is possible to take prinout of the image (Pls note i want print out of the image only and not screen of item master) from item master itself.
    If no is there any other way to handle this....? As you said about PLD is it possible to manage only the image in PLD may be on the second page.......
    Pls guide.
    Thanks
    swapnil

  • A quick way to set different color for certain items in JList?

    is there a quick way of setting different color for certain items in JList?

    Either use HTML strings as the values in your JList (quickest, but may not be the most convenient, especially if your model isn't just text), or create your own ListCellRenderer (e.g. extend DefaultListCellRenderer).
    There is no such thing as "list.setItemForeground(int index, Color c)". You'll have to use one of the methods above.

  • How can I make a image like this one? (image in description)

    Hi guys I need to know how can I make a image like this one http://img31.imageshack.us/img31/2710/69823211.gif
    I need step by step instructions please. How can I animate it like that? Whats the font? Tell me everything please.

    To do a step by step instruction on here will take someone a very long time, as you havent really said at what level you are at.
    On Youtube there are a lot of animation tutorials for PS. But essentially in this case you are moving that white streak across a few frames at a time.
    The font might be found with the help of http://http://www.myfonts.com/WhatTheFont/

  • Two checkboxes to each item of JList

    I want to take two checkboxes to each item of Jlist
    and depending upon the checkbox state i want to add
    that item in a defferent Jlist

    You don't need any invisible nodes for that. Just create a class that can hold both the id and name, and which will return the name from the toString() method:
    public class Pair {
      private String id;
      private String name;
      public Pair(String i, String n) {
        id = i;
        name = n;
      public String getId() { return id; }
      public String getName() { return name; }
      public String toString() { return getName(); } // used by JTree to display the name
    }Of course, id and name can be other objects than Strings.

  • I updated to Photoshop cc 2014 and now can't resize the images like I used to.

    I updated to Photoshop cc 2014 and now can't resize the images like I used to. 
    I used to click on the image and then go to the corner hold down shift and resize it.  Now it won't do it.
    How do I do it now? 
    I have a project deadline and need to do this asap.  Panicking that I won't meet my deadline.

    Did you turn off the "show transform controls" option in the move tool?
    It sounds like you were using that previously.
    And you can always transform by using the Free Transform command (command/control T).

  • How I can put an image like a intro for a gallery?

    I see a books with an image like a intro for a gallery or for a widget, example, in an page there is a imagen, I tap in the image and an gallery opens, how I can make this in my book? How I can put an image and when I tap in the image a gallery opens or a widget opens?

    Hello Apple 4r1
    You could do this in Keynote I am sure.
    Create a simple two page Keynote document.
    The first slide will have the "INTRO Image" once press this slide can then automatically open up the second slide with a transition automatically.The second slide can hold all the images on the one page and just play over time each image for a set amount of time each before end of time.
    I hope that helps some what.
    Another great little piece of software that builds widgets that can be used within iBooks Author is Hype from the app store.
    Regards,
    Nigel

  • Make an image like this

    Hey guys how do I make an image like this:
    Note how it is dark on one side and then lightens on the other side. I have Fireworks 8.

    OK I did that but the gradient is going sideways, not up and down:
    How do I fix this?

Maybe you are looking for

  • CAN NOT OPEN EOS20D  FILE

    HAVE PHOTSHOP CS2. IN PAST NO PROBLEM OPENING CANON EOS20D FILE. PROBLEM WITH PC AND HAD TO REINSTAL VIA ADOBE WEBSITE. NOW CAN NOT OPEN FILE. DOES NOT RECOGNIZE

  • Committed Spend / Quantity

    Hi The following fields are being populated in the detail layer  and are not mapped to the reporting layer in the standard transformation but the fields are being used in the reports 0XSASPNACOM     Committed Spend Amount 0XSASPNQCOM     Committed Sp

  • User name and Password for Actions

    Dear Friends i am working with IDES 6.0 , while performing Hiring action, for every infotype after enter data, sys prompting for USER name and Password, only after providing User name and Password  sys is going for the next infotype to my knowledge s

  • How do you get page tabs to automatically delete when you close Firefox. I now have to manally delete all of them - dozen of them!

    Each web page I go to leaves a tab at the top of the page above the website. They stay there until I manually delete them. My previous computer automatically shut them when I closed the home page

  • Problem in BAPI GOODSMVT CREATE OIL

    Dear Abapers, I have developed an ZFunction Module for to do posting 102 Movt type.An ABAP Dump is encountered when doing the negative subsequent adjustment via the Z function module. The dump only happens when BAPI_GOODSMVT_CREATE_OIL is called Afte