Having problem setting JTextFields on a passed object.
System.out suggests that all parameters are correct.
Am I working with the KeyCards Object wrong? (keycards just builds Panel and components)
netbeans project attached.

The problem to be solved is in the keycards package.
XMLReaderProgressions.java and FillJTextFieldsFromGetters.java

Every part of this code is correct (all setters,strings,txtfields good)
The concept is to take a KeyCards.java object created earlier (GUI)
pass it to this method which creates new JTextFields and puts text into them. Nothing shows up in the txtflds

public void initJTextFields(KeyCards kc) {
        kc.sigTxt = new JTextField();
        kc.relaToneTxt = new JTextField();
        kc.paraToneTxt = new JTextField();
        kc.relaSigTxt = new JTextField();
        kc.paraSigTxt = new JTextField();
        kc.majTxt = new JTextField();
        kc.iTxt = new JTextField();
        kc.ivTxt = new JTextField();
        kc.viiDDTxt = new JTextField();
        kc.iiiTxt = new JTextField();
        kc.viTxt = new JTextField();
        kc.iiTxt = new JTextField();
        kc.vTxt = new JTextField();
        kc.relaMinTxt = new JTextField();
        kc.iRelaTxt = new JTextField();
        kc.ivRelaTxt = new JTextField();
        kc.viiDDRelaTxt = new JTextField();
        kc.iiiAugRelaTxt = new JTextField();
        kc.viRelaTxt = new JTextField();
        kc.iiDDRelaTxt = new JTextField();
        kc.vRelaTxt = new JTextField();
        kc.paraMinTxt = new JTextField();
        kc.iParaTxt = new JTextField();
        kc.ivParaTxt = new JTextField();
        kc.viiDDParaTxt = new JTextField();
        kc.iiiAugParaTxt = new JTextField();
        kc.viParaTxt = new JTextField();
        kc.iiDDParaTxt = new JTextField();
        kc.vParaTxt = new JTextField();
        kc.aITxt = new JTextField();
        kc.aIVTxt = new JTextField();
        kc.aVIIDDTxt = new JTextField();
        kc.aIIITxt = new JTextField();
        kc.aVITxt = new JTextField();
        kc.aIITxt = new JTextField();
        kc.aVTxt = new JTextField();
        kc.rAITxt = new JTextField();
        kc.rAIVTxt = new JTextField();
        kc.rAVIIDDTxt = new JTextField();
        kc.rAIIIAugTxt = new JTextField();
        kc.rAVITxt = new JTextField();
        kc.rAIIDDTxt = new JTextField();
        kc.rAVTxt = new JTextField();
        kc.pAITxt = new JTextField();
        kc.pAIVTxt = new JTextField();
        kc.pAVIIDDTxt = new JTextField();
        kc.pAIIIAugTxt = new JTextField();
        kc.pAVITxt = new JTextField();
        kc.pAIIDDTxt = new JTextField();
        kc.pAVTxt = new JTextField();


    }



    public void showKey(KeyCards kc) {

        System.out.println("showKey sets all textfields");
         initJTextFields(kc);
            
            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);

    }

You should only init your JTextFields once in the entire program. Therefore, it doesn't make sense to call initJTextFields from within your showKey method. You should init the JTextFields when the GUI is first created, then you should .add() them to your JPanel.

Here is an example to help you. Notice in the example that in the actionPerformed method, I create a new JTextField. Without that line, the example would have worked. There is no reason to create a completely different JTextField (using new) after the point when you add it to the JPanel:

public class ExampleGUI {
	static JTextField field = new JTextField("Blank");
	static JFrame frame;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		frame = new JFrame();
		JPanel panel = new JPanel();
		frame.add(panel);
		panel.add(field);
		
		field.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent arg0) {
				//Comment the next line and this example will work. This way, it doesn't.
				ExampleGUI.field = new JTextField();
				ExampleGUI.field.setText("Bleh");
			}
			
		});
		
		frame.setSize(300,300);
		frame.setVisible(true);
	}

}

Edited 6 Years Ago by BestJewSinceJC: n/a

I build a GUI and then alter it later due to a combox selected index evaluation. You solved it before. I have just changed how the data is sent to the setters. I will have to back up and start back where it used to work and get back to you.
Thanks though.
It is clear I do not understand why it worked when it was just hard coded data.

This question has already been answered. Start a new discussion instead.