0

How to implement Windows calculator with JPanel in Java?

I want to implement windows 7 calculator in java, I am newbie in implement GUI in java, please tell me how can I implement calculator GUI with JPanel in Java.

enter image description here

I think first use BorderLayout() to frame, and add textfield to north then put label in center and in South using jpanel with girdLayout(4*1) , really I completely confused

Would appreciate any help:

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Yuseferi
  • 7,931
  • 11
  • 67
  • 103

1 Answers1

1

I see a main JPanel and 6 subordinate JPanels.

The first subordinate JPanel is the display. It would have a FlowLayout with one JLabel for the number display.

The next JPanel is the binary number display. It would have a GridLayout with 32 JLabel fields.

The next 2 JPanels hold the JRadioButton groups. They would have a FlowLayout, and the radio buttons would be in ButtonGroups.

The next JPanel consists of the first 3 columns of buttons. It would have a GridLayout with 18 JButtons.

The final subordinate JPanel consists of the last 5 columns of buttons. It would have a GridBagLayout, because of the zero and equals buttons.

The main JPanel would have a GridBagLayout.

Put this GUI together, by hand (no GUI builder) one JPanel at a time. I would have a separate class for each subordinate JPanel, and another class for the main JPanel. Seven classes just for the JPanels.

Gilbert Le Blanc
  • 50,182
  • 6
  • 67
  • 111
  • can you explain "Put this GUI together, by hand (no GUI builder) one JPanel at a time. I would have a separate class for each subordinate JPanel, and another class for the main JPanel. Seven classes just for the JPanels." more, tnx – Yuseferi Jun 29 '13 at 06:16
  • @zhilevan: Construct the display panel. See that it works. Construct the number keys panel. See that it works. Rinse and repeat for the remaining 4 subordinate panels. When the subordinate panels are completed, then try to put the entire calculator together. Each subordinate panel should be in its own Java class. Each subordinate panel should have a GUI model class that contains the data for the subordinate panel. – Gilbert Le Blanc Jun 29 '13 at 12:13