aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Help with adding letters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Help with adding letters" Watch "Help with adding letters" New topic
Author

Help with adding letters

Lovro Posaric
Greenhorn

Joined: Jul 01, 2012
Posts: 11

Hi!
I need help with my application...
I've made application with JComboBox, few buttons...I've filled jComboBox with arraylist...I want to add letter by letter to jLabel...I have done this:

but it doesn't reset letters counter(brojSlovaInfinitiv)...to 0 when word in jComboBox is changed...

Thanks & sorry for bad english..!
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2288
    
  49
From the description and code posted it's a bit hard to give a definitive answer as I'm not entirely sure what you are trying to achieve or how you have gone about it but you probably need to add a selection listener to your combo box and in the listener check if the selection has changed and if so reset your counter.
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

OP, as Tony said you should post more detailed description of the problem you are facing and in this case SSCCE that we can go through. It is difficult to get the problem in deep, even for me who understand those variable names.

Edit: I see from your posts that you use NetBeans for your GUI applications extensively. But, what I've noticed is that you leave components with default names that NetBeans gives (e.g. jLabel1, jPanel1, jButton1, ...). I would suggest you modify it each time you add a component to your GUI. The reason is simple - your code will be more readable (even to yourself) and easier to maintain later.


The quieter you are, the more you are able to hear.
Lovro Posaric
Greenhorn

Joined: Jul 01, 2012
Posts: 11

Hi!
Sorry for late answer..I wasn't able to answer beacause I wasn't at my computer...
Here is the code..(deleted part of arrays..)


brojSlova* are conuters how many letters are added to jlabel...
And I used netbeans only to add ActionListener for every button itself...
So I want to when some verb(item from jComboBox1) is changed to restart letter counter(eg. brojSlovaInfinitiv)...
I haven't modified names of most of labels(I renamed only ones what I use(change their text)), there are just few buttons so I didn't rename them...
I hope you understand what I want to do..

L
Thanks!
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Can you please give some test data for those String arrays you are declaring at lines 18-22? I still can't get really into this application, and it seems interesting to me.
From your first post, you said:
but it doesn't reset letters counter(brojSlovaInfinitiv)...to 0 when word in jComboBox is changed...

You don't have any listener for your combo box, so you can't know when the value is changed. You can resolve this by adding a listener to it:
Lovro Posaric
Greenhorn

Joined: Jul 01, 2012
Posts: 11

Oh...thanks...
As you see from listener: it checks if text from jTextField equals word from arraylist...so you can add whatever word you want..

THANKS AGAIN!
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Oh, I see it now.
Well, everything you need to add is in that listener I mentioned in my previous post. Reset that variable you were talking about in your original post, set those labels in the bottom to empty string after the value in combo box is changed and it should work properly.

Greetings from neighbourhood!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with adding letters