i have a error in this program...i m tryin to write a java GUI program that converts character to corresponding integer and vice versa...tis is my code...can anyone help me solve the error???the error is :

1 error found:
File: C:\Users\Kumaresen Nair\Desktop\Conversion.java [line: 58]
Error: The local variable word may not have been initialized

this is my program code

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Conversion extends JFrame
{
    private JLabel wordLabel;
    private JLabel numberLabel;
    private JTextField wordTF;
    private JTextField numberTF;
    private WordHandler wordHandler;
    private NumHandler numberHandler;
    private static final int WIDTH = 500;
    private static final int HEIGHT = 50;
    public Conversion()
    {
        setTitle("Word and Number Conversion");
        Container c = getContentPane();
        c.setLayout(new GridLayout(1, 4));
        wordLabel = new JLabel("String : ",
                                  SwingConstants.RIGHT);
        numberLabel = new JLabel("Number : ",
                                     SwingConstants.RIGHT);
        wordTF = new JTextField(7);
        numberTF = new JTextField(7);
        c.add(wordLabel);
        c.add(wordTF);
        c.add(numberLabel);
        c.add(numberTF);
        wordHandler = new WordHandler();
        numberHandler = new NumHandler();
        wordTF.addActionListener(wordHandler);
        numberTF.addActionListener(numberHandler);
        setSize(WIDTH, HEIGHT);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
    }
    private class WordHandler implements ActionListener
    {
        public void actionPerformed(ActionEvent e)
        {
           String word;
            int number;
             number = Integer.parseInt(word);
            numberTF.setText(" " +number);
        }
    }
    private class NumHandler implements ActionListener
    {
        public void actionPerformed(ActionEvent e)
        {
          int number = 110;
String word;
word = Integer.toString(number);
  wordTF.setText(" " +word); 
        }
    }
    public static void main(String[] args)
    {
    }
}
Member Avatar for stbuchok

You might want to move this into the Java forum as you have posted this in the JavaScript forum (two completely differently things).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.