vendredi 17 juin 2016

Where to define JavaSwing elements?

I have a question about good programming style.

I have multiple JPanel components that change the appearance of the content on my frame. For selection I use a JMenu.

Now it is that I have repeating JLabel components on each of these panels. For example I have on 5 Panels the JLabel("Name"), same goes for JTextArea components and other Swing elements.

My question is:

  • Do I really have to program all of these all over again?
  • Should I make something like an interface I define all my components in?
  • Should I try to minimize the panels and make special classes for every single one?
  • Should I use getters and setters to get them from other classes, rather then defining them all over again?

How do you solve those problems?

Aucun commentaire:

Enregistrer un commentaire