Answer the question
In order to leave comments, you need to log in
Is it possible in Java JPanel in the constructor to pass the color of the panel?
And how to do it?
For example for JButton. Setting the label on the button.
myButton.setText("myButton"); or JButton myButton = new JButton("myButton");
I know that the panel color can be set using the setBackground(Color.yellow) method. Is it possible to specify the color that you need right when creating the panel?
Answer the question
In order to leave comments, you need to log in
JButton myButton = new JButton("myButton") {{setBackground(Color.yellow);}};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question