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

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.

  • 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

  • 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

  • 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.

  • ITunes does not show up on apple tv 1st gen.

    i have a 1st gen apple tv with the 160 gig HD. recently, it will not show the itunes site. Under teh movies tab there are my movies and trailers and that's it. Does anyone know how to get the itunes store back on apple tv?

    Known issue currently, you'll need to wait for the fix.

  • My downloaded text sounds do not show up under the sounds tab in settings after installing 8.1.1. can someone help me please?

    i downloaded a couple text tones and since installing 8.1.1, they will not show up under the sounds tab. in fact, they do not show up in my recent purchases on itunes, but when i go to buy them again, it says that i have already bought this tone. I just want to use the tones i paid for as the tones on my phone. not asking much.... thanks for the help. i hope someone can help me get the tones working. thank you.

    This was happening to me too but only for some of my songs. I have a mac so I dunno about PCs, but for most of my ringtones I had to create an ACC version in itunes to make them short enough then turn that into a m4r and those all worked fine. But if the song was already short enough and I didn't create an ACC version and just turned the original into a m4r, then it wouldn't appear in my itunes.
    so if you're on a mac:
    1. go to get info, options, pick when you want the song to start and end.
         Has to be pretty short to work, 30 second or less is good
         if it's already short enough that's fine
    2. right click and click 'create ACC version'
         a copy with the length you put in will appear, drag that into a folder or whatever and just type in m4r where m4a would be
         still make an ACC version even if it's the right length
    Hopefully this helps someone else.

  • Internet Streams in Playlists do not show up on Apple TV

    I use the following setup:
    - Apple TV MD199LL/A (Software 6.0.1) just updated to the latest
    - iTunes 11.1.3 for Windows (from a Windows 7 x64)
    - iTunes 11.1.3 for MAC (from a Apple MacBook Pro x64, Maverix)
    Homesharing is turned on both computers
    From both machines I share pictures, videos and music.
    All photos, videos and music files are getting displayed  on the Apple TV menu, and can be played.
    All iTunes playlists from both machines are  getting displazed on the Apple TV
    BUT!
    If a internet stream is added to a playlist, this entry does not show on the Apple TV menu.
    If the playlist contains only internet streams the Apple TV menu says "There are no songs in this library"
    If I hit the play key on my remote, it  will randomly play the first stream in the playlist (not realy reproducable pattern)
    I can play those streams in iTunes and send it via AirPlay without problems,
    Can anyone help me with this and tell me what I'm doing wrong?
    Thank you

    You can only view that rental on the iPad. For it to show up it has to be rented directly on ATV or through a computer and streamed via home sharing

  • When I sync my iPod to my MacBook through iTunes new events do not show up and old events are not deleted. I am using Snow Leopard  and not iSync.

    I am using Snow Leopard on a MacBook. I have an iPod touch 3G. I do not use iSync it Mobile Me. When I sync my iPod through iTunes new events on my iPod do not show up on my Mac and old events do not delete. I have read help instructions that include deleting the data on the iPod. The iPod has the correct data and the Mac does not so I have not followed those instructions. I need help as the only reason I bought the Mac was to be able to sync, back up, view and print my calendar. Currently it is useless. If only Apple could have learned from the elegance of the Palm software.

    Start here:
    iPhone, iPad, or iPod touch: Device not recognized in iTunes for Windows

  • Synced videos do not show up on iPod

    Every time I sync my iPod with iTunes, although iTunes says the videos are synced, they do not show up in the Video app on the iPod.
    This is a fairly new problem.  All these videos have been synced before and they all showed up just fine in the Video app, but as of late the iPod does not show them.  Searching for them yields no results.
    The videos are in a compatible format and do not have an extremely high definition.  Again, I do not think the problem is with the videos, because previously I was able to view them all just fine.
    I have at least 1G of memory left, 2G without syncing the videos.
    I have erased and re-synced them in iTunes, to no avail.  I can play the videos on the iPod from iTunes, but not on the actual iPod device.  I'm using windows iTunes, and it is up to date.  The iPod software is up to date.  I don't want to do a restore because I've already done that multiple times for multiple issues, but if that's what I have to do, I will. It's a pretty old iPod.  I'm syncing with a third-party Duracell cable, but I really don't think that's the problem.
    I'm not sure what it means, but in iTunes I have checked the option that reads, "Prefer standard definition videos".  Syncing with that option unchecked changes nothing so far as I can tell.
    Thanks for all your help!
    iPod Touch 4th Gen. 8G
    iOS 6.1.6
    1G free with videos, 2G free without
    iTunes for Windows 64-bit V12.1
    Duracell 30 pin to USB iPod cable

    Try:
    - DFU mode and then restore to factory settings/new iPod via iTunes                   
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    - Try with a new video

  • Files do not show up on HDD

    I tried to get an answer through the iTunes community, and was advised to try here instead as it didn't have anything directly to do with iTunes
    Not all iTunes Files not showing up on External HDD
    So in a nutshell, all of my 35'000 iTunes files (actual MP3 files) were saved on a TC 2.0TB disk and used on multiple Mac's to pull music from. All music files would be saved and streamed wirelessly from this TC and nowhere else.
    I would always add files to this external wireless client and iTunes would work flawlessly playing whatever song I chose through the library.
    If I would go in to the iTunes directory (path) and look up files on the HDD the files were just not there (but if clicking on the link through iTunes - show in finder - they would appear on the HDD but only through this method). I gave it no further thought until my TC died (i.e. no longer powers up) on me...
    I removed the HDD from the TC and placed it in an USB cradle and after looking into the iTunes folder there are only a fraction of the folders / files much less than expected... When I do a cmd-I I'm told that there are 35'000 files, but they just won't show up.
    Any ideas on how i can get all the files to be displayed as I want to copy these over on a new TC and need to map iTunes to this new location/path?

    Hello Jfrosa,
    Thank you for the details of the issue you are experiencing with File Sharing.  I found an article that should help with troubleshooting this:
    OS X: How to connect to Windows File Sharing (SMB) using Snow Leopard or earlier
    http://support.apple.com/kb/ht1568
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Movie rentals that I downloaded onto iMac with Lion to do not show up on ATV 2 in menu for computers.  Purchased movies show up just fine.  What to do or look for?

    I have an imac that is running lion and an Apple TV generation 2.  I have rented a movie from itunes and it shows up on my imac in Itunes under a rental icon, and will play fine on my computer.  However, it does not show up as choice to play on my apple tv.  I have homesharing enabled and everything else works fine including purchased movies that are on my imac, but no where does it show rental movies. 
    What do I look for?  What do I do to play the rental movie on my apple tv 2?

    Answer to my own question:
    Wait until the downloaded rental has completed its download to the imac.  This took a long time for me, since it was part of several things that I was downloading at the same time.
    Finally, it showed up on my apple tv.   Interestingly, I was able to watch much of the movie on my iMac before the movie finished its download and was available to the ATV 2.

  • I have an apple iphone 4 that I want to download audio books from my library onto it.  I cannot figure out how to do that.  The iphone does not show up on my mac laptop as a connected device.  Does this kind of download have to run through itunes?  Thanks

    I have an apple iphone 4 that I want to download audio books from my library onto.  I cannot figure out how to do that.  The iphone does not show up on my mac laptop as a connected device.  Does this kind of download have to run through itunes?  Thanks

    Yes it is done through iTunes. The iPhone will never show up in Finder as a device. The following is general information on iTunes sync: http://support.apple.com/kb/HT1386 and the following is a previous discussion where the post by Andreas Junge helped others that had a problem syncing audiobooks: https://discussions.apple.com/message/20052732#20052732

  • HT1657 I rented a movie from iTunes but it is not showing up in the Movies section. What do I do?

    I just rented and downloaded a movie from iTunes and now it will not show up in my iTunes library. What do I do?
    It DOES show up in iTunes on my iPhone. It DOES NOT show up on my desktop.
    Any thoughts? Ideas?
    I rented it for a flight I get on in 3 hours. Any quick help would be great.
    Thanks.

    If the computer iTunes is signed into the same account then contact iTunes:
    How to report/refund an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase

  • HT5100 I have downloaded lectures from iTunes u but they do not show up on my bookshelf.  Why?

    I have downloaded lectures from iTunes u.  It had been working fine, but now my downloads do not show up on my bookshelf.  They do show up as downloaded when I search through the catalog.  How do I fix this?

    Wow, I just checked & all the DOWNLOADED songs MADE it into my iTunes "Songs". Thanks anyway!

Maybe you are looking for