0

How to make 3 JList that connect each other?

private JList style = new JList(new String[] { "Monday", "Tuesday",
  "Wednesday", "Thursday", "Friday","Saturday","Sunday" });

private JList style2 = new JList(new String[] {"Lucy","bin"});

public void valueChanged(ListSelectionEvent evt) { updateFont();

}


  public void updateFont() {

      String m = (String) style.getSelectedValue();
      System.out.println(m);

    if(style.getSelectedValue()== "Monday")
    {
        style2.setListData(new String[]{"Lucy"});
        String mn = (String) style2.getSelectedValue();
        System.out.println(mn);
        //style3.setListData(st.getTime(mn));

    }
    if(style.getSelectedValue()== "Tuesday")
    {
        style2.setListData(new String[]{"Lucy"});               
    }

    if(style.getSelectedValue()== "Wednesday")
    {
        style2.setListData(st.getMovieList());              
    }

    if(style.getSelectedValue()== "Thursday")
    {
        style2.setListData(st.getMovieList());              
    }

    if(style.getSelectedValue()== "Friday")
    {
        style2.setListData(st.getMovieList());              
    }

    if(style.getSelectedValue()== "Saturday")
    {
        style2.setListData(new String[] {"Lucy","bin"});                
    }
    if(style.getSelectedValue()== "Sunday")
    {
        style2.setListData(new String[] {"Lucy","bin"});                
    }

    repaint();
shamil khairi
  • 93
  • 1
  • 1
  • 6
  • And how are they suppose to be connected? – MadProgrammer Nov 08 '14 at 06:16
  • when we click at the 1st list the second list are react, same goes to 2nd and third, i want to make, my source only go to 2nd list,and when i click the 2nd list, it give null value – shamil khairi Nov 08 '14 at 07:27
  • 1
    Start by taking a look at [How to Use Lists](http://docs.oracle.com/javase/tutorial/uiswing/components/list.html). You'll want to play around with the `ListSelectionListener`... – MadProgrammer Nov 08 '14 at 07:36
  • the mn show value null :( – shamil khairi Nov 08 '14 at 12:10
  • 1) For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve) (Minimal Complete Verifiable Example). 2) See [What is a stack trace, and how can I use it to debug my application errors?](http://stackoverflow.com/q/3988788/418556) & [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/q/218384/418556) – Andrew Thompson Nov 08 '14 at 13:51
  • Whe should it be anyone else, once you change the list data, the selection is invalidated... – MadProgrammer Nov 08 '14 at 19:20

0 Answers0