my.jabbr.app.ftpclient.ui.install.ProductLicenseInstallationPanel.java Source code

Java tutorial

Introduction

Here is the source code for my.jabbr.app.ftpclient.ui.install.ProductLicenseInstallationPanel.java

Source

package my.jabbr.app.ftpclient.ui.install;

import java.awt.BorderLayout;
import java.io.File;
import java.io.IOException;
import java.io.ObjectOutputStream;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import my.jabbr.app.ftpclient.controller.ConfigManager;
import my.jabbr.app.ftpclient.ui.accessories.UIAccessories;

import org.apache.commons.io.FileUtils;

@SuppressWarnings("serial")
public class ProductLicenseInstallationPanel extends AbstractInstallationPanel {

    private JTextArea licenseText;

    public ProductLicenseInstallationPanel() {
        initComponents();
    }

    private void initComponents() {
        try {
            String licenseStr = FileUtils.readFileToString(new File(ConfigManager.GPL_LICENSE_FILE));
            licenseText = new JTextArea(licenseStr);
            licenseText.setColumns(20);
            licenseText.setRows(15);
            licenseText.setBorder(BorderFactory.createLineBorder(UIAccessories.BORDER_GRAY));
            licenseText.setBackground(UIAccessories.WHITE);
            licenseText.setEditable(false);

            JScrollPane scrollPane = new JScrollPane(licenseText);
            scrollPane.setBorder(null);
            scrollPane.setOpaque(false);
            scrollPane.getViewport().setOpaque(false);
            scrollPane.getViewport().setBorder(null);
            scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

            setLayout(new BorderLayout(20, 20));
            add(createTransparentFillerPanel(), BorderLayout.NORTH);
            add(scrollPane, BorderLayout.CENTER);
        } catch (IOException e) {
            e.printStackTrace();
        }

        this.setOpaque(false);
    }

    private void writeObject(ObjectOutputStream oos) throws IOException {
        throw new IOException("Class Not Serializable");
    }

    private JPanel createTransparentFillerPanel() {
        JPanel panel = new JPanel();
        panel.setSize(645, 50);
        panel.setOpaque(false);
        panel.setBorder(null);
        return panel;
    }
}