Swing - Changing text in JTextArea from void
I am having a problem with changing text in a JTextArea from a void..
My Code:
Code:
/*
* Class: Pie
*/
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPopupMenu;
import javax.swing.JTextArea;
import javax.swing.UIManager;
public class Pie extends JFrame implements ActionListener
{
String type = "Nothing";
public Pie()
{
super("Pie Machine");
try
{ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JFrame.setDefaultLookAndFeelDecorated(true);
JPopupMenu.setDefaultLightWeightPopupEnabled(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton meat = new JButton("Meat");
JButton apple = new JButton("Apple");
JButton make = new JButton("Make Pie!");
JTextArea area = new JTextArea();
area.setColumns(20);
area.setLineWrap(true);
area.setRows(5);
area.setWrapStyleWord(true);
make.addActionListener(this);
meat.addActionListener(this);
apple.addActionListener(this);
FlowLayout bord = new FlowLayout();
setLayout(bord);
//add("North", lbl);
add("Center", meat);
add("Center", apple);
add("Center", area);
//add("Center", make);
pack();
setVisible(true);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void actionPerformed(ActionEvent evt)
{
String cmd = evt.getActionCommand();
if (cmd != null)
{
if (cmd.equalsIgnoreCase("Apple"))
{
isApple();
}
if (cmd.equalsIgnoreCase("Meat"))
{
isMeat();
}
}
}
public void isMeat()
{
}
public void isApple()
{
}
public static void main(String[] arguments)
{
Pie frame = new Pie();
frame.setSize(250, 250);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
}
}
In the isApple() and isMeat() voids, how would I change the text of the JTextArea?