Search:

Type: Posts; User: sim18

Page 1 of 3 1 2 3

Search: Search took 0.35 seconds.

  1. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    THANK YOU SOOOOOOOO MUCH!
    You have made my day!!!
  2. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    it assigns a null value to the 'leftbtn', I just can't seem to get it :/
  3. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    I have tried:



    System.out.println("There is an image!");
    }

    But I get a nullPointerExceptionError?
  4. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    I have looked at the API, and I can only find checkImage(), but not sure how to use it in this context :/ ?
    Thanks for all your help again
  5. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    I have already set the button to have an ImageIcon though, I just need to know how I can tell if it has an image or not,

    say I have two buttons I click on one, and I want to know if the left of...
  6. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    To call the method would that be :


    int leftHole = (Integer) leftbtn.getClientProperty("ImageIcon");

    Because that still doesn't work, what method would you suggest?
  7. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    I am basically trying to act like I clicked on that button to easily get the information about it, as this code gives me a null pointer exception

    I really hope I am explaining properly :/ I have...
  8. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    Yes that was my problem thank you :)

    public static JButton[][] button; -> I had to change it to [] []

    Now
    JButton leftbtn = button[button1rowLeft][button1column]; works, but now, my leftbtn...
  9. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    What do you mean definition of button sorry?
  10. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    yes it is deffinatly a 2D array because I used :


    JButton[][] button = new JButton[8][8]; //Sets new JButtons
  11. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    I'm really struggling on this, I need to get this done by today and it is this one tiny bit that I need to do to complete my program :(
  12. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    Sorry about the long reply,

    JButton leftbtn = button[button1rowLeft][button1column];

    [button1column]
    ^

    it gives me an error on that line specifically [button1column]
  13. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    I'm not sure what you mean, I am using eclipse and when I try and run the program it just says :

    Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
    The...
  14. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    "Array required, but javax.swing.JButton found

    You are using syntax here that suggests that you are trying to access an array element. The variable you refer to is not an array,though"
  15. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    That still comes up with the error 'array required. but java.swing.JButton found' ?
  16. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    When I try and index it into the array :
    ____________________________________ edit:

    and when I do System.out.println on leftbtn its output is: [[Ljavax.swing.JButton;@208ee9c9

    Is there a way...
  17. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    I get that, but I'm not sure how to actually retrieve the source for the button?

    When I create the buttons in the array I give each row/col a reference and then i give each row/col +1 & -1 to get...
  18. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    Thanks for the reply :)

    when I do:


    JButton[][]

    I still get the same 'Source' as I do for the button clicked even though it should be the left button of the button I just clicked?
  19. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    Hi, i'm really sorry but I have looked a the JButton API doc, I found 'checkHorizontalKey' method, but I am not sure if this is correct as I tried using it.

    I can get the buttons row/col...
  20. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    edit
  21. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    Hi, thanks for all your help I feel I have done & learnt so much from what you last told me.

    I have one last problem. I have done the code that allows me to click one button, click the next...
  22. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    Just thought I would say thank you so much for your help and letting me know about the client properties. I have read over it lots today and have made so much progress. I haven't got stuck at the...
  23. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    I will have to have a go tomorrow, thank you very much again
  24. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    I have gone through the API as you said.

    So from:


    public void actionPerformed(ActionEvent e) {
    JButton src = (JButton) e.getSource();
    System.out.println(src);
    }...
  25. Replies
    60
    Views
    965

    Re: Help with checking JButton positions please

    To be honest I'm not really sure where to start with this, you say that the buttons save their row and columns using client properties, i'm not sure how to get them.
Results 1 to 25 of 68
Page 1 of 3 1 2 3