Let’s say I would like to create a simple calculator. It consists of 3 fields. Text field to show result, field with checkboxes to select system and field with numbers.
What kind of component should I use for each element ?
How can I position elements in my window ?
How can I position elements inside component (ie checkboxes) ?
This is what I’m trying to achieve.
I would use
JTextFieldfor the number-windowJRadioButtonfor the radio buttons, andJButtonfor the buttons.The layout of the components should be deferred to a so called layout-manager. (Have a look at Using Layout Managers. In this case a
GridLayoutand/or aGridBagLayoutwould do fine.This code should get you started: