This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

button size and frame border

 
William Cowie
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a complete noob with java so bear with me, anyway I have created a simple calculator in the windows style(well that is the idea), I am trying to change the blank button in my code to the same size as the memory buttons down the left hand side but it just stretches. Also I am trying to create a small border round the number, operator and text panels any ideas how to sort these?

heres a pic: http://www.itshops.co.uk/calc.jpg

 
Campbell Ritchie
Sheriff
Posts: 48454
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Of course it stretches. Java Layout Managers are designed that when the size of the whole window changes, the individual components change too.

Go to Cay Horstmann's website, and find the GBC class, then use it to help with the GridBagLayout, which allows you to put an Inset around a button.

You can miss out the line about import java.lang.*; .
Also if you use J2SE 5.0 you can forget about pane and just add() all the components directly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic