R
R
roman38472014-03-13 21:02:10
Java
roman3847, 2014-03-13 21:02:10

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

1 answer(s)
R
Ruslan Lopatin, 2014-03-13
@roman3847

JButton myButton = new JButton("myButton") {{setBackground(Color.yellow);}};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question