JList not showing elements

Hi To all,
I am trying to get elements in a JList.All the things are going right but in the application it is not showing any data.
my code is like ...
JList jlist=new JList();
while(---code---)
//some code
Vector datalist = new Vector();
String fname=f.getName();
for(int i=0;(i<datalist.size());i++)
datalist.add(fname);
jlist.setListData(datalist);
System.out.println(datalist);
it is showing all names in dos prompt through System.out.println()..
but not through jlist.
Any help please
Thanks in advance

I'm having a problem with JList (it's not showing the
elements added to the List).
i've checked the forum, but couldn't found the answer
to my problem. Any suggestion on the forum search
keyword?
here's my code
public class TestClass extends JFrame{
public static void main(String args[]){
JFrame fra = new MyClass();
fra.show();
public class MyClass{
private JList list;
public MyClass(){
setSize(400,300);  
list = new JList();
JSplitPane split = new
ew JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
new JScrollPane(tree),
new JScrollPane(fileList));
ContentPane c = getContentPane(c);
c.add(split);
} // end of constructor
public populateListAtRunTime(){
DefaultListModel listModel = new
ew DefaultListModel();
listModel.addElement("Testing 1");
listModel.addElement("Testing 2");
list = new JList(listModel);/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With this line you are not changing the
list you have already added to the SplitPane
(I think it is already added before this gets
called, you never show the relationship of this
method to the constructor...), instead, you are
creating a new JList which you never add to
anywhere. Is there a way to instead add elements
to the JList's data model instead of creating a new
one? Something like this:
DefaultTableModel listModel = list.getListModel(); //Or something like it...
listModel.addElement(//...);
list.revalidate();
} // end of myClass (inner class)
The tree showed up in the split pane
And i think the list also showed up on the splitpane
also (except that the element value is not
there)...any clue on why this is happening?
sorry again..i know this topic must have been posted
numerous time, but i'm bad with search term
keyword..and did not find any result that come close
to my match
I tried JList + visible, JList + show, and a few
other

Similar Messages

  • JList not showing images

    Have raised a thread giving details of the problem in Java2D forum
    JList not showing images
    Have anybody experienced this issue? I face this issue only when i use swingworker and only for small images (few kBs). It works fine for large images (More than 1MB files). I use Win 7.
    Regards,
    Sreram

    One, do you say because i set the model each time, sometimes the list is not getting repainted? I didn't say that. It's just good concurrency practice to only manipulate models on the EDT, particularly when SwingWorker easily allows the break up of loading the images in a background thread and updating the model on the EDT through the publish/process methods.
    Will the splitting up of worker as process chunks be of any use? Again it's just a good habit to get into for concurrency reasons.
    As for your repainting issue, try changing this line
    item.setImage(getImagefromFile(f)); to
    item.setImage(new ImageIcon(getImageFromFile(f)).getImage()); The ImageIcon class uses MediaTracker to synchronously load images (you can use your own if you want). If you're getting your images via the Toolkit.createImage# methods, then the images need to be loaded. Usually what happens is the toolkit image will get loaded when first drawn. The component that's doing the drawing gets repainted as more of the image comes in. But in the case of a JList, that component is the cell renderer pane and it doesn't care about repaint() calls. So changing the above line will insure the images are already loaded and ready to draw when first shown. tjacobs01 post reminded me of this.

  • Itunes not showing elements 11 drop down list of albums and won't sync, says ïtunes cannot sync, required folder cannot be found. ï have tried re installing both but no success. pls help!!!

    Hi, Itunes won't sync my photos to ipad from elements 11. itunes doesn't show drop down list of albums and says Ipad "......cannot be synced, required folder cannot be found" i have tried re installing both programs but no luck. pls help!!!

    I managed to finally fix the problem in a relatively painless way. It turned out that the problem wasn't on my phone, the problem was with iTunes. I completely uninstalled iTunes from my PC and then reinstalled it and everything was fine.
    In order to completely uninstall iTunes, I did two things:
    Used RevoUninstaller to uninstall iTunes. This cleans out a bunch of extra things that the normal iTunes uninstaller misses.
    Searched for any iTunes folders/files on my computer (using the freeware utility called Everything) and deleted them manually.
    I hope that works for you.

  • JList not showing up

    I'm overlooking something stupid and just need a different pair of eyes to see what I'm missing.
    I've made a DefaultListModel and populated it.
    I created a JList, passing the Model as a parameter.
    I created a JScrollPane, passing my JList, and setting scroll bar options.
    I added my scroll pane to my frame.
    My frame is visible.
    public class ListTest extends JFrame {
         public ListTest() {
            super("NewClass");
            SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI();     }});
         public void createAndShowGUI() {
            DefaultListModel modelScript = new DefaultListModel();
            modelScript.addElement("BLAH");
            JList listScript = new JList(modelScript);
            listScript.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            listScript.setLayoutOrientation(JList.VERTICAL);
            JScrollPane panScript= new JScrollPane(listScript, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                               JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            add(panScript);
            setVisible(true);
         public static void main(String[] listArgs) {
            ListTest oListTest = new ListTest();
    }Edited by: porpoisepower on Mar 5, 2010 9:20 AM

    well pack() fixed my sample!
    but not my actual code :(
    So here's some of my non-sample code.
    I can make out a bevel on the right side of the frame, as if the ListBox was 0 wide.
        private void createAndShowGUI() {
            JPanel panTree;
            JPanel panScript;
            boolSystemTheme  = true;  // I know this looks stupid.
            if (boolSystemTheme) {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                catch (Exception e) {
                    System.err.println("Couldn't use system look and feel.");
            txtResults = new JTextArea(8,15);
            frameMain = new JFrame("DynaRhino - Development");
            panTree = new JPanel();
            panTree.setLayout(new BorderLayout());
            panTree.add(initTree(), BorderLayout.CENTER); // Not included code returns a JScrollPane with a tree control
            panTree.add(initToolBar(),BorderLayout.NORTH); // Not included code returns a JToolBar
            panScript = new JPanel();
            panScript.setLayout(new BorderLayout());
            panScript.add(initScriptQueue(),BorderLayout.CENTER);
            frameMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frameMain.setSize (450,700);
            frameMain.setLayout(new BorderLayout());
            frameMain.add(initResults(),BorderLayout.SOUTH);
            frameMain.add(panTree,BorderLayout.WEST);
            frameMain.add(panScript,BorderLayout.EAST);
            frameMain.setLocationRelativeTo(null);
            frameMain.setVisible(true);
        private JScrollPane initScriptQueue() {
            DefaultListModel modelScript = new DefaultListModel();
            modelScript.addElement("Ping Client");
            JList listScript = new JList(modelScript);
            listScript.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            listScript.setLayoutOrientation(JList.VERTICAL);
            JScrollPane panScript= new JScrollPane();
            panScript.add(listScript);
            return panScript;
        }Edited by: porpoisepower on Mar 5, 2010 10:35 AM
    added comment regarding boolSystemTheme

  • Not showing element

    hi there - id appreciate if anyone can reply to me tonight as i have revision to do for this exam
    im tryin to see whats in the element but it gives me memory address ref's..why?
    //Main
         public static void main(String[] args)
              Object data1 = new Student("Fred", "Engineering", 123);
              Object data2 = new Student("Ahmed", "Engineering", 456);
              Object data3 = new Student("john", "Computing", 789);     
              ChainNode c1 = new ChainNode(data1, null);
              ChainNode c2 = new ChainNode(data1, c1);
              ChainNode c3 = new ChainNode(data1, c2);
              ConsoleIO.out.println(" " + c3);
         }     //this is ChainNode
    import textio.*;
    import java.util.*;
    public class ChainNode
         private Object element;
         private ChainNode next;
         public ChainNode(Object element, ChainNode next)
              this.element = element;
              this.next = next;
         public String toString()
              return new String("Node = " + element);
    }//this is student
    import textio.*;
    import java.util.*;
    public class Student implements java.lang.Comparable
         public Student(String aName, String aCourse, int matric)
              theName = aName;
              theCourse = aCourse;
              theMatric = matric;
        public final boolean    equals(Object obj) {  
            return this.compareTo(obj) == 0;
        public final int    compareTo(Object obj) {   
            int parMatric = ((Student)obj).getMatricNumber();
            int result = 0;
            if(theMatric < parMatric)
                 result = -1;
            else if(theMatric == parMatric)
                 result = 0;
            else
                  result = 1;
            return result;
        }    // method: compareTo
         public int getMatricNumber()
              return theMatric;
        public int    hashCode() {   
            Integer theMatNum = new Integer(theMatric);
            return theMatNum.hashCode();
        }    // method: hashCode     
         String theName;
         String theCourse;
         int theMatric;     
    }it gives me: "Student@7b"
    ??

    Try adding a toString() method in Student - currently you are only getting the method defined by Object

  • JList is not showing up in my Frame

    This is a program I wrote for Having images in a List. A custom cellrenderer and a custom listmodel. Somehow the list itself does not show up in my frame.
    import java.awt.Component;
    import javax.swing.DefaultListModel;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.ListCellRenderer;
    public class ListWithImages extends JFrame {
         public ListWithImages() {
              //          We need a Custom model and a Custom Cell Renderer
              CustomImageListModel customImageListModel = new CustomImageListModel();
              CustomImageListCellRenderer customImageListCellRenderer = new CustomImageListCellRenderer();
              JList jlist = new JList(customImageListModel);
              jlist.setCellRenderer(customImageListCellRenderer);
              jlist.setVisibleRowCount(6);
              getContentPane().add(new JScrollPane(jlist));
              pack();
              setVisible(true);
         public static void main(String args[]) {
              new ListWithImages();
         class CustomImageListModel extends DefaultListModel {
              @Override
              public void addElement(Object arg0) {
                   // TODO Auto-generated method stub
         //          Add 10 elements with images
                   for (int i = 0; i < 10; i++) {
                        super.addElement(new Object[] { "Item " + i, new ImageIcon("smiley.jpg") });
         class CustomImageListCellRenderer extends JLabel implements ListCellRenderer {
              public CustomImageListCellRenderer() {
                   setOpaque(true);
              public Component getListCellRendererComponent(JList jlist, Object obj,
                        int index, boolean isSelected, boolean focus) {
                   CustomImageListModel model = (CustomImageListModel) jlist.getModel();
                   setText((String) ((Object[]) obj)[0]);
                   setIcon((Icon) ((Object[]) obj)[1]);
                   if (!isSelected) {
                        setBackground(jlist.getBackground());
                        setForeground(jlist.getForeground());
                   } else {
                        setBackground(jlist.getSelectionBackground());
                        setForeground(jlist.getSelectionForeground());
                   return this;
    }

    I try yhis code and the list is displayed. Try using a layout to get a better design
    public ListWithImages() {
                    this.setLaout(new FlowLayout());
              //          We need a Custom model and a Custom Cell Renderer
              CustomImageListModel customImageListModel = new CustomImageListModel();
              CustomImageListCellRenderer customImageListCellRenderer = new CustomImageListCellRenderer();
              JList jlist = new JList(customImageListModel);
              jlist.setCellRenderer(customImageListCellRenderer);
              jlist.setVisibleRowCount(6);
              getContentPane().add(new JScrollPane(jlist));
              pack();
              setVisible(true);
         }http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html
    HTH

  • Why when using Adobe Bridge,  I apply a star rating,  the rating does not show up in Photoshop Elements? [tags]

    Why when using Adobe Bridge,  I apply a star rating,   the rating does not show up in Photoshop Elements.  I use Elements as my organizer and Bridge to view as it is much more user friendly.  Anyone any solutions??

    Most likely you have set the wrong file as the external editor. You don't want the obvious one; that's just a link to the welcome screen. Go back and choose this one, which is hidden away inside the folder Support Files:

  • Elements do not show up in edge file but they do in HTML file; no errors occured

    I am a senior in college working on building a website for a fictional company for a year-long thesis graphic design project. In my class last semester, I learned how to use Edge Animate and created an 11 page website without any trouble. I had always kept the files saved to my flash drive, and kept a backup on my personal laptop as well as on my external hard drive. There was also a backup of the files on a disc that I turned into my professor in mid-December. All of these files worked fine at the time.
    In early January, I wanted to make changes to the website so I installed a trial version of Edge Animate on my laptop. When I opened any of the edge files from any of the backups, the stage was blank and the animations did not show up on the timeline. The elements of the website still show up in the Library but they are no longer arranged on the stage. When I got back to school at the end of January, I tried opening the files on the school computers and had the same problem. I asked my professor to try the file that was saved to the disc and he encountered the same issues on his computer. All of these computers are either iMacs or Macbook Pros.
    I have not recieved any error messages and did not do anything to corrupt the files or save over them. I am able to open the html files in a browser with no issues; all animations and images work fine. The only change I can think of is that Edge may have been updated over break and when I installed the trial version I installed a newer version, and for some reason the new version of the program could not properly load my project that I started on a older version in October or November of 2013.
    I am happy to upload the files but I am unsure how to do that. Please let me know if there is a way to resolve this issue, or will I have to start over?
    Thank you!

    Try to clear your preference and restart your Animate.See if that fixes your problem
    http://helpx.adobe.com/edge-animate/kb/restore-preferences-edge-animate.html
    If  that does not work see if there is a lloopback address lookup.
    Check out the correct answer in this post to fix that http://forums.adobe.com/message/6116991
    Let us know if this fixed your issue

  • Text element assigned to select options not showing

    Hi guys,
    We have a problem in shaowing the text assigned to the select-options...
    When we run the program the text element ssigned to the select options is not showing instead the element name is shown.
    The original language is german, and it wont show the english word we appended to as text element for select-options.
    example:
    AUART insteat od blocked order
    How can we show the text elemen when we run the program?
    Thanks!

    Hi Mark,
    Go to the program text elements and select the Selection Texts tab,
    There you fill find the select option for AUART and the corresponding text maintained.
    You need to maintain translations for this text entered.
    Chose Goto (in menu bar) -> Translation
    Then maintain translation in English.
    Regards,
    Aditya

  • Does anybody know why when I aTrying to edit my yahoo profile using Firefox certain elements do not show up such as update "Load Photo" on the avatar page.

    Trying to edit my yahoo profile using Firefox and certain elements do not show up such as update "Load Photo" on the avatar page.
    If I use Explorer it allows me to see all the links and can edit my profile but not in Firefox.
    I am not sure the URL will let you in as is a private link.

    '''Try the Firefox SafeMode''' to see how it works there. <br />
    ''A troubleshooting mode, which disables most Add-ons.'' <br />
    ''(If you're not using it, switch to the Default Theme.)''
    * You can open the Firefox 4.0+ SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running. <br />
    ''Don't select anything right now, just use "Continue in SafeMode."''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shft key) to open it again.''
    '''''If it is good in the Firefox SafeMode''''', your problem is probably caused by an extension, and you need to figure out which one. <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes
    ''When you figure out what is causing that, please let us know. It might help other user's who have that problem.''

  • Separator is not showing up in the JList that is set in the TextField

    Hi,
    This problem is really weird and I am tired trying to find the problem and so thought i ll ask u guys... i cant see any problem in the code below.. but when i run it the separator that i want if some condition is true it just dsnt come... i did debug it and it does actually go in the if condition but the separator is not showing up... i dont kno y...
    I am pasting the code of the JList renderer SearchListCellRenderer that implements ListCellRenderer.......it has only one method....
    public Component getListCellRendererComponent(JList list, Object value,
                   int     index, boolean isSelected, boolean cellHasFocus) {
              JLabel label = null;
              if (value != null){
                   label = new JLabel();/*(JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
                   isSelected, cellHasFocus);*/
                   if(!anatomySeparator && anatomyMap.containsKey(value.toString().toLowerCase())){
                        label.setVerticalTextPosition(SwingConstants.BOTTOM);
                        label.setPreferredSize(new Dimension(300, 80));
                        label.setText("<html><body>" + "<p style='color:white;'><b>--------------Anatomy--------------</b></p>" + "<p style='color:white;'><b>" + value.toString() + "</b></p></body></html>");
                        anatomySeparator = true;
                        logger.debug("in anatomy");
                   }else if(!diseaseSeparator && diseaseMap.containsKey(value.toString().toLowerCase())){
                        label.setVerticalTextPosition(SwingConstants.BOTTOM);
                        label.setPreferredSize(new Dimension(300, 80));
                        label.setText("<html><body>" + "<p style='color:white;'><b>---------------Diseases----------------</b></p>" + "<p style='color:white;'><b>" + value.toString() + "</b></p></body></html>");
                        diseaseSeparator = true;
                        logger.debug("in disease");
                   }else if(!propSeparator && observationMap.containsKey(value.toString().toLowerCase())){
                        label.setVerticalTextPosition(SwingConstants.BOTTOM);
                        label.setPreferredSize(new Dimension(300, 80));
                        label.setText("<html><body>" + "<p style='color:white;'><b>-----------Observations----------------</b></p>" + "<p style='color:white;'><b>" + value.toString() + "</b></p></body></html>");
                        propSeparator = true;
                        logger.debug("in observation");
                   }else{
                        label.setPreferredSize(new Dimension(300, 30));
                        label.setText("<html><body><p style='color:white;'><b>" + value.toString() + "</b></p></body></html>");
              return label;
    If i see the output the list in the JList is bold also in the condition i have the label size larger so in some values the label is actually large than others... that means it does go in the if condition... but the separator that i have there it just dsnt show up... i dnt kno wat is wrong... can anyone pls help me with this????
    This is how i set the autocopleter text field with the Jlist and its renderer... if that is of some help.....
    JList list = new JList();
    JPopupMenu popup = new JPopupMenu();
    JTextComponent textComp;
    private static final String AUTOCOMPLETER = "AUTOCOMPLETER"; //NOI18N
    public SearchListCellRenderer renderer;
    public AutoCompleter(JTextComponent comp){
    textComp = comp;
    textComp.putClientProperty(AUTOCOMPLETER, this);
    JScrollPane scroll = new JScrollPane(list);
    scroll.setBorder(null);
    list.setFocusable( false );
    list.setBackground(Color.DARK_GRAY);
    list.setForeground(Color.WHITE);
    renderer = new SearchListCellRenderer();
    list.setCellRenderer(renderer);
    scroll.getVerticalScrollBar().setFocusable( false );
    scroll.getHorizontalScrollBar().setFocusable( false );
    popup.setBorder(BorderFactory.createLineBorder(Color.black));
    popup.add(scroll);
    if(textComp instanceof JTextField){
    textComp.registerKeyboardAction(showAction, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), JComponent.WHEN_FOCUSED);
    textComp.getDocument().addDocumentListener(documentListener);
    }else
    textComp.registerKeyboardAction(showAction, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);
    textComp.registerKeyboardAction(upAction, KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), JComponent.WHEN_FOCUSED);
    textComp.registerKeyboardAction(hidePopupAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
    popup.addPopupMenuListener(new PopupMenuListener(){
    public void popupMenuWillBecomeVisible(PopupMenuEvent e){
    public void popupMenuWillBecomeInvisible(PopupMenuEvent e){
    textComp.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
    public void popupMenuCanceled(PopupMenuEvent e){
    list.setRequestFocusEnabled(false);
    }

    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • I have photoshop elements 9 and iphoto does not show it in my preferences edit window. How do I get it as an option in my preferences

    I have photoshop elements 9 and iphoto does not show it in my advaced preferences drop down, it used to be there, how do I get it back again?

    Hi, Yes you are correct in iPhoto Prefernces, Advanced tab editing I used to have iPhoto and "Use external editor.". It changed to iPhoto and iPhoto Library. I have einstaleed PSE 9 and downloaded the update.  There is still no lkink to external editor in the drop down box.  Have I done something wrong inadvertently or is there a clitch?  can you reinstal iPhoto.  I am new to Macs. Every thing came preinstalled.  it is the top of the range system with 16 Gb of rRAM, 2 Tb hard drive to top graphics card etc.  I used to be on Windows PC.  Have more than 27,000 photos on the system.  Much apprecite your reply and interest in this.

  • Photo does not show up in Adobe Elements

    I have a MacBook and have iphoto set up to open the edit with Adobe Photoshop Elements and not with iphot oediting tool. I had version 8 of APE and upgraded to APE 9 - now the photo does not show up in the Adobe window when I try to edit. How do I fix this ?

    Most likely you have set the wrong file as the external editor. You don't want the obvious one; that's just a link to the welcome screen. Go back and choose this one, which is hidden away inside the folder Support Files:

  • Adobe Photoshop elements 10 Editor not showing under application support;adobe

    Adobe Photoshop elements 10 Editor not showing under application support;adobe on a MAC.  I would like to add actions in photo effects but can't add like instructios say because it is not in adobe.

    SSharpPhotography I would recommend posting your inquiry to the Photoshop Elements forum.

  • Why does adobe photoshop elements 6.0 not show up for a download choice of putting my photos into my computer, I'm on windows7.  I'm sure it did when I first got my computer.  Could it be that I have lots of other photo software that may be interfering?

    why does adobe photoshop elements 6.0 not show up for a download choice of putting my photos into my computer, I'm on windows7.  I'm sure it did when I first got my computer.  Could it be that I have lots of other photo software that may be interfering?@@

    If you open the Organizer and go to Edit>Preferences>Camera or Card Reader, do you have Auto Launch Adobe Photo Downloader on Device Connect checked?
    Try checking that if you don't.

Maybe you are looking for

  • Accounts generated after reservation

    Hi to all, I've done reservation against the sales order in MB21 using mvt typ 231. After that i had issued the materil with ref to sales order n reservation in MB1A using mvt typ 231. After goods issue, following accounts are generated. I want to kn

  • Phone icon doesn't work after ios8 update

    After updating my phone to iOS 8 it is now not letting me access my phone icon it closes automatically after I open it. I tried hard resetting it it still didn't help. What do I do to fix it?

  • Import x500 addres from csv

    I need to export legacyexchangeDN from old domain and import to new domail. I have exported legacyexchangeDN from windows power shell using Get-ADUser -SearchBase "....." -Filter * -Properties SamAccountName,legacyExchangeDN | Select-Object SamAccoun

  • Why am I getting an It works! error message?

    I am trying to logon to a work system and am getting an It works! message after login and nothing more

  • Having Trouble accessing Adobe website

    http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.htm l The website is frequently inaccessable on our corporate network. While monitoring network traffic there was no indication of any traffic being blocked howeve