PDA

Click to See Complete Forum and Search --> : Help!!


308holes
May 11th, 2002, 12:57 AM
Ok i have been messing with his in Jbuilder5 for 2 days and its not working at all im getting this error
"Could not Find Main Mothod Program will exit"


package ButtonApplet;

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class ButtonApplet extends Applet implements ActionListener
{
//Declare components
TextField txtDept = new TextField(15);
TextField txtName = new TextField(20);
TextField txtPhone = new TextField(5);
TextArea txaPhoneList = new TextArea(10,30);
Button btnAdd = new Button("Add to List");
//Declares Var
String strDept;
String strName;
String strPhone;

public void init()
{
//Place components on Applet

add(new Label("Department: "));
add(txtDept);
add(new Label("Name: "));
add(txtName);
add(new Label("Extension: "));
add(txtPhone);
add(btnAdd);
add(txaPhoneList);
txtDept.requestFocus();

//Add Action Listeners
btnAdd.addActionListener(this);
txtDept.addActionListener(this);
txtName.addActionListener(this);
txtPhone.addActionListener(this);

}

public void actionPerformed(ActionEvent event)
{
//Action for "Add to List"
//Triggered when the user click on the Button or press the Enter Key
//in any Text Field

String strOutPutLine;

//Assign the Text Field to a Variable
strDept = txtDept.getText();
strName = txtName.getText();
strPhone = txtPhone.getText();

//Concatenate the Variables
strOutPutLine = strDept + "\t" + strName + "\t" + strPhone;
//Append the concatenated line to the phone list
txaPhoneList.append(strOutPutLine + "\n");

//Clears the Text Fields
txtDept.setText("");
txtName.setText("");
txtPhone.setText("");

//Set the Focus
txtDept.requestFocus();
}
}

Cudabean
May 11th, 2002, 02:36 PM
Will your JBuilder5 compile a simple applet like this:


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

public class Applet1 extends JApplet {
public void init() {
getContentPane().add(new JLabel("Applet!"));
}
}


Also, have you tried compiling outside of JBuilder5 using the javac command on the commandline? Have you successfully compiled and run anything using JBuilder5?

cudabean

308holes
May 11th, 2002, 03:14 PM
No same Error

Cudabean
May 11th, 2002, 05:08 PM
Y'know, it could be the case that JBuilder, for whatever reason, is not aware that it has an applet and instead is trying to execute it. Executing applets is usually not appropriate (sometimes it is, if you write the class to be a dual applet/application). I've not used JBuilder, but there's probably some compiler option that needs to be checked to tell JBuilder to handle your class as an applet at runtime.

cudabean

Mrs Kensington
May 14th, 2002, 04:03 AM
JCreator!!!!!!!!!!!!!!!!
www.jcreator.com (http://www.jcreator.com)
There is a free version available. It has no GUI creater but real men/women write gui's with notepad!

honeybee
May 14th, 2002, 09:40 AM
There's also Forte from sun microsystems and NetBeans from I think www.netbeans.org.

.

308holes
May 15th, 2002, 01:49 AM
JCreator works SOO MUCH BETTER THANKS !!!!

joan_fl
May 16th, 2002, 09:38 AM
Ok i have been messing with his in Jbuilder5 for 2 days and its not working at all im getting this error

Check your project properties in the tab RUN. You'll see settings for application & applet. That should fix your problem in JBuilder.

Joan