Home » Java » java – Using one button to pull information from several panels-Exceptionshub

java – Using one button to pull information from several panels-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I’m building this form that I want to be able to change what fields are displayed based on what setting you select.

There’s going to be 3 panels, first with text fields gathering information, second for notes, third for a checklist. The main frame will add those panels onto it and use one buttons to gather the information from each panel and compile it into a text area so you can just copy/paste it after it’s been formatted.

So the problem I’m having is getting the information passed over to the main frame. I have created a formlistener to pass information from the form using an object FormEvent I have created which will carry over the necessary information. I have then created a method in the form to pull the relevant information depending on which form is being used at the time. My problem is getting that method to call properly. This is the ActionListener for the button:

confirm.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
    form.getUbntInfo(); // this is where i have it set
    form.setFormListener(new FormListener() {
          // would like it to go here so that it creates the event 
          // object to pass before               
          // it passes the information, but it causes compile error here
        public void formEventOccured(FormEvent e) {
            String complaint = e.getComplaint();
            String ping = e.getPing();
            String ap = e.getAp();
                signal0 = e.getSignal0();
                signal1 = e.getSignal1();
                chain0 = e.getChain0();
                chain1 = e.getChain1();
                sinr0 = e.getSinr0();
                sinr1 = e.getSinr1();
                sinr0 = e.getLan();
                System.out.println("local signal: " + signal0);
        }
    });

Essentially the getUbntInfo(); method needs to have a formListener set so that it can pass create the object to pass along the information. As it stands I can press the button twice and it passes the information the second time but it will not do it the first time. What am I doing wrong?

How to&Answers: