0

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)
    {
    }
}
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by stbuchok
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.