• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing GUI wierdness

 
vaibhav mishra
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mineButton[i][j] = new JButton();
mineButton[i][j].setMargin(new java.awt.Insets(0,0,0,0));//<---add this line
 
vaibhav mishra
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it would be better if you noted on your cross-posts at other sites that you
now have a solution
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got it
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic