0

So I have a class called MyFrame that extends JFrame. I have added an object of another class named TabbedFrame as a component to MyFrame Class in MyFrame's constructor like

add(new TabbedFrame());
setTitle("Some Title");
setVisible(true);   

Now the class TabbedFrame extends another class called FrameDemo in which the frame title is defined as :

super ("Title One");

When I run it, I get Title One as my JFrame's title. But I think it should be Some Title since I've changed it in MyClass's constructor. Here's what the code is so far. Any help would be highly appreciated. Thanks.

public class MyFrame extends JFrame{
public MyFrame(){

add(new TabbedFrame());

setTitle("Some Title");


setVisible(true);

}


public static void main(String[] args){

MyFrame frame = new MyFrame();

}
}
tckmn
  • 57,719
  • 27
  • 114
  • 156
Ingila Ejaz
  • 399
  • 7
  • 25
  • Can you post the code for `TabbedFrame` class? – Shashank Kadne Nov 10 '12 at 17:13
  • And FrameDemo class extends...? – Branislav Lazic Nov 10 '12 at 17:32
  • FrameDemo simple extends JFrame branno88 – Ingila Ejaz Nov 10 '12 at 18:13
  • 1
    This question strangely appears similar to this [one](http://stackoverflow.com/q/13322306/1057230), asked a few hours before this one. Your question is hiding the actual information and revealing nothing much. Better would be to take a second look at your question and add the necessary information, so that it can be answered to it's right potential. – nIcE cOw Nov 10 '12 at 18:13
  • @ShashankKadne the TabbedFrame class extends FrameDemo. In FrameDemo, I see frame's title set by using 'super' keyword. – Ingila Ejaz Nov 10 '12 at 18:16
  • @IngilaEjaz Wait a second...Your TabbedFrame extends FrameDemo, and your FrameDemo extends JFrame, and than you are adding TabbedFrame on MyFrame which extends JFrame, right? How can you do that without of having a IllegalArgumentException? I'm totally confused. – Branislav Lazic Nov 10 '12 at 19:08
  • 1) For better help sooner, post an [SSCCE](http://sscce.org/). 2) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson Nov 11 '12 at 00:48
  • I have figured it out :) – Ingila Ejaz Nov 11 '12 at 12:20
  • The first thing I did wrong was that I extended it from JFrame. It should be TabbedFrame. Secondly, addTabbedFrame() would create the TabbedFrame's object in that case the frame's title would be Title One. So add.TabbedFrame must not be there. I shared the answer in case if anyone else goes as stupid as I went. lol – Ingila Ejaz Nov 11 '12 at 12:24

1 Answers1

0

The first thing I did wrong was that I extended it from JFrame. It should be TabbedFrame. Secondly,

addTabbedFrame() 

would create the TabbedFrame's object in that case the frame's title would be Title One. So add.TabbedFrame must not be there. I shared the answer in case if anyone else goes as stupid as I went. lol – Ingila Ejaz 19 hours ago

Ingila Ejaz
  • 399
  • 7
  • 25