Next level of complexity ;-)
Classes are usually created inside "packages". A package is a logical collection of related classes. eg. The package java.awt contains all the main abstract windowing toolkit classes like Frames, Windows, Buttons etc.
If you want your class to be able to access a Button, you "import" the class into your .java file:
import java.awt.Button;
public class MyClass2
{
private Button myButton;
.
.
}
Main Topics
Browse All Topics





by: jimmackPosted on 2003-11-01 at 15:52:32ID: 9664346
If you have a class called MyClass, you create an "instance" of it (an object) like this:
MyClass myObject = new MyClass();
If the MyClass has a method called "getName()", you tell the object you created to get the name like this:
String theName = myObject.getName();
The class would look like this:
public class MyClass
{
private String name;
public MyClass()
{
name = "example";
}
public String getName()
{
return (name);
}
}
Java IDE's. Try:
http://www.netbeans.org
http://www.eclipse.org
Good luck ;-)