Question: I am programming a calculator in JAVA using GUI. I have my calculator layout but i want to add radio buttons which will allow the
I am programming a calculator in JAVA using GUI. I have my calculator layout but i want to add radio buttons which will allow the user to have the decimal numbers converted to hex, octa, dec, and binary. like the one below
this is what i have.
mainly what i have is teh buttons only but the functions i can work with
so how can i add the radio buttons to my calculator?
here is code for my calculator:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class CalculatorBuild extends JFrame implements ActionListener
{
public CalculatorBuild(){
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("GridLayout Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new GridLayout(6, 4));
frame.add(new JButton("A"));
frame.add(new JButton(""));
frame.add(new JButton(""));
frame.add(new JButton(""));
frame.add(new JButton(""));
frame.add(new JButton("B"));
frame.add(new JButton("
frame.add(new JButton("CE"));
frame.add(new JButton("c"));
frame.add(new JButton("%"));
frame.add(new JButton("C"));
frame.add(new JButton("7"));
frame.add(new JButton("8"));
frame.add(new JButton("9"));
frame.add(new JButton("+"));
frame.add(new JButton("D"));
frame.add(new JButton("4"));
frame.add(new JButton("5"));
frame.add(new JButton("6"));
frame.add(new JButton("-"));
frame.add(new JButton("E"));
frame.add(new JButton("1"));
frame.add(new JButton("2"));
frame.add(new JButton("3"));
frame.add(new JButton("*"));
frame.add(new JButton("F"));
frame.add(new JButton("."));
frame.add(new JButton("0"));
frame.add(new JButton("+/-"));
frame.add(new JButton("="));
frame.pack();
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
}
}
Calculator View Edit Help 63 0000 0000 0000 0000 0000 0000 0000 e000 31 47 32 15 Quot Mod A Hex O Dec Oct Bin D 456 1/2x Qword Dword Word Byte 0 0 2 0 0 0 ABCDEF
Step by Step Solution
There are 3 Steps involved in it
To add radio buttons for conversion options Hex Dec Oct Bin to your calculator follow these steps Step 1 Import Required Classes Ensure you have the n... View full answer
Get step-by-step solutions from verified subject matter experts
