Originally Posted by
Nieuwenhuizen-jk
I made an answer yesterday, as far as I know posted it, at 11 sep but do not see it back.
Are you sure it's not on the first page?
Originally Posted by
Nieuwenhuizen-jk
But I looked back and think I understand most of KevinWorkman's reaction of 2011-09-08T13:05:
The compiler does not "understand" how to handle a constructor without data
public JButton() {
this(null, null);
}
and instead go going back where it came from goes to the second, third, fourth
public JButton(Icon icon) {
this(null, icon);
}
public JButton(String text) {
this(text, null);
}
public JButton(Action a) { // skipped, different parameter class
this();
setAction(a);
}
and eventually arrives at
public JButton(String text, Icon icon) {
// Create the model
setModel(new DefaultButtonModel());
// initialize
init(text, icon);
}
No. It doesn't go from one to the other to eventually arrive. This line from the no-args constructor:
this(null, null);
Directly calls the two-args constructor.
Originally Posted by
Nieuwenhuizen-jk
finds SetModel in Abstract... line 1718, I don't know where it finds DefaultButtonModel ( not in Abstract..., not in JComponent} although Abstract... uses it in line 1297 and finds init in Abstract...line 2139
Huh? What do you mean "where it finds"? What do you mean by any of this, actually?
Originally Posted by
Nieuwenhuizen-jk
But I do not see why this is better than
public JButton(String text, Icon icon) {
if(text != null) { // copied from init(String
setText(text);
}
if(icon != null) {
setIcon(icon);
}
// Set the UI
updateUI();
setAlignmentX(LEFT_ALIGNMENT);
setAlignmentY(CENTER_ALIGNMENT);
}
}
It's simply a short cut. People don't love passing in null arguments. That's it. No magic.
Originally Posted by
Nieuwenhuizen-jk
Do I ask to much if I say : "Can you please explain to me why this is not? ( I have an habit in trying to understand why people do better jobs than I do )"
What? Why what is not?
Originally Posted by
Nieuwenhuizen-jk
And I am always open for good advices to solve the "TripleButton" problem, sketched before?
What TripleButton problem?
You seem to have a pretty basic misunderstanding of how Java works. Before you dive into Swing source code, I highly recommend starting over at the beginner tutorials.