Hey guys Im having trouble with my interface java program I have it all set up but im getting an error on my lowercase button and uppercase. is there a certaint type of formate this needs to be in for interface?
here is my code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Week_ten_number_thirty_eight extends JFrame
{
private Container contents;
private JLabel inputLabel, resultLabel, result;
private JTextField wordInput;
private JButton Lowercase, Uppercase;
public Week_ten_number_thirty_eight()
{
super("Lowercase or Uppercase?");
contents = getContentPane();
contents.setLayout(new FlowLayout());
inputLabel = new JLabel("Enter a single word");//text field label
wordInput = new JTextField(8);//text field is 8 characters wide
//instantiate buttons
Lowercase = new JButton("Lowercase");
Uppercase = new JButton("Uppercase");
resultLabel = new JLabel("Result");//label for result
result = new JLabel ("???");//label to hold result
//add components to the window
contents.add(inputLabel);
contents.add(resultLabel);
contents.add(result);
contents.add(wordInput);
contents.add(Lowercase);
contents.add(Uppercase);
//instantiate our event handler
ButtonHandler bh = new ButtonHandler();
Lowercase.addActionListener(bh);
Uppercase.addActionListener(bh);
setSize(175,150);
setVisible(true);
}
//private inner class event handler
private class ButtonHandler implements ActionListener
{
//implement actionPerformed method
public void actionPerformed (ActionEvent ae)
{
if(ae.getSource() == Lowercase)
{
result.setText(wordInput.toLowercase());
}
else if (ae.getSource()==Uppercase)
{
result.setText(wordInput.toUppercase());
}
}
}
public static void main(String[] args)
{
Week_ten_number_thirty_eight out = new Week_ten_number_thirty_eight();
out.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
the errors are coming up on line 59 and 63
thanks guys.