Results 1 to 4 of 4
Thread: Cannot find symbol
- 03-02-2011, 11:13 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 4
- Rep Power
- 0
Cannot find symbol
Anyone please correct my code, i am beginner of Java. What wrong wtih my coding.:confused:Java Code:import javax.swing.*; import javax.swing.JOptionPane; import java.awt.*; import java.awt.event.*; public class ClickImage extends JFrame implements ActionListener{ final static int FrameWidth = 350; final static int FrameHeight = 200; public ClickImage(){ JFrame FoodLabel = new JFrame("Favourite Food"); setSize(FrameWidth,FrameWidth); setVisible(true); JLabel heading = new JLabel("Please Select Your Favourite Food"); JLabel greeting = new JLabel(""); heading.setFont(new Font("Arial",Font.BOLD, 16)); JTextField answer = new JTextField(10); JButton btn1 = new JButton("Chinese Food"); JButton btn2 = new JButton("Fast Food"); JButton btn3 = new JButton("West Food"); JButton btn4 = new JButton("Mamak Food"); btn1.setToolTipText("Click it for Favourite"); setLayout(new FlowLayout()); add(heading); add(btn1); add(btn2); add(btn3); add(btn4); add(answer); add(greeting); btn1.addActionListener(this); setDefaultCloseOperation(EXIT_ON_CLOSE); } public void actionPerformed(ActionEvent e){ [COLOR="Black"]String name = answer.getText(); String greet = "Hello" + name; greeting.setText(greet);[/COLOR] } public static void main(String[] args){ ClickImage show = new ClickImage(); } }Last edited by Eranga; 03-02-2011 at 11:20 AM. Reason: code tags added
- 03-02-2011, 11:18 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What's the error you comes with?
- 03-02-2011, 11:31 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 4
- Rep Power
- 0
symbol : variable answer
location: class ClickImage
String name = answer.getText();
^
1 error
i get this error!!!!:confused:
- 03-02-2011, 11:36 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes, that error comes because the variable answer in your code.
Similar Threads
-
Cannot find symbol
By Johanis in forum New To JavaReplies: 18Last Post: 11-09-2010, 08:34 PM -
Can not find symbol ???
By AliceNewbie in forum New To JavaReplies: 1Last Post: 02-17-2010, 01:44 AM -
cannot find symbol
By GabWit in forum New To JavaReplies: 3Last Post: 01-25-2009, 12:13 AM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
cannot find symbol symbol : class Item location: package platypos.services.order
By officialhopsof in forum New To JavaReplies: 3Last Post: 05-01-2008, 08:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks