Example usage for javax.swing BorderFactory createLineBorder

List of usage examples for javax.swing BorderFactory createLineBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createLineBorder.

Prototype

public static Border createLineBorder(Color color, int thickness) 

Source Link

Document

Creates a line border with the specified color and width.

Usage

From source file:com.fratello.longevity.smooth.AppGUI.java

private void initialize() {
    LabelMaxSize = 0;/*from   ww  w . ja  v  a 2s .  c  o m*/

    ActiveGUI = true;
    GUI_Start = false;
    GUI_Pause = true;
    GUI_Stop = false;
    ran_at_least_once = false;

    execute();

    initializeFields();

    frmFileSystemSearch = new JFrame();
    frmFileSystemSearch.setTitle("Smooth Longevity Fratello");
    frmFileSystemSearch.setBounds(100, 100, 450, 300);
    frmFileSystemSearch.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmFileSystemSearch.setResizable(false);

    UIManager.put("PopupMenu.border", BorderFactory.createLineBorder(Color.black, 1));

    JMenuBar menuBar = new JMenuBar();
    frmFileSystemSearch.setJMenuBar(menuBar);

    JMenu mnNewMenu = new JMenu("File");
    menuBar.add(mnNewMenu);

    JMenuItem mntmFirst = new JMenuItem("Open Directory");
    mntmFirst.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openFileChooserDir(mntmFirst);
        }
    });
    mnNewMenu.add(mntmFirst);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            frmFileSystemSearch.dispose();
        }
    });
    mnNewMenu.add(mntmExit);

    JMenu mnHelp = new JMenu("Help");
    menuBar.add(mnHelp);

    JMenuItem mntmAbout = new JMenuItem("About");
    mnHelp.add(mntmAbout);

    JMenuItem mntmTutorials = new JMenuItem("Tutorials");
    mnHelp.add(mntmTutorials);

    JMenuItem mntmCheckForUpdates = new JMenuItem("Check for Updates");
    mnHelp.add(mntmCheckForUpdates);

    String ppallink = "https://www.paypal.com/cgi-bin/webscr" + "?cmd=" + "_donations" + "&business="
            + "8YUJNSN6KFV54" + "&lc=" + "US" + "&item_name="
            + "Personal%20funds%20for%20programming%20at%20university" + "&currency_code=" + "USD" + "&bn="
            + "PP%2dDonationsBF" + "%3abtn_donateCC_LG%2egif%3aNonHosted";

    JButton btnDonate = new JButton("Donate");
    btnDonate.setToolTipText("<html>Open default Internet browser <br>(Chrome, FireFox, etc.)</html>");
    btnDonate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    btnDonate.setBounds(159, 176, 90, 25);
    menuBar.add(btnDonate);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    frmFileSystemSearch.getContentPane().add(tabbedPane, BorderLayout.CENTER);

    // ---------------------------- JPanels ------------------------------
    JPanel panel = new JPanel();
    tabbedPane.addTab("Start Directory", null, panel, null);

    JPanel panel_1 = new JPanel();
    tabbedPane.addTab("Search Setup", null, panel_1, null);
    panel_1.setLayout(null);

    JPanel panel_2 = new JPanel();
    tabbedPane.addTab("Run Program", null, panel_2, null);
    panel_2.setLayout(null);

    JPanel panel_3 = new JPanel();
    tabbedPane.addTab("Information", null, panel_3, null);
    panel_3.setBounds(10, 11, 409, 154);
    GridBagLayout gbl_panel_3 = new GridBagLayout();
    gbl_panel_3.columnWidths = new int[] { 0, 0, 0 };
    gbl_panel_3.rowHeights = new int[] { 0, 0, 0 };
    gbl_panel_3.columnWeights = new double[] { 1.0, 1.0, 1.0 };
    gbl_panel_3.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    panel_3.setLayout(gbl_panel_3);

    // ------------- Dynamic Update - Swingworker Components -------------
    SentinelProgressBar = new JProgressBar();
    SentinelProgressBar.setMaximumSize(new Dimension(146, 14));
    SentinelProgressBar.setMaximum(1000);
    SentinelProgressBar.setBounds(74, 187, 146, 14);
    panel_2.add(SentinelProgressBar);

    SentinelProgressLabel = new JLabel();
    SentinelProgressLabel.setToolTipText("Time needed to finish the program in progress");
    SentinelProgressLabel.setBounds(333, 181, 86, 20);
    panel_2.add(SentinelProgressLabel);

    // -------------------------------------------------------------------
    // ------------------------ JPanel Components ------------------------
    JLabel lblCurrentDirectory = new JLabel("Current Directory");
    panel.add(lblCurrentDirectory);

    userSelectedDirectories = new JTextField();
    panel.add(userSelectedDirectories);
    userSelectedDirectories.setColumns(35);

    JButton btnBrowse = new JButton("Browse");
    btnBrowse.setToolTipText("Locate directory in system");
    btnBrowse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openFileChooserDir(btnBrowse);
        }
    });
    panel.add(btnBrowse);

    JButton btnClear = new JButton("Clear");
    btnClear.setToolTipText("Deletes the current directory shown");
    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            userSelectedDirectories.setText("");
            clearSourceDirectory();
        }
    });
    panel.add(btnClear);

    // -------------------------------------------------------------------
    // ----------------------- JPanel_1 Components -----------------------

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Extension :: [Check Box]
    chckbxExt = new JCheckBox("Extension");
    chckbxExt.setToolTipText("Check to ignore file extensions");
    chckbxExt.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Ext", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Ext", false);
        }
    });
    chckbxExt.setBounds(8, 15, 97, 23);
    panel_1.add(chckbxExt);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Hash :: [Check Box]
    chckbxHash = new JCheckBox("Hash");
    chckbxHash.setToolTipText("Check to compare by hashing files (FAST)");
    chckbxHash.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Hash", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Hash", false);
        }
    });
    chckbxHash.setBounds(8, 45, 97, 23);
    panel_1.add(chckbxHash);

    // Hash :: [Combo Box]
    comboBoxHash = new JComboBox<String>();
    comboBoxHash.setToolTipText(
            "<html>Hash algorithm to use in file hashing <br>(note - SHA-512 may not be <br>supported by your computer)</html>");
    comboBoxHash.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String UIselect = (String) cb.getSelectedItem();
            cf.setHashString(UIselect);
        }
    });
    comboBoxHash
            .setModel(new DefaultComboBoxModel<String>(new String[] { "MD5", "SHA-1", "SHA-256", "SHA-512" }));
    comboBoxHash.setBounds(150, 44, 75, 25);
    panel_1.add(comboBoxHash);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Name :: [Check Box]
    chckbxName = new JCheckBox("Name");
    chckbxName.setToolTipText("Name tool-tip goes here");
    chckbxName.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Name", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Name", false);
        }
    });
    chckbxName.setBounds(8, 75, 97, 23);
    panel_1.add(chckbxName);

    // Name :: [Text Field]
    namePercentMatchTextField = new JFormattedTextField(new Double(0.0d));
    namePercentMatchTextField.setFormatterFactory(new DoubleDocListener(namePercentMatchTextField));
    namePercentMatchTextField.getDocument()
            .addDocumentListener(new DoubleDocListener(namePercentMatchTextField));
    namePercentMatchTextField.setToolTipText("Match file names by percentage [00.00-100.00]");
    namePercentMatchTextField.setBounds(150, 74, 110, 25);
    panel_1.add(namePercentMatchTextField);
    namePercentMatchTextField.setColumns(10);

    // Name :: [Combo Box]
    comboBoxNames = new JComboBox<String>();
    comboBoxNames.setToolTipText("Algorithm to compare names");
    comboBoxNames.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String UIselect = (String) cb.getSelectedItem();
            cf.setMatchingAlgorithm(UIselect);
        }
    });
    comboBoxNames.setModel(new DefaultComboBoxModel<String>(new String[] { "Bitap", "Cosine",
            "DamerauLevenshtein", "DynamicTimeWarpingStandard1", "DynamicTimeWarpingStandard2", "Hamming",
            "Hirschberg", "JaccardIndex", "JaroWinkler", "Levenshtein", "NeedlemanWunsch", "SmithWaterman",
            "SorensenSimilarityIndex", "WagnerFischer" }));
    comboBoxNames.setBounds(265, 74, 150, 25);
    panel_1.add(comboBoxNames);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Size :: [Check Box]
    chckbxSize = new JCheckBox("Size");
    chckbxSize.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Size", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Size", false);
        }
    });
    chckbxSize.setBounds(8, 105, 97, 23);
    panel_1.add(chckbxSize);

    // Size :: [Text Field]
    sizePercentMatchTextField = new JFormattedTextField(new Double(0.0d));
    sizePercentMatchTextField.setFormatterFactory(new DoubleDocListener(sizePercentMatchTextField));
    sizePercentMatchTextField.getDocument()
            .addDocumentListener(new DoubleDocListener(sizePercentMatchTextField));
    sizePercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]");
    sizePercentMatchTextField.setBounds(150, 104, 110, 25);
    panel_1.add(sizePercentMatchTextField);
    sizePercentMatchTextField.setColumns(10);

    // Size :: [Combo Box]
    comboBoxSize = new JComboBox<String>();
    comboBoxSize.setToolTipText("Specify byte grouping");
    comboBoxSize.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String UIselect = (String) cb.getSelectedItem();
            cf.setMetricSize(UIselect);
        }
    });
    comboBoxSize.setModel(
            new DefaultComboBoxModel<String>(new String[] { "BYTE", "KILOBYTE", "MEGABYTE", "GIGABYTE" }));
    comboBoxSize.setBounds(265, 104, 150, 25);
    panel_1.add(comboBoxSize);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Thorough :: [Check Box]
    chckbxThorough = new JCheckBox("Thorough");
    chckbxThorough.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Thorough", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Thorough", false);
        }
    });
    chckbxThorough.setToolTipText("Check byte by byte");
    chckbxThorough.setBounds(8, 135, 97, 23);
    panel_1.add(chckbxThorough);

    // Thorough :: [Text Field]
    thoroughPercentMatchTextField = new JFormattedTextField(new Double(0.0d));
    thoroughPercentMatchTextField.setFormatterFactory(new DoubleDocListener(thoroughPercentMatchTextField));
    thoroughPercentMatchTextField.getDocument()
            .addDocumentListener(new DoubleDocListener(thoroughPercentMatchTextField));
    thoroughPercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]");
    thoroughPercentMatchTextField.setBounds(150, 134, 110, 25);
    panel_1.add(thoroughPercentMatchTextField);
    thoroughPercentMatchTextField.setColumns(10);

    // Thorough :: [Check Box]
    chckbxExitFast = new JCheckBox("Exit Fast");
    chckbxExitFast.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setThoroughExitFirstByteMisMatch(true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setThoroughExitFirstByteMisMatch(false);
        }
    });
    chckbxExitFast.setToolTipText("<html>When the first byte comparison <br>is a mis-match then stop</html>");
    chckbxExitFast.setBounds(265, 138, 105, 16);
    panel_1.add(chckbxExitFast);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    JButton btnSaveSearchSettings = new JButton("Save Search Settings");
    btnSaveSearchSettings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            pollSearchSettings();
            cf.saveObject();
            // System.out.println(cf.toString()); // debug
        }
    });
    btnSaveSearchSettings.setBounds(292, 181, 140, 25);
    panel_1.add(btnSaveSearchSettings);

    JButton btnLoadSettings = new JButton("Load Settings");
    btnLoadSettings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (!cf.loadObject())
                cf.setDefaultSettings();
            cacheUpdateGUISettings();
        }
    });
    btnLoadSettings.setBounds(148, 181, 140, 25);
    panel_1.add(btnLoadSettings);

    JButton btnDefaultSettings = new JButton("Use Default Settings");
    btnDefaultSettings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            cf.setDefaultSettings();
            cacheUpdateGUISettings();
        }
    });
    btnDefaultSettings.setBounds(4, 181, 140, 25);
    panel_1.add(btnDefaultSettings);

    // -------------------------------------------------------------------
    // ----------------------- JPanel_2 Components -----------------------
    JLabel labelStatus = new JLabel("Progress");
    labelStatus.setBounds(10, 187, 54, 14);
    panel_2.add(labelStatus);

    JButton btnStart = new JButton("Start");
    btnStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pollSearchSettings();
            if (!ran_at_least_once)
                ran_at_least_once = true;
            else {
                SentinelProgressBar.setValue(0);
                SentinelProgressLabel.setText("Waiting...");
            }
            try {
                if (multiSelection == null) {
                    JOptionPane.showMessageDialog(btnStart, "Please enter at least one directory.",
                            "Press OK to continue", JOptionPane.PLAIN_MESSAGE);
                    return;
                }
                setSourceDirectory(multiSelection);
                GUI_Start = true;
            } catch (Exception err) {
                err.printStackTrace();
            }
        }
    });
    btnStart.setBounds(40, 153, 89, 23);
    panel_2.add(btnStart);

    JButton btnStop = new JButton("Stop");
    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GUI_Stop = true;
        }
    });
    btnStop.setBounds(169, 153, 89, 23);
    panel_2.add(btnStop);

    JButton btnNewButton = new JButton("Pause");
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GUI_Pause = true;
        }
    });
    btnNewButton.setBounds(298, 153, 89, 23);
    panel_2.add(btnNewButton);

    JCheckBox chckbxDeleteDuplicateFiles = new JCheckBox("Delete duplicate files");
    chckbxDeleteDuplicateFiles.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            deleteCopyResults = true;
        }
    });
    chckbxDeleteDuplicateFiles.setBounds(230, 10, 150, 16);
    panel_2.add(chckbxDeleteDuplicateFiles);

    JCheckBox chckbxLogDuplicateFiles = new JCheckBox("Save duplicates to file");
    chckbxLogDuplicateFiles.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            saveCopyResults = true;
        }
    });
    chckbxLogDuplicateFiles.setBounds(230, 36, 150, 16);
    panel_2.add(chckbxLogDuplicateFiles);

    // -------------------------------------------------------------------
    // ----------------------- JPanel_3 Components -----------------------

    JLabel lblAbout = new JLabel("About");
    GridBagConstraints gbc_lblAbout = new GridBagConstraints();
    gbc_lblAbout.insets = new Insets(0, 0, 5, 5);
    gbc_lblAbout.gridx = 0;
    gbc_lblAbout.gridy = 0;
    panel_3.add(lblAbout, gbc_lblAbout);

    JLabel lblTutorials = new JLabel("Tutorials");
    GridBagConstraints gbc_lblTutorials = new GridBagConstraints();
    gbc_lblTutorials.insets = new Insets(0, 0, 5, 5);
    gbc_lblTutorials.gridx = 1;
    gbc_lblTutorials.gridy = 0;
    panel_3.add(lblTutorials, gbc_lblTutorials);

    JLabel lblUpdates = new JLabel("Updates");
    GridBagConstraints gbc_lblUpdates = new GridBagConstraints();
    gbc_lblUpdates.insets = new Insets(0, 0, 5, 0);
    gbc_lblUpdates.gridx = 2;
    gbc_lblUpdates.gridy = 0;
    panel_3.add(lblUpdates, gbc_lblUpdates);

    JButton btnInformation = new JButton("Information");
    btnInformation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    GridBagConstraints gbc_btnInformation = new GridBagConstraints();
    gbc_btnInformation.insets = new Insets(0, 0, 0, 5);
    gbc_btnInformation.gridx = 0;
    gbc_btnInformation.gridy = 1;
    panel_3.add(btnInformation, gbc_btnInformation);

    JButton btnExamples = new JButton("Examples");
    btnExamples.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    GridBagConstraints gbc_btnExamples = new GridBagConstraints();
    gbc_btnExamples.insets = new Insets(0, 0, 0, 5);
    gbc_btnExamples.gridx = 1;
    gbc_btnExamples.gridy = 1;
    panel_3.add(btnExamples, gbc_btnExamples);

    JButton btnCheckNow = new JButton("Check Now");
    btnCheckNow.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    GridBagConstraints gbc_btnCheckNow = new GridBagConstraints();
    gbc_btnCheckNow.gridx = 2;
    gbc_btnCheckNow.gridy = 1;
    panel_3.add(btnCheckNow, gbc_btnCheckNow);
}

From source file:Visuals.PieChart.java

public JPanel addCharts() {
    ChartPanel piePanel = drawPieChart();
    piePanel.setDomainZoomable(true);/*ww w  .  j  a va 2  s  .  c  o m*/
    JPanel thisPiePanel = new JPanel();

    String[][] finalRisks = new String[riskCount][4];
    for (int i = 0; i < riskCount; i++) {
        finalRisks[i][0] = risks[i][0];
        finalRisks[i][1] = risks[i][1];
        finalRisks[i][2] = risks[i][2];
        finalRisks[i][3] = risks[i][3];
    }

    JTable table = new JTable(finalRisks, columns);
    //table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    TableRowSorter<TableModel> sorter = new TableRowSorter<>(table.getModel());
    table.setRowSorter(sorter);
    List<RowSorter.SortKey> sortKeys = new ArrayList<>();

    int columnIndexToSort = 2;
    sortKeys.add(new RowSorter.SortKey(columnIndexToSort, SortOrder.ASCENDING));

    sorter.setSortKeys(sortKeys);
    sorter.sort();

    TableColumn tcol = table.getColumnModel().getColumn(2);
    table.removeColumn(tcol);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    table.getColumnModel().getColumn(1).setPreferredWidth(600);

    table.getColumnModel().getColumn(2).setPreferredWidth(600);

    JLabel right = new JLabel(
            "                                                                                                    ");
    thisPiePanel.add(right, BorderLayout.EAST);

    table.setShowHorizontalLines(true);
    table.setRowHeight(40);

    JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    Dimension d = table.getPreferredSize();
    tableScrollPane
            .setPreferredSize(new Dimension((d.width - 400), (table.getRowHeight() + 1) * (riskCount + 1)));
    table.setEnabled(false);
    thisPiePanel.setLayout(new BorderLayout());
    if (riskCount == 0) {

        thisPiePanel.add(piePanel, BorderLayout.CENTER);
    } else {
        thisPiePanel.add(right, BorderLayout.EAST);
        thisPiePanel.add(piePanel, BorderLayout.CENTER);
        thisPiePanel.add(tableScrollPane, BorderLayout.SOUTH);
    }
    thisPiePanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
    return thisPiePanel;
}

From source file:org.ut.biolab.medsavant.client.view.UpdatesPanel.java

private void showPopup(final int start) {
    popup = new JPopupMenu();
    popup.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1));

    if (notifications == null) {
        popup.add(new NotificationIcon(null, null));
    } else {//from  w w  w .  j a  v  a2s  .  c o m

        //add notifications
        for (int i = start; i < Math.min(start + 5, notifications.length); i++) {
            popup.add(new NotificationIcon(notifications[i], popup));
            if (i != Math.min(start + 5, notifications.length) - 1) {
                popup.add(createSeparator());
            }
        }

        //add page header
        if (notifications.length > 5) {
            JPanel header = new JPanel();
            header.setMinimumSize(new Dimension(1, 15));
            header.setLayout(new BoxLayout(header, BoxLayout.X_AXIS));
            if (start >= 5) {
                JLabel prevButton = ViewUtil.createLabelButton("  Prev Page  ");
                prevButton.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        showPopup(start - 5);
                    }
                });
                header.add(prevButton);
            }
            header.add(Box.createHorizontalGlue());
            if (start + 5 < notifications.length) {
                JLabel nextButton = ViewUtil.createLabelButton("  Next Page  ");
                nextButton.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        showPopup(start + 5);
                    }
                });
                header.add(nextButton);
            }
            popup.add(createSeparator());
            popup.add(header);
        }
    }

    //int offset = -Math.min(5, notifications.length - start) * (MENU_ICON_SIZE.height + 2) -3 - (headerAdded ? 16 : 0);        
    popup.show(this, 0, this.getPreferredSize().height);
}

From source file:com.limegroup.gnutella.gui.notify.AnimatedWindow.java

public static void main(String[] args) {
    JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createLineBorder(Color.black, 2));
    JLabel label = new JLabel("Hello World");
    label.setIcon(UIManager.getIcon("FileView.computerIcon"));
    label.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    content.add(label, BorderLayout.CENTER);

    final AnimatedWindow window = new AnimatedWindow(null);
    window.setFinalLocation(new Point(200, 200));
    window.setContentPane(content);//from  ww  w. j  a  v a2s .  c  o m

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 10));

    JButton button = new JButton("Bottom -> Top");
    buttonPanel.add(button);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            window.setMode(AnimationMode.BOTTOM_TO_TOP);
            if (!window.isVisible() || window.isHideAnimationInProgress()) {
                window.doShow();
            } else {
                window.doHide();
            }
        }
    });

    button = new JButton("Top -> Bottom");
    buttonPanel.add(button);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            window.setMode(AnimationMode.TOP_TO_BOTTOM);
            if (!window.isVisible() || window.isHideAnimationInProgress()) {
                window.doShow();
            } else {
                window.doHide();
            }
        }
    });

    button = new JButton("Fade");
    buttonPanel.add(button);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            window.setMode(AnimationMode.FADE);
            if (!window.isVisible() || window.isHideAnimationInProgress()) {
                window.doShow();
            } else {
                window.doHide();
            }
        }
    });

    JFrame app = new JFrame("AnimatedWindow Demo");
    app.setContentPane(buttonPanel);
    app.pack();
    app.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    app.setVisible(true);
}

From source file:volker.streaming.music.gui.FormatPanel.java

private void initComponents() {
    formatLabel = new JLabel("How should your track info be displayed:");
    formatArea = new JTextArea(config.getFormat());
    formatLighter = new DefaultHighlighter();
    // TODO allow configuration of this color
    formatPainter = new DefaultHighlighter.DefaultHighlightPainter(new Color(200, 200, 255));
    formatArea.setHighlighter(formatLighter);
    formatArea.getDocument().addDocumentListener(new DocumentListener() {
        @Override//from w ww  .  j a v  a  2  s .  co  m
        public void removeUpdate(DocumentEvent e) {
            formatUpdated();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            formatUpdated();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            formatUpdated();
        }
    });

    ImageIcon infoIcon = null;
    try {
        InputStream is = getClass().getResourceAsStream("info.png");
        if (is == null) {
            LOG.error("Couldn't find the info image.");
        } else {
            infoIcon = new ImageIcon(ImageIO.read(is));
            is.close();
        }
    } catch (IOException e1) {
        LOG.error("Couldn't find the info image.", e1);
    }
    if (infoIcon == null) {
        formatInfoButton = new JButton("?");
    } else {
        formatInfoButton = new JButton(infoIcon);
        formatInfoButton.setBorder(BorderFactory.createEmptyBorder());
    }

    formatInfoButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            showFormatHelp();
        }
    });

    templateLabel = new JLabel("Your template:");

    tagLabel = new JLabel("Available tags:");
    tagList = new JList<String>(new AbstractListModel<String>() {
        private static final long serialVersionUID = -8886588605378873151L;

        @Override
        public int getSize() {
            return properTags.size();
        }

        @Override
        public String getElementAt(int index) {
            return properTags.get(index);
        }
    });
    tagScrollPane = new JScrollPane(tagList);

    previewLabel = new JLabel("Preview:");
    previewField = new JTextField();
    previewField.setEditable(false);
    previewField.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
    previewField.setBackground(new Color(255, 255, 150));

    formatUpdated();
    highlightTags();

    nullMessageLabel = new JLabel("Message to display when no song is found:");
    nullMessageField = new JTextField(config.getNoTrackMessage() == null ? "" : config.getNoTrackMessage());
    nullMessageField.getDocument().addDocumentListener(new DocumentListener() {
        public void action() {
            config.setNoTrackMessage(nullMessageField.getText());
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            action();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            action();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            action();
        }
    });

    hline = new JSeparator(SwingConstants.HORIZONTAL);
    fileLabel = new JLabel("Location of text file:");
    fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fileField = new JTextField(15);
    if (config.getOutputFile() != null) {
        fileField.setText(config.getOutputFile().getAbsolutePath());
    }
    fileField.getDocument().addDocumentListener(new DocumentListener() {
        public void action() {
            config.setOutputFile(new File(fileField.getText()));
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            action();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            action();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            action();
        }
    });
    fileButton = new JButton("Browse");
    fileButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            browseFile();
        }
    });
}

From source file:ConfigFiles.java

public ConfigFiles(Dimension screensize) {
    //         initializeFileBrowser();
    paths = new JPanel();
    paths.setBackground(Color.WHITE);
    //paths.setBorder(BorderFactory.createTitledBorder("Paths"));
    paths.setLayout(null);//from   www.j av a2s .c o  m
    paths.setPreferredSize(new Dimension(930, 1144));
    paths.setSize(new Dimension(930, 1144));
    paths.setMinimumSize(new Dimension(930, 1144));
    paths.setMaximumSize(new Dimension(930, 1144));
    //paths.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    setLayout(null);
    ttcpath = new JTextField();
    addPanel("TestCase Source Path",
            "Master directory with the test cases that can" + " be run by the framework", ttcpath,
            RunnerRepository.TESTSUITEPATH, 10, true, null);
    tMasterXML = new JTextField();
    tUsers = new JTextField();

    addPanel("Projects Path", "Location of projects XML files", tUsers, RunnerRepository.REMOTEUSERSDIRECTORY,
            83, true, null);

    tSuites = new JTextField();
    addPanel("Predefined Suites Path", "Location of predefined suites", tSuites,
            RunnerRepository.PREDEFINEDSUITES, 156, true, null);

    testconfigpath = new JTextField();
    addPanel("Test Configuration Path", "Test Configuration path", testconfigpath,
            RunnerRepository.TESTCONFIGPATH, 303, true, null);

    tepid = new JTextField();
    addPanel("EP name File", "Location of the file that contains" + " the Ep name list", tepid,
            RunnerRepository.REMOTEEPIDDIR, 595, true, null);
    tlog = new JTextField();
    addPanel("Logs Path", "Location of the directory that stores the most recent log files."
            + " The files are re-used each Run.", tlog, RunnerRepository.LOGSPATH, 667, true, null);
    tsecondarylog = new JTextField();

    JPanel p = addPanel("Secondary Logs Path",
            "Location of the directory that archives copies of the most recent log files, with"
                    + " original file names appended with <.epoch time>",
            tsecondarylog, RunnerRepository.SECONDARYLOGSPATH, 930, true, null);
    logsenabled.setSelected(Boolean.parseBoolean(RunnerRepository.PATHENABLED));
    logsenabled.setBackground(Color.WHITE);
    p.add(logsenabled);

    JPanel p7 = new JPanel();
    p7.setBackground(Color.WHITE);
    TitledBorder border7 = BorderFactory.createTitledBorder("Log Files");
    border7.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border7.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p7.setBorder(border7);
    p7.setLayout(new BoxLayout(p7, BoxLayout.Y_AXIS));
    p7.setBounds(80, 740, 800, 190);
    paths.add(p7);
    JTextArea log2 = new JTextArea("All the log files that will be monitored");
    log2.setWrapStyleWord(true);
    log2.setLineWrap(true);
    log2.setEditable(false);
    log2.setCursor(null);
    log2.setOpaque(false);
    log2.setFocusable(false);
    log2.setBorder(null);
    log2.setFont(new Font("Arial", Font.PLAIN, 12));
    log2.setBackground(getBackground());
    log2.setMaximumSize(new Dimension(170, 25));
    log2.setPreferredSize(new Dimension(170, 25));
    JPanel p71 = new JPanel();
    p71.setBackground(Color.WHITE);
    p71.setLayout(new GridLayout());
    p71.setMaximumSize(new Dimension(700, 13));
    p71.setPreferredSize(new Dimension(700, 13));
    p71.add(log2);
    JPanel p72 = new JPanel();
    p72.setBackground(Color.WHITE);
    p72.setLayout(new BoxLayout(p72, BoxLayout.Y_AXIS));
    trunning = new JTextField();
    p72.add(addField(trunning, "Running: ", 0));
    tdebug = new JTextField();
    p72.add(addField(tdebug, "Debug: ", 1));
    tsummary = new JTextField();
    p72.add(addField(tsummary, "Summary: ", 2));
    tinfo = new JTextField();
    p72.add(addField(tinfo, "Info: ", 3));
    tcli = new JTextField();
    p72.add(addField(tcli, "Cli: ", 4));
    p7.add(p71);
    p7.add(p72);
    libpath = new JTextField();

    addPanel("Library path", "Secondary user library path", libpath, RunnerRepository.REMOTELIBRARY, 229, true,
            null);

    JPanel p8 = new JPanel();
    p8.setBackground(Color.WHITE);
    TitledBorder border8 = BorderFactory.createTitledBorder("File");
    border8.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border8.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p8.setBorder(border8);
    p8.setLayout(null);
    p8.setBounds(80, 1076, 800, 50);
    if (PermissionValidator.canChangeFWM()) {
        paths.add(p8);
    }
    JButton save = new JButton("Save");
    save.setToolTipText("Save and automatically load config");
    save.setBounds(490, 20, 70, 20);
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            saveXML(false, "fwmconfig");
            loadConfig("fwmconfig.xml");
        }
    });
    p8.add(save);
    //         if(!PermissionValidator.canChangeFWM()){
    //             save.setEnabled(false);
    //         }
    JButton saveas = new JButton("Save as");
    saveas.setBounds(570, 20, 90, 20);
    saveas.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            String filename = CustomDialog.showInputDialog(JOptionPane.QUESTION_MESSAGE,
                    JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "File Name", "Please enter file name");
            if (!filename.equals("NULL")) {
                saveXML(false, filename);
            }
        }
    });
    p8.add(saveas);

    final JButton loadXML = new JButton("Load Config");
    loadXML.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            try {
                String[] configs = RunnerRepository
                        .getRemoteFolderContent(RunnerRepository.USERHOME + "/twister/config/");
                JComboBox combo = new JComboBox(configs);
                int resp = (Integer) CustomDialog.showDialog(combo, JOptionPane.INFORMATION_MESSAGE,
                        JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "Config", null);
                final String config;
                if (resp == JOptionPane.OK_OPTION)
                    config = combo.getSelectedItem().toString();
                else
                    config = null;
                if (config != null) {
                    new Thread() {
                        public void run() {
                            setEnabledTabs(false);
                            JFrame progress = new JFrame();
                            progress.setAlwaysOnTop(true);
                            progress.setLocation((int) loadXML.getLocationOnScreen().getX(),
                                    (int) loadXML.getLocationOnScreen().getY());
                            progress.setUndecorated(true);
                            JProgressBar bar = new JProgressBar();
                            bar.setIndeterminate(true);
                            progress.add(bar);
                            progress.pack();
                            progress.setVisible(true);
                            loadConfig(config);
                            progress.dispose();
                            setEnabledTabs(true);
                        }
                    }.start();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    loadXML.setBounds(670, 20, 120, 20);
    p8.add(loadXML);
    //         if(!PermissionValidator.canChangeFWM()){
    //             loadXML.setEnabled(false);
    //         }

    tdbfile = new JTextField();
    addPanel("Database XML path", "File location for database configuration", tdbfile,
            RunnerRepository.REMOTEDATABASECONFIGPATH + RunnerRepository.REMOTEDATABASECONFIGFILE, 375, true,
            null);
    temailfile = new JTextField();
    //         emailpanel = (JPanel)
    addPanel("Email XML path", "File location for email configuration", temailfile,
            RunnerRepository.REMOTEEMAILCONFIGPATH + RunnerRepository.REMOTEEMAILCONFIGFILE, 448, true, null)
                    .getParent();
    //paths.remove(emailpanel);

    //         emailpanel.setBounds(360,440,350,100);
    //         RunnerRepository.window.mainpanel.p4.getEmails().add(emailpanel);

    tglobalsfile = new JTextField();
    addPanel("Globals XML file", "File location for globals parameters", tglobalsfile,
            RunnerRepository.GLOBALSREMOTEFILE, 521, true, null);

    tceport = new JTextField();
    addPanel("Central Engine Port", "Central Engine port", tceport, RunnerRepository.getCentralEnginePort(),
            1003, false, null);
    //         traPort = new JTextField();
    //         addPanel("Resource Allocator Port","Resource Allocator Port",
    //                 traPort,RunnerRepository.getResourceAllocatorPort(),808,false,null);                
    //         thttpPort = new JTextField();
    //         addPanel("HTTP Server Port","HTTP Server Port",thttpPort,
    //                 RunnerRepository.getHTTPServerPort(),740,false,null);

    //paths.add(loadXML);

    if (!PermissionValidator.canChangeFWM()) {
        ttcpath.setEnabled(false);
        tMasterXML.setEnabled(false);
        tUsers.setEnabled(false);
        tepid.setEnabled(false);
        tSuites.setEnabled(false);
        tlog.setEnabled(false);
        trunning.setEnabled(false);
        tdebug.setEnabled(false);
        tsummary.setEnabled(false);
        tinfo.setEnabled(false);
        tcli.setEnabled(false);
        tdbfile.setEnabled(false);
        temailfile.setEnabled(false);
        tceport.setEnabled(false);
        libpath.setEnabled(false);
        tsecondarylog.setEnabled(false);
        testconfigpath.setEnabled(false);
        tglobalsfile.setEnabled(false);
        logsenabled.setEnabled(false);
    }

}

From source file:net.pandoragames.far.ui.swing.FileListPanel.java

private void init(SwingConfig config, ComponentRepository componentRepository) {

    this.setLayout(new BorderLayout());

    this.setBorder(
            BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING));

    tableModel = componentRepository.getTableModel();
    componentRepository.getResetDispatcher().addResetable(tableModel);
    componentRepository.getSearchBaseListener().addResetable(tableModel);
    componentRepository.getUndoListener().setTableModel(tableModel);

    JTable fileListTable = componentRepository.getFileSetTable();
    int totalWidth = fileListTable.getPreferredSize().width;
    fileListTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    fileListTable.setColumnSelectionAllowed(true);
    fileListTable.getTableHeader().addMouseListener(new TableHeaderMouseListener());
    fileListTable.getTableHeader().getColumnModel().getColumn(0)
            .setHeaderRenderer(new TableHeaderCheckBoxColumnRenderer());
    fileListPopupMenu = new FileListPopupMenu(fileListTable, tableModel, componentRepository, config);
    fileListTable.setComponentPopupMenu(fileListPopupMenu);
    fileListTable.addMouseListener(new FileViewOpener(fileListTable, componentRepository.getRootWindow(),
            config, componentRepository));
    fileListTable.getColumnModel().getColumn(0).setPreferredWidth(20);
    fileListTable.getColumnModel().getColumn(0).setMaxWidth(20);
    fileListTable.getColumnModel().getColumn(1).setCellRenderer(new TargetFileListTableCellRenderer());
    fileListTable.getColumnModel().getColumn(1).setPreferredWidth(2 * totalWidth / 5);
    fileListTable.getColumnModel().getColumn(2).setCellRenderer(new PathColumnRenderer());
    fileListTable.getColumnModel().getColumn(3).setCellRenderer(new InfoColumnRenderer(config));
    JScrollPane scrollPane = new JScrollPane(fileListTable);
    this.add(scrollPane, BorderLayout.CENTER);

    SelectCounter fileCounter = new SelectCounter();
    fileCounter.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING));
    fileCounter.setForeground(Color.GRAY);
    ErrorCounter errorCounter = new ErrorCounter();
    errorCounter.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING));
    JPanel counterLine = new JPanel();
    counterLine.setLayout(new BorderLayout());
    counterLine.add(fileCounter, BorderLayout.WEST);
    counterLine.add(errorCounter, BorderLayout.EAST);

    JProgressBar progressBar = new JProgressBar();
    progressBar.setEnabled(false);//from   www  .  j a v a  2 s .co m
    progressBar.setMaximumSize(new Dimension(100, 20));
    progressBar.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING));
    componentRepository.getProgressBarUpdater().setProgressBar(progressBar);
    JPanel progressBarPanel = new JPanel();
    progressBarPanel.add(progressBar);
    counterLine.add(progressBarPanel, BorderLayout.CENTER);

    counterLine.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
    this.add(counterLine, BorderLayout.SOUTH);

    tableModel.addTableModelListener(new ColumnCountListener(fileCounter));
    tableModel.addTableModelListener(errorCounter);
    componentRepository.getResetDispatcher().addResetable(fileCounter);
    componentRepository.getSearchBaseListener().addResetable(fileCounter);
    componentRepository.getOperationCallBackListener().addComponentStartReseted(fileCounter,
            OperationType.FIND);
    componentRepository.getResetDispatcher().addResetable(errorCounter);
    componentRepository.getSearchBaseListener().addResetable(errorCounter);

    viewAction = new ActionView(componentRepository, config);
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.corretor_eventos.PanelCorretorEventos.java

/**
 * Cria uma borda com ttulo dentro dos padres
 * /*from  w w  w.j  ava  2s .c  om*/
 * @param titulo
 * @return
 */
private Border criaBorda(String titulo) {
    Border bordaLinhaPreta = BorderFactory.createLineBorder(new Color(0, 0, 0), 1);
    Border borda = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5),
            new TitledBorder(bordaLinhaPreta, titulo));
    Border bordaFinal = BorderFactory.createCompoundBorder(borda, BorderFactory.createEmptyBorder(0, 4, 4, 5));
    return bordaFinal;
}

From source file:uk.sipperfly.ui.BackgroundWorker.java

/**
 * The main logic for the work that the background thread does.
 * This method is automatically called by the threading framework.
 * <p>//from w  w  w .j  a v  a2s.c o m
 * The following actions are performed:
 * 1. Recognize whether bag is organized in bagit structure or not.
 * 2. Validate bag.
 * 3. Validates the user can connect to the email server.
 * 4. Bags the input folder using the bagit Java library from the Library of Congress
 * 5. Transfer the folder and all subfolders to the target.
 * 6. Check ftp connection if file or folder is supposed to upload on ftp server
 * 7. upload files on ftp server
 * 8. Sends summary email to the UK Exactly
 *
 * @return 1 for success and -1 for failure
 * @see http://www.digitalpreservation.gov/documents/bagitspec.pdf
 */
@Override
protected Integer doInBackground() {
    try {
        String workingPath;
        if (this.process == 2) {
            if (!this.inputFolder.isEmpty() || this.inputFolder != null) {
                if (!this.parent.editCurrentStatus.getText().isEmpty()
                        && this.parent.editCurrentStatus.getText() != null) {
                    this.parent.UpdateResult("Recognizing Bag...", 1);
                } else {
                    this.parent.UpdateResult("Recognizing Bag...", 1);
                }
                Logger.getLogger(GACOM).log(Level.INFO, "Recognizing Bag");
                if (this.BagRecognition(this.inputFolder) == 0) {
                    this.parent.UpdateResult("Bag Recognition: Not organized in BagIt structure", 0);
                    Logger.getLogger(GACOM).log(Level.SEVERE,
                            "Bag Recognition: Not organized in BagIt structure.");
                    return -1;
                }
            }
        }
        if (this.process == 3 || this.process == 4) {
            if (!this.inputFolder.isEmpty() || this.inputFolder != null) {
                if (this.process == 4) {
                    this.parent.UpdateResult("Validating Bag Before Unbagging...", 1);
                    Logger.getLogger(GACOM).log(Level.INFO, "Validating bag before Unbagging");
                } else {
                    this.parent.UpdateResult("Validating Bag...", 1);
                    Logger.getLogger(GACOM).log(Level.INFO, "Validating Bag");
                }
                if (this.ValidateBag(this.inputFolder) == 0) {
                    Border border = BorderFactory.createLineBorder(Color.red, 2);
                    this.parent.inputLocationDir.setBorder(border);
                    this.parent.UpdateResult("Invalid bag.", 0);
                    Logger.getLogger(GACOM).log(Level.SEVERE, "Invalid bag.");
                    return -1;
                }
            }
        }

        if (this.process == 4) {
            int isExisted = 0;
            this.parent.unBaggingProgress.setMaximum(3);
            this.parent.UpdateResult("Copying data...", 0);
            Logger.getLogger(GACOM).log(Level.INFO, "Copying data...");
            File folder = new File(inputFolder);
            String name = FilenameUtils.removeExtension(folder.getName());
            workingPath = destFolder + File.separator + name;
            File dest = new File(destFolder + File.separator + FilenameUtils.removeExtension(folder.getName()));
            if (dest.exists()) {
                this.getFileSuffix(dest.toString());
                name = name + "_" + fileCounter;
                this.fileCounter = 1;
                workingPath = destFolder + File.separator + name;
                isExisted = 1;
            }
            if (folder.getName().toLowerCase().endsWith(".zip")) {
                String zipPath = "";
                Logger.getLogger(GACOM).log(Level.INFO, "Extracting files from zip folder");
                if (isExisted == 1) {
                    this.zipUtil.unZipIt(inputFolder, workingPath);
                    zipPath = workingPath;
                    workingPath = workingPath + File.separator
                            + FilenameUtils.removeExtension(folder.getName());
                } else {
                    this.zipUtil.unZipIt(inputFolder, destFolder);
                }

                this.parent.unBaggingProgress.setValue(1);
                if (this.validateAndUnbag(workingPath, name, zipPath) == 0) {
                    return -1;
                }
            } else {
                Logger.getLogger(GACOM).log(Level.INFO, "Copying data to destination");
                File targetDir = new File(workingPath);
                FileUtils.copyDirectory(folder, targetDir);
                this.parent.unBaggingProgress.setValue(1);
                if (this.validateAndUnbag(workingPath, name, "") == 0) {
                    return -1;
                }
            }
            this.resetFiles();
        }

        if (this.process == 1) {
            if (this.validateBagName()) {
                this.parent.UpdateResult(
                        "Folder already existed in destination with this title. Please change the title.", 0);
                Logger.getLogger(GACOM).log(Level.SEVERE,
                        "Folder already existed in destination with this title. Please change the title.");
                this.parent.btnTransferFiles.setEnabled(true);
                return -1;
            }
            this.parent.UpdateResult("Verifying Transfer...", 1);
            if (this.config.getEmailNotifications()) {
                // validate email auth
                if (!ValidateCredentials()) {
                    this.parent.UpdateResult("Credentials not valid. Please update Email Settings.", 0);
                    Logger.getLogger(GACOM).log(Level.SEVERE,
                            "Credentials not valid. Please update Email settings.");
                    this.parent.btnTransferFiles.setEnabled(true);
                    return -1;
                }
            }
            // check if drop location folder is not set.

            if (this.parent.editInputDir1.getText() == null || this.parent.editInputDir1.getText().isEmpty()) {
                this.parent.UpdateResult("Please select Transfer destination.", 0);
                Logger.getLogger(GACOM).log(Level.SEVERE, "Please select Transfer destination.");
                this.parent.btnTransferFiles.setEnabled(true);
                return -1;
            }
            // validate bag name.
            if (this.parent.bagNameField.getText() == null || this.parent.bagNameField.getText().isEmpty()) {
                this.parent.UpdateResult("Please provide Transfer name.", 0);
                Logger.getLogger(GACOM).log(Level.SEVERE, "Please provide Transfer name.");
                this.parent.btnTransferFiles.setEnabled(true);
                return -1;
            }
            if (this.config.getEmailNotifications()) {
                RecipientsRepo recipientsRepo = new RecipientsRepo();
                List<Recipients> recipients = recipientsRepo.getAll();
                if (recipients.size() < 1) {
                    this.parent.UpdateResult("Please add at least one recipient.", 0);
                    Logger.getLogger(GACOM).log(Level.SEVERE, "Please add at least one recipient.");
                    this.parent.btnTransferFiles.setEnabled(true);
                    return -1;
                }
            }
            if (this.parent.ftpDelivery.isSelected()) {
                String result = ValidateFTPCredentials();
                if (!(result.equals("FTPES") || result.equals("FTP"))) {
                    this.parent.UpdateResult("Credentials not valid. Please update FTP Settings.", 0);
                    Logger.getLogger(GACOM).log(Level.SEVERE,
                            "Credentials not valid. Please update FTP settings.");
                    this.parent.btnTransferFiles.setEnabled(true);
                    return -1;
                }
            }
            if (this.isCancelled()) {
                Logger.getLogger(GACOM).log(Level.INFO, "Transfer canceled.");
                this.parent.UpdateResult("Transfer canceled.", 0);
                return -1;
            }

            // Set the tragetPath of bag.
            this.setTragetPath();
            //transfer
            this.parent.UpdateResult("Transfering files...", 0);
            Logger.getLogger(GACOM).log(Level.INFO, "Transfering files...");
            Path target = TransferFiles();
            if (this.isCancelled()) {
                Logger.getLogger(GACOM).log(Level.INFO, "Canceling Transfer Files task.");
                Logger.getLogger(GACOM).log(Level.INFO, "Transfer canceled.");
                this.parent.UpdateResult("Transfer canceled.", 0);
                return -1;
            }
            // bagit
            this.parent.UpdateResult("Preparing Bag...", 0);
            Logger.getLogger(GACOM).log(Level.INFO, "Preparing Bag...");
            BagFolder();
            if (this.isCancelled()) {
                Logger.getLogger(GACOM).log(Level.INFO, "Canceling Bagit task.");
                return -1;
            }
            this.parent.btnCancel.setVisible(false);
            if (this.parent.ftpDelivery.isSelected()) {
                if (this.isCancelled()) {
                    Logger.getLogger(GACOM).log(Level.INFO, "Canceling Upload data to FTP");
                    return -1;
                }
                String result = ValidateFTPCredentials();
                if (!(result.equals("FTPES") || result.equals("FTP"))) {
                    this.parent.UpdateResult("Credentials not valid. Please update FTP Settings.", 0);
                    Logger.getLogger(GACOM).log(Level.SEVERE,
                            "Credentials not valid. Please update FTP settings.");
                    this.parent.btnTransferFiles.setEnabled(true);
                    return -1;

                }

                this.parent.jProgressBar2.setValue(this.parent.totalFiles + 1);
                if (this.isCancelled()) {
                    Logger.getLogger(GACOM).log(Level.INFO, "Canceling Upload data to FTP");
                    return -1;
                }

                this.parent.UpdateResult("Uploading data on FTP ...", 0);
                Logger.getLogger(GACOM).log(Level.INFO, "Uploading data on FTP ...");
                UploadFilesFTP();
                //               if (this.parent.serializeBag.isSelected()) {
                //                  this.parent.jProgressBar2.setValue(this.parent.totalFiles + 2);
                //               } else {
                //                  this.parent.jProgressBar2.setValue(this.parent.totalFiles + 8);
                //               }
            }
            if (this.isCancelled()) {
                Logger.getLogger(GACOM).log(Level.INFO, "Canceling send notification email(s).");
                return -1;
            }
            // send email to GA
            if (this.config.getEmailNotifications()) {
                this.parent.UpdateResult("Preparing to send notification email(s)...", 0);
                Logger.getLogger(GACOM).log(Level.INFO, "Preparing to send notification email(s)...");
                SendMail(target);
                if (this.isCancelled()) {
                    Logger.getLogger(GACOM).log(Level.INFO, "Canceling send notification email(s)");
                    return -1;
                }
                if (this.parent.ftpDelivery.isSelected()) {
                    this.parent.jProgressBar2.setValue(this.parent.totalFiles + 9);
                } else {
                    this.parent.jProgressBar2.setValue(this.parent.totalFiles + 1);
                }
            }
            this.parent.jProgressBar2.setValue(this.parent.jProgressBar2.getMaximum());
            Thread.sleep(2000);
            // update UI
            this.parent.list.resetEntryList();
            this.resetTransferFiles();
            this.parent.UpdateResult("Session complete.", 0);
            Logger.getLogger(GACOM).log(Level.INFO, "Session complete.");

        }
        return 1;
    } catch (Exception ex) {
        this.parent.btnTransferFiles.setEnabled(true);
        if (this.isCancelled()) {
            this.parent.UpdateResult("Transfer canceled. Clean up partially copied directories.", 0);
            Logger.getLogger(GACOM).log(Level.INFO,
                    "Transfer canceled. Clean up partially copied directories.");
            return -1;
        }
        this.parent.UpdateResult("An error occurred. Please contact support.", 0);
        Logger.getLogger(GACOM).log(Level.INFO, "An error occurred. Please contact support.", ex);
        return -1;
    }
}

From source file:Proiect.uploadFTP.java

public void propFTP() {
    uploadFTP.setBackground(Encrypter.color_light);
    pan1.setBackground(Encrypter.color_light);
    pan1.setBorder(BorderFactory.createEmptyBorder(6, 5, 10, 5));
    pan2.setBackground(Encrypter.color_light);
    inpan1.setBackground(Encrypter.color_light);
    inpan2.setBackground(Encrypter.color_light);
    pan3.setBackground(Encrypter.color_light);
    pan4.setBackground(Encrypter.color_light);

    adress.setForeground(Encrypter.color_blue);
    user.setForeground(Encrypter.color_blue);
    pass.setForeground(Encrypter.color_blue);
    folder.setForeground(Encrypter.color_blue);
    filen.setForeground(Encrypter.color_blue);

    adressf.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Encrypter.color_dark));
    adressf.setSelectionColor(Encrypter.color_black);
    adressf.setSelectedTextColor(Encrypter.color_white);
    adressf.setBackground(Encrypter.color_light);

    userf.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Encrypter.color_dark));
    userf.setSelectionColor(Encrypter.color_black);
    userf.setSelectedTextColor(Encrypter.color_white);
    userf.setBackground(Encrypter.color_light);

    passf.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Encrypter.color_dark));
    passf.setSelectionColor(Encrypter.color_black);
    passf.setSelectedTextColor(Encrypter.color_white);
    passf.setBackground(Encrypter.color_light);

    folderf.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Encrypter.color_dark));
    folderf.setSelectionColor(Encrypter.color_black);
    folderf.setSelectedTextColor(Encrypter.color_white);
    folderf.setBackground(Encrypter.color_light);

    status.setHorizontalAlignment(SwingConstants.RIGHT);

    ImageIcon title_icon = getImageIcon("assets/icons/upload.png");
    titleFTP.setForeground(Encrypter.color_blue);
    titleFTP.setFont(Encrypter.font16);/*from   ww  w  . j a  v a2s .  c o m*/
    titleFTP.setIcon(title_icon);

    connect.setBackground(Encrypter.color_light);
    connect.setBorder(BorderFactory.createEmptyBorder());
    connect.setForeground(Encrypter.color_black);
    connect.setFont(Encrypter.font16);
    connect.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    connect.setToolTipText("Transfer File");

    browsef.setBackground(Encrypter.color_light);
    browsef.setBorder(BorderFactory.createEmptyBorder());
    browsef.setForeground(Encrypter.color_black);
    browsef.setFont(Encrypter.font16);
    browsef.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    browsef.setToolTipText("Add file");

    ImageIcon exit_icon = getImageIcon("assets/icons/exit.png");
    exit.setBackground(Encrypter.color_light);
    exit.setBorder(BorderFactory.createLineBorder(Encrypter.color_dark, 0));
    exit.setForeground(Encrypter.color_black);
    exit.setFont(Encrypter.font16);
    exit.setIcon(exit_icon);
    exit.setToolTipText("Exit");

    ImageIcon adv_icon = getImageIcon("assets/icons/adv_ftp.png");
    adv.setIcon(adv_icon);
    adv.setBackground(Encrypter.color_light);
    adv.setBorder(BorderFactory.createLineBorder(Encrypter.color_light, 0));
    adv.setFont(Encrypter.font16);
    adv.setToolTipText("Display server files");
    adv.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    chooserf.addChoosableFileFilter(new FileNameExtensionFilter("Text", "txt"));
    chooserf.addChoosableFileFilter(new FileNameExtensionFilter("HTM", "htm"));
    chooserf.addChoosableFileFilter(new FileNameExtensionFilter("XHTML", "xhtml"));
    chooserf.addChoosableFileFilter(new FileNameExtensionFilter("HTML", "html"));
    chooserf.setAcceptAllFileFilterUsed(false);
}