Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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
Pie
Posts: 49771
69
  • 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