CS Java 1110 Notes - methods of JFrame too, the brackets...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS Java 1110 {BOOK} 1.4 – Customizing a Java class *if you want to add a new method to a class, you have to add on to a new class, for example, add on to class JFrame *the subclass with the new method (OurFrame) has superclass JFrame: import javax.swing.*; (this makes the method available to all classes in the package javax swing public class (name of your method) OurFrame extends JFrame { (public class makes this class accessible to other classes, extends means I tis an add on to JFrame, meaning OurFrame will have all the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: methods of JFrame too, the brackets means the start of the method) /**write the purpose of the new method here*/ Public void setTitleToOrigin() { (public void means that it is accessible from anywhere and that it is a method, setTitleToOrigin is the name of this new method) Method here, as in, this.setTitle((+this.getX()+), (+this.getY() +)) (this means that it is this instance, since we didnt create a variable for this)...
View Full Document

Ask a homework question - tutors are online