i am working with a piglatin translator that has a GUI but i am stuck on how to make it translate when i you push the translate button here is my GUI
what is in red is were the error occurs
if someone could help i would appreciate it
thanks in advance
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.Character.*;
//make this class "is-a" JFrame and "act-like" an action listener
public class AWindowEx1 extends JFrame implements ActionListener
{
protected PigLatin2 pig;
public static final int WIDTH = 400;
public static final int HEIGHT = 350;
public static int NUMBER_OF_CHAR = 700;
private JTextField win;
public static void main(String[ ] args )
{
AWindowEx1 win = new AWindowEx1();
win.setVisible(true);
//create an instance of your class
//make the window visible
}
public AWindowEx1()
{
super("piglatin");
//call the parent class constructor passing title
setSize(WIDTH,HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(2,1));
setLocation(100,200);
setVisible(true);
JPanel winPanel = new JPanel();
winPanel.setLayout(new BorderLayout());
winPanel.setBackground(Color.WHITE);
win = new JTextField(NUMBER_OF_CHAR );
winPanel.add(win,BorderLayout.SOUTH);
JLabel winLabel = new JLabel("piglatin:");
winPanel.add(winLabel,BorderLayout.CENTER);
add(winPanel);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout());
buttonPanel.setBackground(Color.MAGENTA);
JButton actionButton = new JButton("translate");
actionButton.addActionListener(this);
buttonPanel.add(actionButton);
JButton clearButton =new JButton("clear");
clearButton.addActionListener(this);
buttonPanel.add(clearButton);
add(buttonPanel);
}///end window
public void actionPerformed(ActionEvent e)
{
[COLOR="Red"]String actionCommand = e.getActionCommand();
if(actionCommand.equals("translate"))
win.getWord(pig.translateLine());[/COLOR]
else if(actionCommand.equals("clear"))
win.setText("");
else
win.setText("unexpected error");
/*String cmd = e.getActionCommand();
if(cmd.equals("EXIT"))
System.exit(0);
*/
//if the action command is "Exit"; end the application
}
}