Hi Everyone,
At the moment I have a GUI class and associated method that contains several buttons. When one of the buttons is pressed I need to create an object from a totally different class.
i.e.:
public class GUI extends JFrame implements ActionListener{
JButton btn1 = new JButton(“Calculate”);
GUIV()
{
Con = getContentPane();
Con.add(btn1);
Btn1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals(“Calculate”))
{
String str = …;
//Create an object from a totally different class, e.g. CalculateX
//Passing the CalculateX object of the CalculateX class the value
//of String str.
}
}
public void CalculateX{
String Calc = str (…from the GUI class)
If anybody can help with code that does something along these lines it will be greatly appreciated.
Thanks
At the moment I have a GUI class and associated method that contains several buttons. When one of the buttons is pressed I need to create an object from a totally different class.
i.e.:
public class GUI extends JFrame implements ActionListener{
JButton btn1 = new JButton(“Calculate”);
GUIV()
{
Con = getContentPane();
Con.add(btn1);
Btn1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals(“Calculate”))
{
String str = …;
//Create an object from a totally different class, e.g. CalculateX
//Passing the CalculateX object of the CalculateX class the value
//of String str.
}
}
public void CalculateX{
String Calc = str (…from the GUI class)
If anybody can help with code that does something along these lines it will be greatly appreciated.
Thanks