How can I change the color of a button, not just the border around it?


Leila MOZAFFAR:

I want to change both the background and the foreground color of my button. I used setBackground and setForeground and setOpaque(true), and it worked for the foreground, not the button's background. There is something like a black border around the button, but I want the button itself to be black. how can i fix it?

this.closeButton = new JButton ("Close");
    this.closeButton.setBackground(Color.BLACK);
    this.closeButton.setForeground(Color.PINK);
    this.closeButton.setOpaque(true);

this is me

gourmet Show:

The "border" is provided by the appearance delegate. You can "disable" it by callingbutton.setBorderPainted

This may or may not meet your expectations

close button

JButton button = new JButton("Close");
button.setBackground(Color.BLACK);
button.setForeground(Color.PINK);
button.setBorderPainted(false);
button.setOpaque(true);

Related


How can I change the color of the Bootstrap border?

Cody Marshall Been trying to figure out how to change the color of my Bootstrap border without using the generic Bootstrap colors (aka <span class="border border-primary"></span> So I tried giving me borderan id and styling the id in the .CSS file as border-co

How can I change the color of the button?

hahoanghai.ueh I am new to android programming. How can I change the color of the button? <Button android:id="@+id/btn" android:layout_width="55dp" android:layout_height="50dp" android:layout_gravity="center" android:text="Button Text"

How can I change the outline color of the button?

username How can I make the blue outline color #D5A021 instead of blue when the user clicks the button? I think it might be related tobtn-primary HTML <a class="btn btn-primary btn-xl js-scroll-trigger" href="#services">Find Out More <i class="fa fa-chevron-do

How can I change the color of the button text?

Brown I want to click a button and change its text color and message properties. I got the button to change its color, but I need to change one of the color of its text. private void TurnGreen(Button button) { ColorBlock colors = button.colors; colors.

How can I change the color of the button?

hahoanghai.ueh I am new to android programming. How can I change the color of the button? <Button android:id="@+id/btn" android:layout_width="55dp" android:layout_height="50dp" android:layout_gravity="center" android:text="Button Text"

How can I change the color of the counter on the button?

Adrian I need help changing the color of the digital counter on the button, is there any way? A website provides a set of free codes for react buttons, but they set the number counter color for the default button to be gray, I'm trying to make it stand out mor

How can I change the outline color of the button?

username How can I make the blue outline color #D5A021 instead of blue when the user clicks the button? I think it might be related tobtn-primary HTML <a class="btn btn-primary btn-xl js-scroll-trigger" href="#services">Find Out More <i class="fa fa-chevron-do

How can I change the color of the button text?

Brown I want to click a button and change its text color and message properties. I got the button to change its color, but I need to change one of the color of its text. private void TurnGreen(Button button) { ColorBlock colors = button.colors; colors.

How can I change the background color of the button?

Adam Shakhabov How to change the background color of the button when the button is pressed? @property (weak, nonatomic) IBOutlet UIButton *buttonDeleteOutlet; My button has no method: setBackgroundColor(UIColor *) forState: (UIControlState *) . Only setBackgr

How can I change the color of a button to a command?

Evan Monroe I want to change the color of a button in my javascript, but using forEach() or a loop makes the button listed in my javascript now blue. I don't want to use HTML because I'm trying to practice with events. I also want the color to turn black when

How can I change the color of the button text?

Brown I want to click a button and change its text color and message properties. I got the button to change its color, but I need to change one of the color of its text. private void TurnGreen(Button button) { ColorBlock colors = button.colors; colors.

How can I change the color of the button?

hahoanghai.ueh I am new to android programming. How can I change the color of the button? <Button android:id="@+id/btn" android:layout_width="55dp" android:layout_height="50dp" android:layout_gravity="center" android:text="Button Text"

How can I change the outline color of the button?

username How can I make the blue outline color #D5A021 instead of blue when the user clicks the button? I think it might be related tobtn-primary HTML <a class="btn btn-primary btn-xl js-scroll-trigger" href="#services">Find Out More <i class="fa fa-chevron-do

How can I change the color of the counter on the button?

Adrian I need help changing the color of the digital counter on the button, is there any way? A website provides a set of free codes for react buttons, but they set the number counter color for the default button to be gray, I'm trying to make it stand out mor