Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
