Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simple Hello World project

1 view
Skip to first unread message

John Meyer

unread,
Dec 2, 2005, 1:16:44 AM12/2/05
to
Okay, I'm starting out making a simple dialog box that takes input and
then puts it into a label. The problem is, I'm using the wizard to
generate the dialog box and it's complaining that there isn't a main()
function within it.

Using Borland JBuilder 2005 Foundation

Arthur Ore

unread,
Dec 2, 2005, 8:01:36 AM12/2/05
to
Hi John,

Every Java Application, Applet or Servlet needs any entry point that tells
it where to start running.

For an Application, this is defined by the method main, which has a
signature as follows

public static void main(String args[])
{
// code goes here.
}

You can either define a new class with a main method which instatiates your
dialogue or do it in the dialogue itself.

One way to get this to work is to add a main method to your dialogue as
follows.

public static void main(String args[])
{
JDialog myDialogue = new Dialog1();
myDialogue.setVisible(true);
}

Another way to do it would be to create a new class which creates an
instance of your dialgue.

public class RunMe
{
public static void main(String[] args)
{
Dialog1 myDialogue = new Dialog1();
myDialogue.setVisible(true);
}
}

Note you'll have to swat up on polymorphism, but in one methodI have created
an instance of a JDialog and in the other I have created an instance of the
new sub-class of the JDialog (created by the wizard so yours may be named
differently) called Dialog1.

You can do it either way in either method. The difference is that when it is
declared to be a Dialog1, the methods and variables that you have defined
will be visible to you. If you define it as a JDialog only the methods and
variables defined by Sun will be accessible. I won't labour the point here
as you didn't ask that question, but polymorphism is one of the most useful
parts of any object oriented language.

Arth

"John Meyer" <john.l...@gmail.com> wrote in message
news:438fe7de$1...@newsgroups.borland.com...

John Meyer

unread,
Dec 2, 2005, 8:53:56 AM12/2/05
to
Worked like a charm.
0 new messages