Hey, I am creating a calculator program, with some small buttons, I want one of the buttons to have "Ans" on them, but whenever I make the JButton smaller then 50, 50, it will show three dots. "...", how can I remove these dots and show the normal text given?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You could change the size of the font on the button. See these links:
Setting font size
Increasing font size (Can be easily changed to decrease font size)
Use
setMargin(Insets m)
to adjust the space between the JButton border and the label. The default is(2, 14, 2, 14)
. To maximize the space available for the label (and to remove the dots completely) you can use something likeThis code attempts to explain why layouts and preferred sizes are so important. The important part lies in the input/output.
TestGuiSize.java
Input/output
Run-time parameters are just the tip of the iceberg of the differences between runs that might sink an application's GUI code. Layouts are designed to handle such differences.
Don't set the preferred size of the button. Use the preferred size of the button and let the layout manager layout the components. The preferred size ensures all the text will be displayed properly on different Look and Feels.
Probably this because margin of your button is too big.
Try this:
You can also turn off border: