I'm creating a GUI with SWING. Some of the buttons have a custom Action attached. My code looks like:
JButton btn = new JButton(text);
btn.setAction(new MyAction());
My action class constructor does:
super(text) //set the label of the button
My question is: since it seems wrong to me repeat the same parameters (the text) two times, how should i handle this? Create the button with no text and let the action set the text (maybe as a constructor parametere)? What is the correct way to handle this? Thanks