• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to remove spaces between buttons(making a calculator)

 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am a beginner in Java . currently i m trying to make a calculator. So far i have made the GUI of the calculator but the problem is that i am unable to remove horizontal spaces between the rows of buttons. i want my calculator to look like the one we get with our windows operating system. There, the buttons are packed . can anyone help me out in removing those spaces. My code so far is as follows:



saima.
 
Brian Cole
Author
Ranch Hand
Posts: 908
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saima kanwal wrote:i have made the GUI of the calculator but the problem is that i am unable to remove horizontal spaces between the rows of buttons.


A calculator is the prototypical example for using GridLayout. You may want to use that instead of FlowLayout.
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sure you don't write code that is left aligned, so don't expect us to read it that way. The "Preview" button is there for a reason.

Edit your posting and post properly formatted code.
 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Brian. I will now try with GridLayout.
As for my left aligned code , let me clarify that to you: since i m a beginner,and since I have started studying Java all by myself just by browsing material and through books , and it's only a month that i have started studying Java, I am not practiced in writing the correct way you are referring.(I am still using notepad for writing my code and using command line for compilation.) i will now download some Integrated Development Environment so that my code is not left aligned or try to make it that way myself. Anyways , thanks for your suggestions.
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still using notepad for writing my code and using command line for compilation.) i will now download some Integrated Development Environment


Me too, I use a simple text based editor and a command line for compiling this does not prevent you for using standard intendation of your code.

How hard is it to type spaces or add a tab character at the beginning of a line?

Properly formatted code will make it much easier to read and understand your code, thus prevent silly errors like mismatched brackets and so on.
 
santhosh varala kumar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:
I am still using notepad for writing my code and using command line for compilation.) i will now download some Integrated Development Environment


Me too, I use a simple text based editor and a command line for compiling this does not prevent you for using standard intendation of your code.

How hard is it to type spaces or add a tab character at the beginning of a line?

Properly formatted code will make it much easier to read and understand your code, thus prevent silly errors like mismatched brackets and so on.


Best thing you write the codeby using IDE
such IDE can be
1. Net beans
2. Eclipse
which will do format for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic