0

I am trying to access a varible value from a return fuction in another class. Everytime I attempt to access the variable, it returns a null value. This is selecting from a choice control
Part of the first class called CheeseBread

public void itemStateChanged(ItemEvent e)
	{
		if(e.getSource() == total1)
		{
			calc1(total.getSelectedItem());
		}
		
		if(e.getSource() == total2)
		{
			calc2(total2.getSelectedItem());
		}
		
		if(e.getSource() == total3)
		{
			calc3(cheese.getSelectedItem());
		}
	}
	
	public static void calc1(String answer)
	{
		mchoice = answer;
	}
	
	public String ranswer()
	{
		return mchoice;
	}

This is part of the second class attempting to retreive the values

public class SandwichShop extends JApplet
{
	private static final long serialVersionUID = 1L;
	private CheeseBread Panel1= new CheeseBread();
		private String one, two, three;
	private JTextField wow = new JTextField(9);
	
	public void init()
	{
		JPanel bigpanel = new JPanel();
		
		bigpanel.setLayout(new BoxLayout(bigpanel, BoxLayout.Y_AXIS));
		bigpanel.add(Panel1);
		bigpanel.add(Panel2);
		bigpanel.add(Panel3);
		bigpanel.add(Panel4);
		bigpanel.add(dumb);
		String test= ("wow");
		getContentPane().add(bigpanel, "Center");
		MeatBreadCheese.calcMPrice(wow);
		
		
		
		two = Panel1.rBread();
		three = Panel1.rCheese();
		wow.setText(test);
		System.out.print(wow);
		setSize(500,500);
	}
}
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by NormR1
0

I am trying to access a varible value from a return fuction in another class.

What code are you talking about?
You need to give the name of the class, the name of the method and indicate with easy to see comments where you are calling the method.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.