By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,798 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,798 IT Pros & Developers. It's quick & easy.

Please:need a urgent help

hirak1984
100+
P: 316
When i am calling this class from another class only a blank frame appears,with nothing on it.I dont know where the problem is,Please help.
Expand|Select|Wrap|Line Numbers
  1.  class project extends JFrame{ 
  2. public void project() {
  3. //JFrame frame=new JFrame();
  4.   jtf = new JTextField(3);
  5.   jtf1 = new JTextField(15);
  6.   JPanel p1 = new JPanel();
  7.   p1.add(new JLabel("SID"));
  8.   p1.add(jtf);
  9.   p1.add(new JLabel("User name:"));
  10.   p1.add(jtf1);
  11.   p1.add(new JLabel("Password:"));
  12.   p1.add(pass);
  13.   p1.setSize(200,200);
  14.   this.getContentPane().add(p1);
  15.   JButton submit = new JButton("SUBMIT");
  16.   submit.setActionCommand("submit");
  17.   submit.addActionListener(this);
  18.  
  19.   JButton reset = new JButton("RESET");
  20.   reset.setActionCommand("reset");
  21.   reset.addActionListener(this);
  22.  
  23.   JPanel p2 = new JPanel();
  24.   p2.add(submit);
  25.  
  26.   p2.add(reset);
  27.   //contentPane.add("Center", p2);
  28.   //p2.setSize(200,200);
  29.   this.setVisible(true);
  30.   this.setVisible(true);
  31.   this.getContentPane().add(p2);
  32.   this.setSize(500,500);
  33.   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  34.  
  35.  }
  36. }
  37.  
Jan 30 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 1,510
I assume the project() method is a constructor?
Expand|Select|Wrap|Line Numbers
  1. public void project() {
  2.  
if so it should not have a return type, e.g.
Expand|Select|Wrap|Line Numbers
  1. public project() {
it may then appear when you create a new project();
Jan 30 '07 #2

10K+
P: 13,264
I assume the project() method is a constructor?
Expand|Select|Wrap|Line Numbers
  1. public void project() {
  2.  
if so it should not have a return type, e.g.
Expand|Select|Wrap|Line Numbers
  1. public project() {
it may then appear when you create a new project();
Make it a habit to name your classes starting with a capital Letter e.g
Expand|Select|Wrap|Line Numbers
  1. class Project
and your methods should begin with a small letter. horace1 is right. Constructors do not have a return type (void is a return type). Read the Java classes in this forum.
Jan 30 '07 #3

hirak1984
100+
P: 316
Hey buddies it worked!!!!!!!!!!!!11
i only removed "void" from the constructor.
thanks for all the pain u took to read my code and figure out the error.
This is why thescripts is the best of its kind on the net.


Make it a habit to name your classes starting with a capital Letter e.g
Expand|Select|Wrap|Line Numbers
  1. class Project
and your methods should begin with a small letter. horace1 is right. Constructors do not have a return type (void is a return type). Read the Java classes in this forum.
Jan 30 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.