getValue() null pointer

    Apr 24 2010 | 4:43 pm
    I have all but finished creating a GUI Drum Machine in Max Java. However, there is a null pointer statement upon compiling and it won't accept getValue() in the ChangeListener. If I write simply outlet (16, 88) for example it works, but as soon as I enter JSlider.getValue() it compiles, but gives me pages of errors to do with a null pointer in the max windowupon moving the JSlider.
    This correction will help me complete my GUI so any help would me very very very VERY VERY VERY much appreciated!
    Thank you very much

    • Apr 24 2010 | 5:14 pm
      Hey, what is GUICW6Frame? Max can not find it. Did you mean JFrame? (sorry, just scrolled down... it is an inline class)
    • Apr 24 2010 | 5:21 pm
      lol yes it is... have u any suggestions to what is wrong? its so confusing because it happened once because i hadnt copied my MaxObject over to the variables to reference in the use of it. But now i have done that it shouldnt be happening!
    • Apr 24 2010 | 7:23 pm
      hi. inside the GUICW6Frame constructor you have:
      JSlider TempoSlider = new JSlider( JSlider.VERTICAL, 0, 1000, 0 );
      this is declaring and initialising a variable local to the constructor - the TempoSlider instance variable remainsa null, so, when you later try to call getValue() on the slider you'll have problems.
      just a note - it may be dangerous to open your JFrame from this thread - look into using SwingUtilities.invokeLater(Runnable r) to make the window visble.
      Also, in java the convention is to start variable names with lower case.
      HTH jan
    • Apr 25 2010 | 2:16 pm
      Thank you very much and cheers for the lower case heads up