Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Confusion  RSS feed

 
Khadija Lokhandwala
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am learning Swing and was really stuck wit this
I have a JMenu Class named "Vertical Menu" which I have customised.
I have over ridden the setFont() method and it is working fine. I wanted to override the setPreferredSize() method too, but size was not reflecting. So I placed it in the "Vertical Menu"'s constructor. And it worked.

The question is: why did setPreferredSize() method work after placing it in the constructor?? if so then, how does the overridden method work.

P.S : setFont() was invoked on the VerticalMenu Object
i.e i did not do
VerticalMenu menu = new VerticalMenu();
menu.setFont();

Thank You
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if I'm reading this correctly, the method you override should be
getPreferredSize()

putting setPreferredSize in the constructor executes that call
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!