title: Lwjgl GUI library
body: <p>I'm trying to make a little lwjgl GUI library by myself. I started again for 3 times now. My problem is that I fail to create a good OOP design.
  I looked at the Java built in library Swing and AWT.
  I dit read the codes, and studied the class design of Swing and AWT.
  But I think this is not the correct way to make my own GUI library for lwjgl, because it's something with much differences.
  One of my biggest problems I Always have in OO is that I can't reach a method. I think this is a general programming problem. For example, I have the following classes:</p>
  
  <pre><code>    class Container {
  
          private ArrayList&lt;Component&gt; components = new ArrayList&lt;Component&gt;();
  
          public void add(Component c) { // Accepts only Component objects, or child objects of Component
  
              this.components.add(c);
          }
  
          public volid paintAll() {
  
              for(int i = 0; i &lt; this.components.size(); i++) {
  
                   // Not possible, the Component object has no method paintComponent(), the
                   // class which extends Component does. This can be a button, but it's stored as 
                   // a Component. So the method paintComponent "Does not exist" in this object,  
                   // but is does.
                   this.components.get(i).paintComponent(); // error
              }
          }
      }
  
  class Component {
  
      private int x;
      private int y;
      private int width;
      private int height;
  
      /* methods of Component class */
  }
  
  class Button extends Component {
  
      private String text;
  
      public Button(String text) {
  
          this.text = text;
      }
  
      public void paintComponent() {
  
          /* Paint the button */
  
      }
  }
  
  // In Swing, the Component class has no method like paintComponent.
  // The container can only reach the methods of Component, and can not use methods of
  // classes which extends Component.
  // That's my problem. How can I solve this?
  
  Container container = new Container();
  Button b = new Button("This is a button");
  Container.add(b); // b "Is a" Component.
  </code></pre>