• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Setting text fields

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a class KeyCards.java that just sets up a panel (gui) with labels,combobox and text fields

when the combobox is selected a class generates strings to send to a class
public Class Progressions extends KeyCards and puts the strings in setters.
once all the strings are there it calls a method showKey() to set all the text fields in KeyCards.java

showKey() prints out that is has the right string but nothing goes in the text fields

should showKey() set the text fields a different way?

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to look into Commons Bean Utils.

And things like strXxxXxx, or "systems hungarian notation" has been largely discredited by now.
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is an interesting API it could help pairing up properties and names as of now that part of my class seems to work. I'd hate to start on a new concept when I can't even set a text field. So for now I was trying to find out why the text fields say
Xxx.setText("text") and nothing goes into the text field. I can set them when the class is originally built but when I return to it through the extended class to set them I does not throw an error and the text fields show empty.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you've only showed a bunch of calls to setters--without any more information, it's impossible to help. Usually it's best to isolate the issue to a minimal solution that demonstrates the problem, then post all the relevant info.
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I understand that and I apologize but the last thing to post is the GUI keycard.java. I will attach it. However I guess I was expecting that I could not set text field on the class if it was already created. I've just never used extends to do this. The keycads.java is just panels and JTextfields and a combo box but it is very long. it used to have a 1000 line switch in it but I have been learning Dom and JDom so at least that is not there anymore. I will tell you that it used to work perfect with the swithch but it was time to learn XML

I can't attach it say no .zip , .java, .txt attchments what else is there? anyway I will post it if you want to see it but it too long to post unless you wamt tp weed through 900 lines of panels and JTextfields etc..
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Usually it's best to isolate the issue to a minimal solution that demonstrates the problem, then post all the relevant info.

 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok then the setters originally shown show the minimum amount of code because they have all the correct Strings in the variables and they are to set text fields in a class that has textfields that are already created. But nothing goes in the text field.

public void showKey() {

System.out.println("showKey sets all textfields");
sigTxt = new JTextField();
sigTxt.setText(strSigTxt);
relaToneTxt = new JTextField();
relaToneTxt.setText(strRelaToneTxt);
paraToneTxt = new JTextField();
paraToneTxt.setText(strParaToneTxt);
relaSigTxt = new JTextField();
relaSigTxt.setText(strRelaSigTxt);
paraSigTxt = new JTextField();
paraSigTxt.setText(strParaSigTxt);
majTxt = new JTextField();
majTxt.setText(strMajTxt);
iTxt = new JTextField();
iTxt.setText(strITxt);
ivTxt = new JTextField();
ivTxt.setText(strIVTxt);
viiDDTxt = new JTextField();
viiDDTxt.setText(strVIIDDTxt);
iiiTxt = new JTextField();
iiiTxt.setText(strIIITxt);
viTxt = new JTextField();
viTxt.setText(strVITxt);
iiTxt = new JTextField();
iiTxt.setText(strIITxt);
vTxt = new JTextField();
vTxt.setText(strVTxt);

//textfield relamin
relaMinTxt = new JTextField();
relaMinTxt.setText(strRelaMinTxt);
iRelaTxt = new JTextField();
iRelaTxt.setText(strIRelaTxt);
ivRelaTxt = new JTextField();
ivRelaTxt.setText(strIVRelaTxt);
viiDDRelaTxt = new JTextField();
viiDDRelaTxt.setText(strVIIDDRelaTxt);
iiiAugRelaTxt = new JTextField();
iiiAugRelaTxt.setText(strIIIAugRelaTxt);
viRelaTxt = new JTextField();
viRelaTxt.setText(strVIRelaTxt);
iiDDRelaTxt = new JTextField();
iiDDRelaTxt.setText(strIIDDRelaTxt);
vRelaTxt = new JTextField();
vRelaTxt.setText(strVRelaTxt);
//texfield paramin
paraMinTxt = new JTextField();
paraMinTxt.setText(strParaMinTxt);
iParaTxt = new JTextField();
iParaTxt.setText(strIParaTxt);
ivParaTxt = new JTextField();
ivParaTxt.setText(strIVParaTxt);
viiDDParaTxt = new JTextField();
viiDDParaTxt.setText(strVIIDDParaTxt);
iiiAugParaTxt = new JTextField();
iiiAugParaTxt.setText(strIIIAugParaTxt);
viParaTxt = new JTextField();
viParaTxt.setText(strVIParaTxt);
iiDDParaTxt = new JTextField();
iiDDParaTxt.setText(strIIDDParaTxt);
vParaTxt = new JTextField();
vParaTxt.setText(strVParaTxt);

//appegio==========================
// amajTxt.setText(");
aITxt = new JTextField();
aITxt.setText(strAITxt);
aIVTxt = new JTextField();
aIVTxt.setText(strAIVTxt);
aVIIDDTxt = new JTextField();
aVIIDDTxt.setText(strAVIIDDTxt);
aIIITxt = new JTextField();
aIIITxt.setText(strAIIITxt);
aVITxt = new JTextField();
aVITxt.setText(strAVITxt);
aIITxt = new JTextField();
aIITxt.setText(strAIITxt);
aVTxt = new JTextField();
aVTxt.setText(strAVTxt);

//arelaMinTxt.setText(");
rAITxt = new JTextField();
rAITxt.setText(strRAITxt);
rAIVTxt = new JTextField();
rAIVTxt.setText(strRAIVTxt);
rAVIIDDTxt = new JTextField();
rAVIIDDTxt.setText(strRAVIIDDTxt);
rAIIIAugTxt = new JTextField();
rAIIIAugTxt.setText(strRAIIIAugTxt);
rAVITxt = new JTextField();
rAVITxt.setText(strRAVITxt);
rAIIDDTxt = new JTextField();
rAIIDDTxt.setText(strRAIIDDTxt);
rAVTxt = new JTextField();
rAVTxt.setText(strRAVTxt);
//Car. aparamin);
pAITxt = new JTextField();
pAITxt.setText(strPAITxt);
pAIVTxt = new JTextField();
pAIVTxt.setText(strPAIVTxt);
pAVIIDDTxt = new JTextField();
pAVIIDDTxt.setText(strPAVIIDDTxt);
pAIIIAugTxt = new JTextField();
pAIIIAugTxt.setText(strPAIIIAugTxt);
pAVITxt = new JTextField();
pAVITxt.setText(strPAVITxt);
pAIIDDTxt = new JTextField();
pAIIDDTxt.setText(strPAIIDDTxt);
pAVTxt = new JTextField();
pAVTxt.setText(strPAVTxt);

}

and the textfield names are all correct and use the proper conventions for getters and setters. they are in a system that describes 6 0r 7 word descriptions. You mentioned Hungarian notation. What does this mean?
how would you write variable names that describe one of 51 description prhases
pAIIDDTxt=Parallel key,arpeggio, supertonic, fully diminished chord text?

is there a better way to write this varaible?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://en.wikipedia.org/wiki/Hungarian_notation
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The original question was an attempt to understand objects. The solution had nothing to do with getters or setters or nameing conventions. Now ,I am posting the actual solution. My showKey() needed to set the textFields of the object that was created originally. Any further information "Dealing with Object" is welcome. I hope this will help someone understand OOP a little better.
Thanks again.


[code]
public void fillSetters(KeyCards kc) {
// sets all textfields
showKey(kc);
}

public void showKey(KeyCards kc){
System.out.println("showKey sets all textfields");
kc.sigTxt.setText(strSigTxt);
kc.relaToneTxt.setText(strRelaToneTxt);
kc.paraToneTxt.setText(strParaToneTxt);
kc.relaSigTxt.setText(strRelaSigTxt);
kc.paraSigTxt.setText(strParaSigTxt);
kc.majTxt.setText(strMajTxt);
kc.iTxt.setText(strITxt);
kc.ivTxt.setText(strIVTxt);
kc.viiDDTxt.setText(strVIIDDTxt);
kc.iiiTxt.setText(strIIITxt);
kc.viTxt.setText(strVITxt);
kc.iiTxt.setText(strIITxt);
kc.vTxt.setText(strVTxt);

//textfield relamin
kc.relaMinTxt.setText(strRelaMinTxt);
kc.iRelaTxt.setText(strIRelaTxt);
kc.ivRelaTxt.setText(strIVRelaTxt);
kc.viiDDRelaTxt.setText(strVIIDDRelaTxt);
kc.iiiAugRelaTxt.setText(strIIIAugRelaTxt);
kc.viRelaTxt.setText(strVIRelaTxt);
kc.iiDDRelaTxt.setText(strIIDDRelaTxt);
kc.vRelaTxt.setText(strVRelaTxt);
//texfield paramin
kc.paraMinTxt.setText(strParaMinTxt);
kc.iParaTxt.setText(strIParaTxt);
kc.ivParaTxt.setText(strIVParaTxt);
kc.viiDDParaTxt.setText(strVIIDDParaTxt);
kc.iiiAugParaTxt.setText(strIIIAugParaTxt);
kc.viParaTxt.setText(strVIParaTxt);
kc.iiDDParaTxt.setText(strIIDDParaTxt);
kc.vParaTxt.setText(strVParaTxt);

//appegio==========================
// amajTxt.setText(");
kc.aITxt.setText(strAITxt);
kc.aIVTxt.setText(strAIVTxt);
kc.aVIIDDTxt.setText(strAVIIDDTxt);
kc.aIIITxt.setText(strAIIITxt);
kc.aVITxt.setText(strAVITxt);
kc.aIITxt.setText(strAIITxt);
kc.aVTxt.setText(strAVTxt);

//arelaMinTxt.setText(");
kc.rAITxt.setText(strRAITxt);
kc.rAIVTxt.setText(strRAIVTxt);
kc.rAVIIDDTxt.setText(strRAVIIDDTxt);
kc.rAIIIAugTxt.setText(strRAIIIAugTxt);
kc.rAVITxt.setText(strRAVITxt);
kc.rAIIDDTxt.setText(strRAIIDDTxt);
kc.rAVTxt.setText(strRAVTxt);
//Car. aparamin);
kc.pAITxt.setText(strPAITxt);
kc.pAIVTxt.setText(strPAIVTxt);
kc.pAVIIDDTxt.setText(strPAVIIDDTxt);
kc.pAIIIAugTxt.setText(strPAIIIAugTxt);
kc.pAVITxt.setText(strPAVITxt);
kc.pAIIDDTxt.setText(strPAIIDDTxt);
kc.pAVTxt.setText(strPAVTxt);

}

[/code]
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You asked what Hungarian notation was, so I provided a reference.

Your solution indicates you didn't provide enough information to answer the first time. Glad you got it working.
 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic