As a newbie in programming, nevermind Java, I got myself in yet another conundrum, *sigh*.
Ok, here we go.
I'm using a third party GUI library that, much like Swing, creates a table based off of a csv file.
Now I want to set and action for a selected cell when Enter is pressed. There's a method for that.
Now as you can see this method requires two arguments of type int, which are row and column numbers, so it knows which cell to set action to.
How do we get selected col/row? Well, there's a method for that, too!
Now you noticed that it does not return int, instead it returns Objects.
How do I get my col/row numbers, given the above?
There's a variable selectedColumn in that method, but it's private.
There's also a method that returns that variable, but I always get zeroes. Does it have to do something with the fact that variable is private?
Knute Snortum wrote:Would you like to post your solution back here, or tell us what you did? There may be other people with similar problems that would want to know.
Ok, since I'm new to this, I kinda solved it intuitively, I can't even explain what I did, and why my first approach didn't work, so I hope someone could chip in and explain what happened there better than I'm going to do now.
Anyway, basically my understanding is, that when the table is created the selected col/row is 0 0 by default and that's when I call method setCellEnterAction, so basically the method is called once on creation of the table, so why would it be called every time I select a cell in a table during runtime? It won't, right?
So I have to prepare all cells to do smth when enter is pressed beforehand, before runtime.
Hence the nested for loop that I did and it worked like a charm.