All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codemagi.burp.ui.MessagePanel Maven / Gradle / Ivy

Go to download

The Burp Suite Utils project provides developers with APIs for building Burp Suite Extensions.

The newest version!
package com.codemagi.burp.ui;

import java.util.Timer;
import java.util.TimerTask;

/**
 *
 * @author adetlefsen
 */
public class MessagePanel extends javax.swing.JPanel {

    private int clearDelay = 1000;

    /**
     * Creates new form MessagePanel
     */
    public MessagePanel() {
        initComponents();
    }

    /**
     * Creates new form MessagePanel
     *
     * @param clearDelay The delay (in milliseconds) before the message is
     * cleared.
     */
    public MessagePanel(int clearDelay) {
        this.clearDelay = clearDelay;
        initComponents();
    }

    /**
     * Sets the clear delay: The amount of time (in milliseconds) before
     * messages posted to the panel will be automatically cleared.
     *
     * @param newValue number of milliseconds for the message to persist
     */
    public void setClearDelay(int newValue) {
        clearDelay = newValue;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // //GEN-BEGIN:initComponents
    private void initComponents() {

        statusMessage = new javax.swing.JLabel();

        statusMessage.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        statusMessage.setAutoscrolls(true);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// //GEN-END:initComponents

    public void setStatusMessage(String message) {
        statusMessage.setText("" + message + "");

        //hide the message after a delay
        Timer timer = new Timer();
        timer.schedule(new CloseDialogTask(), clearDelay);
    }

    class CloseDialogTask extends TimerTask {

        @Override
        public void run() {
            statusMessage.setText("");
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel statusMessage;
    // End of variables declaration//GEN-END:variables
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy