• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help me Please!!!  RSS feed

 
Craig Snowbarger
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got three windows in my application so far. The first one is a "public" dialog window with a place for the user to enter their username and password. There are two buttons below the username and password fields labeled "Login" and "New User" respectively. I have an actioneventlistener attached to the "Login button" that, when clicked, opens the main application window if the username and password are found in the database. I got that far and every thing worked great until I attached an action listener to the "New User" button. The "New User" button should open up a dialog box that has fields to enter appropriate info., but I can't get it to compile. I get this when I compile:
bin/TST.java [141:1] No constructor in bin.NewUser matches <init>()
new NewUser().show();
^
1 error
I don't understand what I'm doing wrong.
HELP!!!
Craig Snowbarger
 
Chris Perkins
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you tried to call a no-arg constructor for the NewUser class when there isn't one. You probably wrote at least one other constructor, which means the compiler didn't supply a no-arg constructor for you. you should write one.
 
Craig Snowbarger
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to forgive me, but I'm still pretty new at Java, so can you give me an example of a no-arg constructor?
 
Angela Lamb
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A no-arg constructor is just a constructor with no arguments. For example:

public NewUser() {
// constructor code
}


If you don't supply any constructors for a class, a no-arg constructor is automatically created for you. If you have other constructors, though, it will not be created.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!