Java display components after intervals
I have a list of JComponents each having a visibility time. I have to pick each component from the List, use a swing timer, display it for the specifed visibility time after which remove the displayed component from the panel, take the next component from the list and display and so on. At a particular time I should display only one component. Please help

    

        testList.add(new JLabel());
        testList.add(new JButton());
    
        java.util.Timer timer;
        TimerTask task;
    
       for (Iterator<> it = testList.iterator(); it.hasNext(); ) {
        final JComponent comp= it.next();
        comp.setSize(new Dimension(200, 200));
            for(int index=0; index==getComponents().length;index++) {
              if(getComponents().length==0)
                  add(not.getComponent(), BorderLayout.CENTER);
          }
        timer= new java.util.Timer();
        task= new TimerTask() {
            public void run() {
                validate();
                try {
                    remove(comp);
    
                } catch (Exception e) {
                    e.printStackTrace();
                }
    
                validate();
                repaint();
                }
            };
    
            timer.schedule( task ,30*1000);
            it.remove();
    
       }
Java display components after intervals
===

I have a list of JComponents each having a visibility time. I have to pick each component from the List, use a swing timer, display it for the specifed visibility time after which remove the displayed component from the panel, take the next component from the list and display and so on. At a particular time I should display only one component. Please help

    

        testList.add(new JLabel());
        testList.add(new JButton());
    
        java.util.Timer timer;
        TimerTask task;
    
       for (Iterator<> it = testList.iterator(); it.hasNext(); ) {
        final JComponent comp= it.next();
        comp.setSize(new Dimension(200, 200));
            for(int index=0; index==getComponents().length;index++) {
              if(getComponents().length==0)
                  add(not.getComponent(), BorderLayout.CENTER);
          }
        timer= new java.util.Timer();
        task= new TimerTask() {
            public void run() {
                validate();
                try {
                    remove(comp);
    
                } catch (Exception e) {
                    e.printStackTrace();
                }
    
                validate();
                repaint();
                }
            };
    
            timer.schedule( task ,30*1000);
            it.remove();
    
       }