Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Recreating Component GUIs  RSS feed

 
Tom Josephits
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am making a bunch of swing components that I need to look just like existing ones (such as JButton and JComboBox), but need to extend another abstract class I made. Is there anyway I could make the gui look the same as those ones?
 
Paul Clapham
Sheriff
Posts: 22472
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a GUI component which looks just like a JButton, but which needs to extend some other class? That's not a good idea (partly because you can't do it, as you already found). Perhaps you should try composition instead of inheritance? This would involve writing a class which extends your abstract class and which contains a JButton. You would then just put that JButton into your GUI, and write the code extending your abstract class which works with that JButton.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!