001package jmri.jmrix.ieee802154.swing.packetgen;
002
003import jmri.jmrix.ieee802154.IEEE802154Message;
004import jmri.jmrix.ieee802154.IEEE802154TrafficController;
005
006/**
007 * Frame for user input of XpressNet messages
008 *
009 * @author Bob Jacobsen Copyright (C) 2001,2002
010 */
011public class PacketGenFrame extends jmri.jmrix.swing.AbstractPacketGenFrame {
012
013    /**
014     * {@inheritDoc}
015     */
016    @Override
017    public void initComponents() {
018        super.initComponents();
019
020        // all we need to do is set the title 
021        Bundle.getMessage("jmri.jmrix.ieee802154.swing.packetgen.PacketGenAction");
022
023        // pack to cause display
024        pack();
025    }
026
027    /**
028     * {@inheritDoc}
029     */
030    @Override
031    public void sendButtonActionPerformed(java.awt.event.ActionEvent e) {
032        tc.sendIEEE802154Message(createPacket(packetTextField.getSelectedItem().toString()), null);
033    }
034
035    IEEE802154Message createPacket(String s) {
036        if (s.equals("")) {
037            return null; // message cannot be empty
038        }
039        IEEE802154Message m = new IEEE802154Message(s, s.length());
040        return m;
041    }
042
043    // connect to the TrafficController
044    public void connect(IEEE802154TrafficController t) {
045        tc = t;
046    }
047
048    // private data
049    private IEEE802154TrafficController tc = null;
050}