0

I have to use Frame not JFrame. I have to use BorderLayout. I created a

class A extends Frame{}

class B extends Frame{}

and I woule like to add instance of class A into class B but what I get is another window. I want to make that A is "subframe" to B it is inside of it.

class B{  
...
    setLayout(new BorderLayout());
        Panel p = new Panel();
        a = new A();
        p.add(a);
        add(a, BorderLayout.CENTER);
....
}
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Yoda
  • 17,363
  • 67
  • 204
  • 344
  • 2
    Use a `CardLayout`. See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) This is mentioned around every 8 hours on SO. *"I have to use `Frame` not `JFrame`."* Why? – Andrew Thompson May 02 '13 at 09:27
  • I have to use `BorderLayout` did not supsect this kind of answer was coming so I didn't write it. – Yoda May 02 '13 at 09:28
  • *"I have to use `BorderLayout`"* ***Why?*** – Andrew Thompson May 02 '13 at 09:29
  • Because stupid teacher of my student said so. Sorry I am angry I understand stupidity of that demand. – Yoda May 02 '13 at 09:29
  • OK - a `Panel` with a `CardLayout` can be put inside a constraint of a `BorderLayout` (or vice-versa). But do me a favor & drag your teacher, kicking & screaming if need be, into this millennium. Most Java GUI developers have never used AWT, and those of us who did, have largely forgotten the details. – Andrew Thompson May 02 '13 at 09:32
  • Also, now I notice. The code should not `extend` frame. Just use an instance of one. – Andrew Thompson May 02 '13 at 09:33

0 Answers0