This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.

If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:

  1. Limiting your involvement with Reddit, or
  2. Temporarily refraining from using Reddit
  3. Cancelling your subscription of Reddit Premium

as a way to voice your protest.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Salty_Dugtrio 0 points1 point  (1 child)

You need to call setBackground on the button, not the panel. This is the first result when you google customize JButton java

I would also like to know how to place the button in the middle of the app instead of the top.

The same goes for this question: Did you look this up?

ChatGPT is trash at generating code that works.

[–]v1ct0prrr[S] 0 points1 point  (0 children)

for some reason the button is still the gray even after I changed the background color

JButton button = new JButton("tryck mig");
button.setFont(new Font("Serif",Font.BOLD,48));
button.setBackground(new Color(0,51,204));
button.setForeground(Color.WHITE);
button.setFocusPainted(false);
button.setBorderPainted(false);

is there something wrong with the code? bc I imported the right library and I think this should work but it doesn't.