import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class JHelloFrame extends JFrame implements ActionListener{
		
		JLabel question= new JLabel("What is your name");
		Font bigFont= new Font("Arial",Font.BOLD,16);
		JTextField answer= new JTextField(12);
		JButton pressMe=new JButton("RressMe");
		JLabel greeting= new JLabel("");
		final  int Width=175;
		final int Height=225;
		public JHelloFrame()
		{
			super("Hello Frame");
	      setSize(Width,Height);
	   	setLayout(new FlowLayout());
			question.setFont(bigFont);
			greeting.setFont(bigFont);
			add(question);
			add(answer);
			add(pressMe);
			add(greeting);
			setVisible(true);
			setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			pressMe.addActionListener(this);
				}
			
			public void ActionListener(ActionEvent e){
			
				String name=answer.getText();
				String greet="Hello,"+name;
				greeting.setText(greet);
				}
		
	}

MAIN

public class JHelloDemo
	{
		public static void main(String [] args){
			
		JHelloFrame Frame= new JHelloFrame();
		}
			}

Can you please identify what the problem it doesn't run

this is the error

public class JHelloDemo
{
public static void main(String [] args){

JHelloFrame Frame= new JHelloFrame();
}
}

You posted the error wrong, you just posted your main class again.

Besides that, It looks like your problem lies with your actionPerformed method. You don't have one. You call a method

public void ActionListener(ActionEvent e){
 
				String name=answer.getText();
				String greet="Hello,"+name;
				greeting.setText(greet);
				}

it should be

public void actionPerformed(ActionEvent e){
 
				String name=answer.getText();
				String greet="Hello,"+name;
				greeting.setText(greet);
				}

Edited 5 Years Ago by Akill10: n/a

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class JHelloFrame extends JFrame implements ActionListener{
 {		
		JLabel question= new JLabel("What is your name");
		Font bigFont= new Font("Arial",Font.BOLD,16);
		JTextField answer= new JTextField(12);
		JButton pressMe=new JButton("RressMe");
		JLabel greeting= new JLabel("");
		final  int Width=175;
		final int Height=225;
		public JHelloFrame()
		{
			super("Hello Frame");
	      setSize(Width,Height);
	   	setLayout(new FlowLayout());
			question.setFont(bigFont);
			greeting.setFont(bigFont);
			add(question);
			add(answer);
			add(pressMe);
			add(greeting);
			setVisible(true);
			setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			pressMe.addActionListener(this);
				}
			
			public void actionPerformed(ActionEvent e){
			
				String name=answer.getText();
				String greet="Hello,"+name;
				greeting.setText(greet);
				}
		
	}

It has problem

the errors

----jGRASP exec: javac -g C:\Documents and Settings\Home\Desktop\GUI programs\JHelloDemo.java
---- at: Dec 22, 2010 10:31:43 PM

----jGRASP wedge: pid for wedge is 3984.
----jGRASP wedge2: pid for wedge2 is 976.
----jGRASP wedge2: CLASSPATH is ".;;.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;C:\Program Files\jgrasp\extensions\classes".
----jGRASP wedge2: working directory is [C:\Documents and Settings\Home\Desktop\GUI programs] platform id is 2.
----jGRASP wedge2: actual command sent ["C:\Program Files\Java\jdk1.6.0\bin\javac.exe" -g "C:\Documents and Settings\Home\Desktop\GUI programs\JHelloDemo.java"].
----jGRASP wedge2: pid for process is 3780.

.\JHelloFrame.java:14: illegal start of expression
public JHelloFrame()
^
.\JHelloFrame.java:17: cannot find symbol
symbol : variable Width
location: class JHelloFrame
setSize(Width,Height);
^
.\JHelloFrame.java:17: cannot find symbol
symbol : variable Height
location: class JHelloFrame
setSize(Width,Height);
^
.\JHelloFrame.java:19: cannot find symbol
symbol : variable bigFont
location: class JHelloFrame
question.setFont(bigFont);
^
.\JHelloFrame.java:19: cannot find symbol
symbol : variable question
location: class JHelloFrame
question.setFont(bigFont);
^
.\JHelloFrame.java:20: cannot find symbol
symbol : variable bigFont
location: class JHelloFrame
greeting.setFont(bigFont);
^
.\JHelloFrame.java:20: cannot find symbol
symbol : variable greeting
location: class JHelloFrame
greeting.setFont(bigFont);
^
.\JHelloFrame.java:21: cannot find symbol
symbol : variable question
location: class JHelloFrame
add(question);
^
.\JHelloFrame.java:22: cannot find symbol
symbol : variable answer
location: class JHelloFrame
add(answer);
^
.\JHelloFrame.java:23: cannot find symbol
symbol : variable pressMe
location: class JHelloFrame
add(pressMe);
^
.\JHelloFrame.java:24: cannot find symbol
symbol : variable greeting
location: class JHelloFrame
add(greeting);
^
.\JHelloFrame.java:27: cannot find symbol
symbol : variable pressMe
location: class JHelloFrame
pressMe.addActionListener(this);
^
.\JHelloFrame.java:32: cannot find symbol
symbol : variable answer
location: class JHelloFrame
String name=answer.getText();
^
.\JHelloFrame.java:34: cannot find symbol
symbol : variable greeting
location: class JHelloFrame
greeting.setText(greet);
^
14 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

You put an extra { at the top of your JHelloFrame class. It's messsing up everything else.

public class JHelloFrame extends JFrame implements ActionListener{
 {	//your problem

I recommend using an IDE which compiles as you write, you can find errors much quicker

Edited 5 Years Ago by Akill10: n/a

thanks guys for helping me i'm just new in GUI....I'm still trying to learn more.
can anyone of you here that is already master in GUI give me some idea how to learn easily.......

THANKS: :)

I can't say what the best way for you to learn is, but for me, I used tutorials on youtube and stuff. A good tutorial maker is www.thenewboston.com and look under java/intermediate java/java game development in the programming section on the left.
He is a really good teacher and explains stuff pretty well.
Good luck!

"I recommend using an IDE which compiles as you write, you can find errors much quicker"
This is not the good way to really learn (my opinion)

"I recommend using an IDE which compiles as you write, you can find errors much quicker"
This is not the good way to really learn (my opinion)

But since he's just starting GUI's, I assume he already has basic java under his belt. Trying to learn something like GUI's without some sort of text editor is a bad idea.

This article has been dead for over six months. Start a new discussion instead.