0

I am currently writing a Game Engine in Java and I reached a point where I think about creating my own types of Buttons, Lists and so on.

I can't just create awt Components and change their behavior because I want them to have different shapes, textures etc.

Should I extend Button in a new Class , say MyOwnButton.class and modify it's inhitered methods or create a new Button from scratches?

What would give me a better Performance?

user263980
  • 31
  • 1
  • 6
  • Yes. Never recreate the wheel. – yitzih Mar 03 '15 at 06:03
  • If you really want to do that, then using Swing's `AbstractButton` or `JComponent` as the superclass is probably a good option. They are meant for light-weight components (that are drawn by Java code rather than the operating-system peer widgets) and insulate you somewhat from the problems you'd get if you inherited from `Component` directly. – Erwin Bolwidt Mar 03 '15 at 06:09
  • @ErwinBolwidt Good advice, so long as the OP isn't intending to use a `BufferStrategy` to render the game, then they should be using Swing at all (and even AWT might cause issues) – MadProgrammer Mar 03 '15 at 06:13
  • I DO want to draw using BufferStrategy, but why does this cause problems? – user263980 Mar 03 '15 at 06:17
  • Dp you really mean the app. is using AWT components? Why use AWT? See [this answer](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) for many good reasons to abandon AWT using components in favor of Swing. – Andrew Thompson Mar 04 '15 at 05:52
  • Hey there. I separated your paragraph in sentences which now express in a clearer way what you need. It is a good idea to write your question in a way that makes the actual sentence of the question stand out. – Félix Adriyel Gagnon-Grenier Mar 06 '15 at 23:10

0 Answers0