Gary Down

Greenhorn
+ Follow
since Jan 04, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gary Down

Being new to this (android and java) I have hit a wall. The first level list displays but appears to be inactive (nothing happens when clicked).

The source and the XML files are below.

Any help will be appreciated.

Cheers,
Gary.

Activity_main.xml


all_levels_text



10 years ago
Thanks Alex,
you first reply got me headed in the right direction to fix the repeated actionlistener events.

The other bit I was referring to was from a later comment I posted
"If I delete all the fields (by entering 0 in one after the other) the Jpanel is not changed after the last delete (i.e. the last is still showing)."

I think it has something to do with the validate() statement when nothing has been added to the panel when there is nothing left in the set to display. I'll try a few things around that tomorrow.

Thanks again,
Gary.
Thanks me.
solved the first part. I was adding the actionlistener to the NumericTextField object in the list everytime the display function was called. Moved the add to where the object is created and added to the list.

Still haven't figured the last delete bit yet.

Any comment/advise welcome..

Gary.

I believe that was a red herring, no matter what I try I can't seem to find the problem (doesn't mean there isn't one).

Just to restate the problem.
The first time I enter 0 (zero) into one of the NumericTextFields all seems OK, the entry is deleted and the Jpanel redisplayed with the now deleted item erased.
Second and subsequent times I enter ), the field is deleted correctly but fires multiple action events which are detected by the ActionListener. It works but seems a lot of excessive processing.
If I delete all the fields (by entering 0 in one after the other) the Jpanel is not changed after the last delete (i.e. the last is still showing).
sorry.
this.add(cartItem.getItemCount());

should read
this.add(itemCount);

was moving things around a little....
I believe you're right.

The culprit (I think) is itemCount in the displayCart which has an actionlister added each time it is added to the display (a JPanel) is called to re create the display after an item is deleted. Now to figure a better way to do it.

Thanks,
Gary.
javascript: x()
jumpingjoy

I have an action listener attached to a NumericTextField (extends JTextField).
I display 3 of these then enter 0 which is detected by the listener.
No problems so far.
The first time the listener is fired 1 time.
the 2nd time the listener is fired 2 times.
the 3rd time the listener is fired 4 times.

What is causing the repetitions and how do I prevent it.
AM I right in thinking it has something to with using a Timer?

Thanks,
Gary.



output is :-
java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=0,when=1200452253421,modifiers=] on AA AA
deleted true
java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=0,when=1200452265827,modifiers=] on BB BB
deleted true
java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=0,when=1200452265827,modifiers=] on BB BB
deleted false
java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=0,when=1200452270327,modifiers=] on CC CC
deleted true
java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=0,when=1200452270327,modifiers=] on CC CC
deleted false
java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=0,when=1200452270327,modifiers=] on CC CC
deleted false
java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=0,when=1200452270327,modifiers=] on CC CC
deleted false
I applet contains button items which, when pressed, passes control to one of the other 2 applets..no dramas so far

after finishing with the second one (either by clicking outside the applet or any other activity) I would like to render it invisible but not close it completely.

Please point me in the right direction as to what I should be looking at to accomplish this. I just beginning to learn java so a push in the right direction is all that I want just now.

Thanks,
Gary.
16 years ago
Thanks again Ulf,
you've helped in getting me in the right direction.

I have ended up with the code below. Any comments are welcomed (eg. anything I should be wary off in the code) :-
16 years ago
Ulf,
Thanks for the idea...it didn't directly fix it but certainly aimed me in a different direction of thinking. I eliminated the button altogether and moved the listener to the itemCount. Now all I need to do is force the input to be numeric (which I believe can be done by extending the TextField class)
Any comment/suggestion is welcome.

PS.. I changed my name, however my surname is Down and I've been called Top for most of my life (some bizarre nickname my father hung on me). Gary will do fine.

Cheers,
Gary

16 years ago
How should I approach this?
I am iterating through a Treeset which contains variable numbers of objects, each containing a known number of items.

The update and redisplay works but.......
How do I detect which row the button (once clicked) belongs to so I can apply the update to the correct object in the Treeset?

Thanks,
Top.

NOTE: the result = shoppingCart.AddItemToCart.....
and result = shoppingCart.UpdateItemInCart("AA", 20); are temporary, only for testing purposes and will be remover later

16 years ago