001package apps.jmrit.log;
002
003import java.awt.FlowLayout;
004
005import javax.swing.*;
006
007import org.slf4j.Logger;
008import org.slf4j.LoggerFactory;
009
010/**
011 * User interface for adding an item to the log file.
012 *
013 * @author Bob Jacobsen Copyright (C) 2007
014 */
015public class LogPanel extends JPanel {
016
017    // member declarations
018    JLabel label = new JLabel(Bundle.getMessage("LogMessageLabel"));
019    JButton sendButton = new JButton(Bundle.getMessage("ButtonAddText"));
020    JTextField textField = new JTextField(40);
021
022    public LogPanel() {
023        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
024
025        JPanel p1 = new JPanel();
026        p1.setLayout(new FlowLayout());
027        p1.add(label);
028        p1.add(textField);
029        add(p1);
030        add(sendButton);
031
032        sendButton.setToolTipText(Bundle.getMessage("LogSendToolTip"));
033        sendButton.addActionListener(this::sendTextToLog );
034    }
035
036    @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( value="SLF4J_FORMAT_SHOULD_BE_CONST",
037        justification="Error String always needs to be evaluated unchanged.")
038    private void sendTextToLog(java.awt.event.ActionEvent e){
039        log.error(textField.getText());
040    }
041
042    private final static Logger log = LoggerFactory.getLogger(LogPanel.class);
043
044}