Dear Readers, I have been trying to make the label of JButton to be displayed. But all that shows up is "...". This is because the display area of JButton is small. So I tried reducing the Font size of JButton to a minimum. What happens is that the size of "..." gets reduced!!! Text is still not displayed! And its not a long string, its just a single number.
Post a minimal example program demonstrating your problem.
Don't explciitly set the preferred size of a button. Are you pack()ing your JFrame? Then components should be receiving adequate dimensions unless a layout manager is dropping the ball.
There is no emoticon for what I am feeling!
Shyam Prasad Murarka
Joined: May 02, 2005
Dear Readers, Whatever code was relevant to the problem I have posted it. The rest of the code is many lines long. What I am trying is to make a minesweeper game. I have finsihed making it. And its working. But I have to improve the GUI. For that I need to maintain the height and width of each box. Is there any other way other than using setPreferrdSize()??
Dear Readers, Michael, thanks for your sample. It made me realize something. Your code worked perfectly. But I wanted the button size to be (15,15) so I changed it. But the double digits number did not show up this time. Then I commented the line that sets the Margin. This time the single digits also did not show up!! So i put back the setMargin() line and the single digits showed up. That's what I wanted. Because in Minesweeper the numbers will never be more than 8. So its working, BUT I still don't understand why its working??
What I estimated is that maybe JButton by default sets a margin greater than 0 resultantly eating away the precious display area!! And by setting it to 0 in the above code, the text gets more space to display iself. So atleast the single digits are being displayed.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com