MacKey
MacKey

Reputation: 45

I can not change the title of Jbutton

I can change the location of a JButton, but I can not change the title. Is it possible that the java file is corrupted? How come I can't change the title while changing the location? I use Eclipse...

The first code The frame with JButton The Changed code The frame with JButton

Upvotes: 0

Views: 110

Answers (1)

McPringle
McPringle

Reputation: 2129

The width of the button is too short to display the title (15 pixels). As a fallback, the is shown.

In addition, I highly recommend not to use the setBounds method directly. Take a look at a Java Swing tutorial on Youtube, Vimeo, Udemy, or as a book. You will learn how to create a user interface with layout managers. You won't have these kinds of problems then.

You might want to consider learning JavaFX instead because Swing is end of life.

Upvotes: 1

Related Questions