wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes unable to remove spaces between buttons(making a calculator) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "unable to remove spaces between buttons(making a calculator) " Watch "unable to remove spaces between buttons(making a calculator) " New topic
Author

unable to remove spaces between buttons(making a calculator)

saima kanwal
Ranch Hand

Joined: Oct 05, 2009
Posts: 148
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.


SCJP 6.0 (86%) SCWCD 5 (94%)
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
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.


bitguru blog
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
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

Joined: Oct 05, 2009
Posts: 148
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

Joined: Jun 13, 2009
Posts: 2152
    
    7
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

Joined: Nov 05, 2009
Posts: 25
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.
 
Consider Paul's rocket mass heater.
 
subject: unable to remove spaces between buttons(making a calculator)
 
Similar Threads
Very Very New
change font in JPanel
an array of buttons in an applet ?
Textfield Problem
Layout problems!!