• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unable to remove spaces between buttons(making a calculator)

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic