• Post Reply Bookmark Topic Watch Topic
  • New Topic

help me with this program.

 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import javax.swing.*;
import java.awt.Component;
class GuiDemo {

public static void main(String args[]) {

JFrame frame=new JFrame("dfdf");

frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().add(yellowLabel, BorderLayout.CENTER);


}
}


/********** why i am getting errors? ************/
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of errors are you getting? I noticed that the class is not public.
 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GuiDemo.java:12: cannot find symbol
symbol : variable yellowLabel
location: class GuiDemo
frame.getContentPane().add(yellowLabel, BorderLayout.CENTER);
^
GuiDemo.java:12: cannot find symbol
symbol : variable BorderLayout
location: class GuiDemo
frame.getContentPane().add(yellowLabel, BorderLayout.CENTER);
^
2 errors

/*********** these are the errors************/
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those two errors are rather to the point aren't they? The compiler complains that it doesn't know what "BorderLayout" and "yellowLabel" are.
 
Mark Newton
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you actually declared and initialised yellowLabel?

It seems like you're very new to Java, if that's so, this isn't the right place to be asking questions. You should start by doing something like running through Sun's Java tutorial:

http://java.sun.com/docs/books/tutorial/

and probably find a book - JavaRanch has a section on recommended books.

For specific questions, people here are usually pretty willing to help, but you'll probably find you get better reactions in the Java In General (beginner) forum, than in these more specific areas.

Finally, as a word of advice, if you want help, demanding that people, "help me with this program" is never going to get into people's good books. Read JavaRanch's FAQs on how to ask good questions.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!