Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Critique my beginner basic GUI calculation program and need some clarifications

 
John Laker
Greenhorn
Posts: 22
  • 0
  • 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.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic