Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first thing to note in your code is this:</p> <pre><code>super("The title"); </code></pre> <p>This actually calls the <code>JFrame</code> constructor, and passed it <code>"The title"</code> as a title String. This is an explicit example of using the <code>Jframe</code> functionality in your code. This will build the window that appears for you.</p> <p>Using methods like <code>add</code> are all inherited from the <code>JFrame</code> class. These add <code>Components</code> to the JFrame object.</p> <p><b> Why Inheritance? </b></p> <p>Well, simply, your class IS a JFrame, with a little more. When you have a <code>Is A</code> operation, you use inheritance. The other advantage of this method is that your class can be referred to as a JFrame. That is:</p> <pre><code>JFrame tuna = new tuna(); // Note: All classes are meant to start with a capital letter. </code></pre> <p><b> Another viewpoint </b></p> <p>It's important to note that you don't strictly HAVE TO inherit from a JFrame class. You can use <code>Composition</code>. In this instance you'd have something like:</p> <pre><code> public class Tuna { private JFrame parentWindow; // Rest of class. } </code></pre> <p>As mentioned above, the convention is to follow the <code>Is A</code> and <code>Has A</code> approach. If class <code>A</code> Is an example of class <code>B</code>, we tend to use inheritance. If class <code>A</code> has an instance of class <code>B</code>, then you use composition, although in most cases, inheritance is interchangeable with Composition.</p> <p><b> Another another Viewpoint </b></p> <p>As mentioned in the comments, you should always look for an existing API that offers this kind of functionality, before attempting to implement it yourself.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload