001package jmri.jmrix.roco.z21.swing.packetgen;
002
003import jmri.jmrix.roco.z21.Z21Message;
004import jmri.jmrix.roco.z21.Z21TrafficController;
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        setTitle(Bundle.getMessage("SendZ21MessageTitle"));
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.sendz21Message(createPacket(packetTextField.getSelectedItem().toString()), null);
033    }
034
035    Z21Message createPacket(String s) {
036        if (s.equals("")) {
037            return null; // message cannot be empty
038        }
039        return new Z21Message(s);
040    }
041
042    // connect to the TrafficController
043    public void connect(Z21TrafficController t) {
044        tc = t;
045    }
046
047    // private data
048    private Z21TrafficController tc = null;
049}