My Swing Questions Topic

i thought that id make 1 topic for all my questions instead of creating a topic each time i run into a problem. so far i only have 1 question but im sure ill have more later haha!

im having a few problems right now and i hope u guys could maybe help me:

1)

if(event.getSource() == editButton && editButton.getText() =="Edit"){

contactNameField.setEditable(true);

contactNumberField.setEditable(true);

contactEMailField.setEditable(true);

editButton.setText("Done");

}

if(event.getSource() == editButton && editButton.getText() =="Done"){

contactNameField.setEditable(false);

contactNumberField.setEditable(false);

contactEMailField.setEditable(false);

editButton.setText("Edit");

}

this doesnt want to work and i have no clue why. when i start my app up and click on the "Edit" button, nothing happens.

whats supposed to happen is this: the text fields are supposed to become editable, and editButton is supposed to change its button text to "Done". if i then click on editButton again, when its text is set to "Done", then the text fields are no longer editable and editButtons text changes back to "Edit"). and yea i have added an actionlistener to my button.

[1751 byte] By [Alex1989a] at [2007-11-27 1:38:21]
# 1
Instead ofeditButton.getText() == "Edit"useeditButton.getText().equals("Edit")
KelVarnsona at 2007-7-12 0:50:12 > top of Java-index,Desktop,Core GUI APIs...
# 2

> i thought that id make 1 topic for all my questions instead of creating a topic each time i run into a problem

Actually, I think most would agree that it's better to have a one-topic-per-problem approach, each with an appropriate subject title that accurately describes your problem. This way, others in the future looking to solve a similar problem will be able to search for it.

KelVarnsona at 2007-7-12 0:50:12 > top of Java-index,Desktop,Core GUI APIs...
# 3
> Instead ofeditButton.getText() ==> "Edit"useeditButton.getText().equals("Edi> t")this still doesnt work :(
Alex1989a at 2007-7-12 0:50:12 > top of Java-index,Desktop,Core GUI APIs...
# 4
Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/button.html]How to Use Buttons[/url] for a working example.
camickra at 2007-7-12 0:50:12 > top of Java-index,Desktop,Core GUI APIs...
# 5
> Read the Swing tutorial on [url> http://java.sun.com/docs/books/tutorial/uiswing/compon> ents/button.html]How to Use Buttons[/url] for a> working example.the tutorial didnt solve my problem :(
Alex1989a at 2007-7-12 0:50:12 > top of Java-index,Desktop,Core GUI APIs...
# 6

> the tutorial didnt solve my problem :(

Of course it does. The example works.

If you can't compare your code to the code in the tutorial to see what your are doing differently then you will never solve your problem. You are doing something different than what the tutorial example does.

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.

camickra at 2007-7-12 0:50:12 > top of Java-index,Desktop,Core GUI APIs...
# 7
k nvm had to be else if sorry guysMessage was edited by: Alex1989
Alex1989a at 2007-7-12 0:50:12 > top of Java-index,Desktop,Core GUI APIs...