Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Replies
    17
    Views
    1,134

    Re: Null pointer error JButton:

    It is possible to pass more that one image in the constructor:
    = new YourConstructor(image1, image2, image3, image4, image5); // pass 5 images to the constructor
  2. Replies
    17
    Views
    1,134

    Re: Null pointer error JButton:

    Load the images one time and pass the references to the images in the constructor:

    ImageIcon xC = new ImageIcon("asd.png"); // load icon one time here
    ...
    for(int i=0; i < array.length; i++ )...
  3. Replies
    17
    Views
    1,134

    Re: Null pointer error JButton:

    What did you change? It looks like the same code that has the problem.
    Add a println() statement next to those statements and see how many times it prints on the console.
  4. Replies
    17
    Views
    1,134

    Re: Null pointer error JButton:

    The images only need to be read one time. Then they can be passed to the MatrixButtons class in its constructor and saved in the class.
  5. Replies
    17
    Views
    1,134

    Re: Null pointer error JButton:

    How many hundreds of times are the ImageIcons being loaded now?
  6. Replies
    17
    Views
    1,134

    Re: Null pointer error JButton:

    What was the code that got the error?
    When working with arrays, there are several steps needed:
    1) define the variable
    2) assign to the variable an array of slots to hold values
    3) assign a...
  7. Replies
    17
    Views
    1,134

    Re: Null pointer error JButton:

    That is up to the programmer to decide what value to put into a variable. What are those variables supposed to hold? When you know that, then you will know what to assign to them.

    This line from...
  8. Replies
    17
    Views
    1,134

    Re: Null pointer error JButton:

    What variable on line 40 has the null value? Find the variable and then backtrack to find out why it does not have a valid value.
Results 1 to 8 of 8