ok, im trying to use the set text method and the code im using it on looks as follows;

/** Convert the stringbuilder into an actual string, then return it */
        String completeMatchList = matchList.toString();
        String [] splitresult;
        String name = matchList.toString();
        splitresult= name.split("\\s");
        //txtbgreenentry.setText(splitresult[0]);
        //txtbyellowentry.setText(splitresult[0]);
        /** System.out.println(splitresult[5]); - this was added to test that the text has been broken down in to individual strings, then it prints off in an array to the console */
                for (int i = 0; i < 18; i++)
        {
            sd.getyh(i).getEmptyMatches();
            sd.getgh(i).getEmptyMatches();
        }
        return completeMatchList;

where the two names for the text areas are txtbgreenentry and txtbyellowentry, im under the assumption that i need to use

txtbgreenentry.setText(splitresult[0]);

but the problem is i am getting the error cannot find symbol variable txtbgreenentry, how can i fix this? is the problem to do with my actionlistener code? does it need to call the setetxt method and if so how do ido this? all my code (for the 2 classes of issue at least)
are below

matchlist

public class Matchlist
{

    private studentdetails sd = new studentdetails();
    /** matchList StringBuilder stores the match list in progress */
    private StringBuilder matchList = new StringBuilder();

    private int loop = 0;
    private int matches = 0;
    public Matchlist()
    {
        sd.createstudentdetails();
    }

    /** Method to create the actual match list, returns the list as a string */
    public String CreateMatch()
    {
        int g;
        int y;
        
        for (g = 0; g < 4; g++) /** this is for the game */
        {
            for (y = 17; y > -1; y--) /** used for the yellow house */
            {
                /** Check to see if the game is empty */
                if (sd.getgh(y).getGame(g).equals(""))
                {
                    for (int x = 0; x < 18; x++) /** used for the yellow house */
                    {
                        if (sd.getyh(x).getGame(g).equals(""))
                        {
                            if (sd.getgh(y).getC_lass() != sd.getyh(x).getC_lass()) /** used for the green house */
                            {
                                /** Check to see if the person has played the other person */
                                if (sd.getgh(y).checkPlayed(sd.getyh(x).getName()) == false)
                                {
                                    /** Set the game to the name of the opponent played */
                                    sd.getyh(x).changeGame(g, sd.getgh(y).getName());
                                    sd.getgh(y).changeGame(g, sd.getyh(x).getName());
                                    /** Build the match list step by step using append with \n at the end to create a new line */
                                    matchList.append(sd.getyh(x).getName() + " vs " + sd.getgh(y).getName()  +"\n");
                                    matches++; /** add to the matches */
                                    break;
                                }
                                
                            }

                        }
                    }
                }
            }

        }
        /** Convert the stringbuilder into an actual string, then return it */
        String completeMatchList = matchList.toString();
        String [] splitresult;
        String name = matchList.toString();
        splitresult= name.split("\\s");
        //txtbdisplaymatch.setText(splitresult[0]); 
        txtbyellowentry.setText(splitresult[0]);
        /** System.out.println(splitresult[5]); - this was added to test that the text has been broken down in to individual strings, then it prints off in an array to the console */
                for (int i = 0; i < 18; i++)
        {
            sd.getyh(i).getEmptyMatches();
            sd.getgh(i).getEmptyMatches();
        }
        
        return completeMatchList; /** returns the match list that has been completed */ 
    } 
}

interface

a
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class MyPanel extends JPanel implements ActionListener
{   //add the "implements ActionListener" line so the class knows its going to take an input

    private Matchlist ml = new Matchlist();
    private JButton btngenerate;
    public JTextArea txtbdisplaymatch;
    private JLabel lblvs;
    private JLabel lblgreenhouse;
    private JLabel lblyellowhouse;
    private JLabel lblname;
    private JTextField txtbgreenentry;
    private JTextField txtbyellowentry;
    private JTextField txtbenterscoreg;
    private JTextField txtbenterscorey;
    private JButton btnfinalresults;
    private JScrollPane scrollpane;
    private JLabel lblcurrentscore;
    private JTextField txtbcurrentgs;
    private JTextField txtbcurrentys;
   

    public MyPanel()
    {
        //construct components

        btngenerate = new JButton("Generate Match List");
        txtbdisplaymatch = new JTextArea(5, 5);
        scrollpane = new javax.swing.JScrollPane(txtbdisplaymatch);
        scrollpane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        lblvs = new JLabel(" vs");
        lblgreenhouse = new JLabel(" Green House");
        lblyellowhouse = new JLabel(" Yellow House");
        lblname = new JLabel(" Name");
        txtbgreenentry = new JTextField(5);
        txtbyellowentry = new JTextField(5);
        txtbenterscoreg = new JTextField(5);
        txtbenterscorey = new JTextField(5);
        btnfinalresults = new JButton("Enter Match Score");
        lblcurrentscore = new JLabel ("Current Score");
        txtbcurrentgs = new JTextField (5);
        txtbcurrentys = new JTextField (5);

        //adjust size and set layout
        setPreferredSize(new Dimension(542, 542));
        setLayout(null);

        //add components
        add(btngenerate);
        add(scrollpane);
        add(lblvs);
        add(lblgreenhouse);
        add(lblyellowhouse);
        add(lblname);
        add(txtbgreenentry);
        add(txtbyellowentry);
        add(txtbenterscoreg);
        add(txtbenterscorey);
        add(btnfinalresults);
        add(lblcurrentscore);
        add(txtbcurrentgs);
        add(txtbcurrentys);

        //set component bounds (only needed by Absolute Positioning)
        btngenerate.setBounds(185, 25, 165, 20);
        scrollpane.setBounds(60, 70, 415, 320); /**Changed it from setting the bounds on the textarea to setting them on the scrollpane */
        lblvs.setBounds(285, 415, 25, 25);
        lblgreenhouse.setBounds(385, 415, 100, 25);
        lblyellowhouse.setBounds(120, 415, 100, 25);
        lblname.setBounds(30, 445, 45, 25);
        txtbgreenentry.setBounds(75, 445, 155, 20);
        txtbyellowentry.setBounds(355, 445, 155, 20);
        txtbenterscoreg.setBounds(235, 445, 20, 20);
        txtbenterscorey.setBounds(330, 445, 20, 20);
        btnfinalresults.setBounds(185, 495, 205, 25);
        lblcurrentscore.setBounds(245, 560, 205, 25);
        txtbcurrentgs.setBounds(150, 580, 25, 25);
        txtbcurrentys.setBounds(390, 580, 25, 25);



        //add action listener
        btngenerate.addActionListener(this);    //use the components name and use the ".addActionListener()" method to enable this component to take inputs
        
    }

    public void actionPerformed(ActionEvent e)
    {//create a method called actionPerformed, this method will contain the code which is run when the component is pressed.
        
        if (e.getSource() == btngenerate)
        { //use the getSource() method and use it to see if it is equal to the compoenent.
            txtbdisplaymatch.setText(ml.CreateMatch());  //use the setText() method to add text from variable a to the txtbdisplaymatch which will display in the text area when the generate button is pressed.
        }
    }

    public static void main(String[] args)
    {
        JFrame frame = new JFrame("MyPanel");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MyPanel());
        frame.pack();
        frame.setVisible(true);
    }
}

Those text fields are in another class. You can't just access private variables in another class. Matchlist shouldn't be setting those values directly anyway. The interface should call methods on MatchList to get results and then set the text in it's text fields as needed.

well i have chnaged the txtb boxes to public and still the same problem, what do i need to change?

You still have no reference to that instance, so whether they are public or private makes no difference. You can't call methods on objects you don't have a reference to.

ao in my matchlist class i need

public MyPanel mp = new MyPanel();

No, actually your matchlist class has nothing at all to do with the interface. If you are going to separate them, make sure you know why and what each of them is supposed to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.