Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package views.Demonstration;
- import java.awt.GridLayout;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.BorderFactory;
- import javax.swing.ButtonGroup;
- import javax.swing.JPanel;
- import javax.swing.JRadioButton;
- import models.errorcodes.ErrorCodeType;
- public class ErrorCodeOptionPane extends JPanel {
- /**
- *
- */
- private static final long serialVersionUID = -8228335037257203656L;
- private final MainPanel mainPanel;
- private final ButtonListener listener;
- private JRadioButton ParityBit = new JRadioButton("Bit Paridade", true);
- private JRadioButton CRC_4_ITU = new JRadioButton("CRC_4_ITU");
- private JRadioButton CRC_8_ITU = new JRadioButton("CRC_8_ITU");
- private JRadioButton HAMMING = new JRadioButton("Hamming (11,15)");
- private ButtonGroup buttonGroup = new ButtonGroup();
- public ErrorCodeOptionPane(final MainPanel mainPanel) {
- this.mainPanel = mainPanel;
- setLayout(new GridLayout(0,4));
- listener = new ButtonListener();
- mainPanel.setDemonstrationPane(ErrorCodeType.PARITY_BIT, 0);
- setBorder(BorderFactory.createTitledBorder("Método de detecção/correcção"));
- addButton(ParityBit);
- addButton(CRC_4_ITU);
- addButton(CRC_8_ITU);
- addButton(HAMMING);
- }
- private void addButton(JRadioButton button ) {
- buttonGroup.add(button);
- add(button);
- button.addActionListener(listener);
- }
- private class ButtonListener implements ActionListener{
- @Override
- public void actionPerformed(ActionEvent e) {
- if(e.getSource().equals(ParityBit)){
- mainPanel.setDemonstrationPane(ErrorCodeType.PARITY_BIT, 0);
- }else if(e.getSource().equals(CRC_4_ITU)){
- mainPanel.setDemonstrationPane(ErrorCodeType.CRC, 1);
- }else if(e.getSource().equals(CRC_8_ITU)){
- mainPanel.setDemonstrationPane(ErrorCodeType.CRC, 2);
- }else if(e.getSource().equals(HAMMING)){
- mainPanel.setDemonstrationPane(ErrorCodeType.HAMMING, 2);
- }
- mainPanel.update();
- }
- }
- }
Add Comment
Please, Sign In to add comment