Forums Register Login

Swing GUI wierdness

+Pie Number of slices to send: Send
I have the following swing code


I ran this with default row value of 16 and column value of 30
you can use whatever value you like for other variables
this produces a GUI window with lots of button and I want to change buttons value to whatever is in cellvalues array
but all I get is 3 dots


can you solve the problem

other helping classes are

Calculation.java
+Pie Number of slices to send: Send
mineButton[i][j] = new JButton();
mineButton[i][j].setMargin(new java.awt.Insets(0,0,0,0));//<---add this line
+Pie Number of slices to send: Send
Thank you very much for your immediate reply

that did solve the problem
can you explain what I did wrong and what this line did
it would be of great help

Thanks again
+Pie Number of slices to send: Send
it would be better if you noted on your cross-posts at other sites that you
now have a solution
+Pie Number of slices to send: Send
> can you explain what I did wrong and what this line did

you didn't actually do anything wrong, it's just how java handles text
when there's insufficient space i.e. button is smaller that its preferredSize.
e.g. if you had a JLabel with "Happy Birthday vaibhav mishra",
and you sized the label to be not too wide, the text might show as Happy Birthd...

with JButtons, sometimes removing the margin works, sometimes reducing the
font size also works, and other times you need to do both - bottom line is it
depends on how small your buttons are
+Pie Number of slices to send: Send
got it
Thanks
The fastest and most reliable components of any system are those that are not there. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1487 times.
Similar Threads
June Newsletter Puzzle
default JFileChooser to details view Mode
Newsletter Inverse
implementing objects in a private class to an array constructor...
slow in TableCellRenderer
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:32:15.