Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import javax.swing. * ; import java.awt.event. * ; import java.util. * ; public class Lab 1 extends JFrame implements ActionListener { static final long serialVersionUID
import javax.swing.;
import java.awt.event.;
import java.util.;
public class Lab extends JFrame implements ActionListener
static final long serialVersionUID L;
private JTextField assemblerInstruction;
private JTextField binaryInstruction;
private JTextField hexInstruction;
private JLabel errorLabel;
public Lab
setTitleM;
setBounds;
setDefaultCloseOperationJFrameEXITONCLOSE;
getContentPanesetLayoutnull;
assemblerInstruction new JTextField;
assemblerInstruction.setBounds;
getContentPaneaddassemblerInstruction;
assemblerInstruction.setColumns;
JLabel lblAssemblyLanguage new JLabelAssembly Language";
lblAssemblyLanguage.setBounds;
getContentPaneaddlblAssemblyLanguage;
binaryInstruction new JTextField;
binaryInstruction.setBounds;
getContentPaneaddbinaryInstruction;
binaryInstruction.setColumns;
hexInstruction new JTextField;
hexInstruction.setBounds;
getContentPaneaddhexInstruction;
hexInstruction.setColumns;
JLabel lblBinary new JLabelBinary Instruction";
lblBinary.setBounds;
getContentPaneaddlblBinary;
JLabel lblHexEquivalent new JLabelHex Instruction";
lblHexEquivalent.setBounds;
getContentPaneaddlblHexEquivalent;
errorLabel new JLabel;
errorLabel.setBounds;
getContentPaneadderrorLabel;
JButton btnEncode new JButtonEncode;
btnEncode.setBounds;
getContentPaneaddbtnEncode;
btnEncode.addActionListenerthis;
JButton btnDecode new JButtonDecode Binary";
btnDecode.setBounds;
getContentPaneaddbtnDecode;
btnDecode.addActionListenerthis;
JButton btnDecodeHex new JButtonDecode Hex";
btnDecodeHex.setBounds;
getContentPaneaddbtnDecodeHex;
btnDecodeHex.addActionListenerthis;
public void actionPerformedActionEvent evt
errorLabel.setText;
if evtgetActionCommandequalsEncode
encode;
else if evtgetActionCommandequalsDecode Binary"
decodeBin;
else if evtgetActionCommandequalsDecode Hex"
decodeHex;
public static void mainString args
Lab window new Lab;
window.setVisibletrue;
String shortToHexshort x
String ans;
for int i; i; i
int hex x & ;
char hexChar ABCDEF".charAthex;
ans hexChar ans;
x shortx ;
return ans;
String shortToBinaryshort x
String ans;
forint i; i; i
ans x & ans;
x shortx ;
return ans;
DO NOT CHANGE ANYTHING ABOVE THIS POINT
I need help with creating the encode, decodeBin, and decodeHex
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started