GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Swing GUI wierdness Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing GUI wierdness" Watch "Swing GUI wierdness" New topic
Author

Swing GUI wierdness

vaibhav mishra
Ranch Hand

Joined: Jun 18, 2008
Posts: 168
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


SCJP
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
mineButton[i][j] = new JButton();
mineButton[i][j].setMargin(new java.awt.Insets(0,0,0,0));//<---add this line
vaibhav mishra
Ranch Hand

Joined: Jun 18, 2008
Posts: 168
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
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
it would be better if you noted on your cross-posts at other sites that you
now have a solution
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> 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
vaibhav mishra
Ranch Hand

Joined: Jun 18, 2008
Posts: 168
got it
Thanks
 
jQuery in Action, 2nd edition
 
subject: Swing GUI wierdness