• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Critique my beginner basic GUI calculation program and need some clarifications

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is a GUI that I wrote for learning more about how to use GUI's in Java.

What you can help me with is the layout of components. I wanted to have the layout of components something like this



Right now it is setup with flowlayout to be in one row. Can someone let me know the code to set it up the way I want.

Also I don't know why I'm using this in the main method


The teacher used that in one of the examples, so I'm using it. But I don't know why.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. http://download.oracle.com/javase/tutorial/uiswing/layout/index.html
2. http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html

Ask if anything there still isn't clear.
 
John Laker
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Darryl Burke wrote:1. http://download.oracle.com/javase/tutorial/uiswing/layout/index.html
2. http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html

Ask if anything there still isn't clear.



I read it, but not sure which one fits what i want to do.

Also I have this code



but the GUI doesn't have these dimensions
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can nest layouts.
Panel1 has the result , centered
Panel2 has num1, num2 centered
Panel3 has +,-,/,* centered
DaddyPanel has panel1,panel2 and panel3 aligned vertically
DaddyPanel is added to the content pane.

You need to choose an appropriate layout (there are others besides the FlowLayout you have been using) The link Darryl provided, will help you find out these layouts.
 
Always look on the bright side of life. At least this ad is really tiny:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic