Search:

Type: Posts; User: Norm

Page 1 of 2 1 2

Search: Search took 0.17 seconds.

  1. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Glad you found it. I don't know why IDEs don't give warnings when variable definitions shadow other definitions.
  2. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    That means that the button array has a null value. Why does the button array have a null value?

    See posts #49 and 43. Make sure the code is not using a variable that is local to a method.
    How...
  3. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    What variable is null? Where does the code assign a non-null value to the variable?
    See posts #49 and 43. Make sure the code is not using a variable that is local to a method.
  4. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Your code uses the setIcon() method to set the image.
    Look at the getIcon() method for getting the image that was set with the setIcon() method.
  5. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Call the method that will return the image if it has one. Read the API doc for the JButton class and see what method returns the current icon/image that the object is using.
  6. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Please explain.

    Why use client properties when the class has a method you can call directly to determine if it has an image: see the icon get and set methods for the class.
  7. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Get a reference to the JButton object and call its methods to determine its state.
    This statement sets leftbtn to the button object:

    JButton leftbtn = buttons[button1rowLeft][button1column];...
  8. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Please explain. What do you mean by "source"?
  9. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Where is the variable: button defined?

    Every variable in a program must be defined before it can be used. Some variable definitions:
    Object obj;
    int anInt;
    double aDbl;
  10. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    You are not using that definition of button which is local to the constructor. Look for the definition of button that you are using.
  11. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    The error message could mean that the array only has one dimension not two.
    Check that the definition for the array you are trying to use has 2 dimensions.
  12. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    The error message could mean that the array only has one dimension not two.
    Check that the definition for the array you are trying to use has 2 dimensions.
  13. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Where on the line with the error does the IDE put the indicator flag that points to the location of the error on the line? See the ^ in post #35. It's beneath where there error is: var
    Where does...
  14. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Please post the FULL text of the error message that shows where the error happened and the source line with the error.
    Here is a sample:


    TestSorts.java:138: cannot find symbol
    symbol :...
  15. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Please post the full text of the error message and the source code where the error happens.
  16. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    button[button1rowLeft][button1column];
    refers to a JButton object, not to an array of JButtons.
    Try this:


    JButton leftbtn = button[button1rowLeft][button1column];
  17. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    I posted an example in post#27


    Compute the indexes and use them to index into the button array.
  18. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    What is the index into the button array for the clicked button?
    Say it was 4,5. Then the button on the same row (4) and two columns to the right would be at column 7
    Then the array element:...
  19. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    This array needs to be a class variable so it can be used to get a reference to any of the buttons:

    JButton[][] button = new JButton[8][8];
    Given the row,col of a button, index into that array to...
  20. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Given a reference to a JButton object (get that from the array using its r,c location), you can call its methods and determine its state.
    Look at the API doc for the JButton class to see what...
  21. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    When you get the row,col location of the clicked button, you can use that in the array to get to any other button in the array by changing the row and/or col values.
  22. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    Ok, you're welcome. Good luck.
  23. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    see you tomorrow.
  24. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    the value that was written to the button with the putClientProperty() method. The buttons location in a row and column variable.
    See post#11

    There is a reference to the event button. The button...
  25. Replies
    60
    Views
    6,013

    Re: Help with checking JButton positions please

    I thought that you had written the code that you posted in post #8. That code saves values with the button component's client properties. Those values are saved in a sort of map. Use the client...
Results 1 to 25 of 29
Page 1 of 2 1 2