Example usage for javax.swing JPanel setOpaque

List of usage examples for javax.swing JPanel setOpaque

Introduction

In this page you can find the example usage for javax.swing JPanel setOpaque.

Prototype

@BeanProperty(expert = true, description = "The component's opacity")
public void setOpaque(boolean isOpaque) 

Source Link

Document

If true the component paints every pixel within its bounds.

Usage

From source file:org.ecoinformatics.seek.datasource.eml.eml2.Eml200DataSource.java

public void preview() {

    String displayText = "PREVIEW NOT IMPLEMENTED FOR THIS ACTOR";
    JFrame frame = new JFrame(this.getName() + " Preview");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    JPanel panel = new JPanel(new BorderLayout());
    JScrollPane scrollPane = null;
    JTable jtable = null;//from   w  w w  .  j a va2s .  c o  m

    try {

        // set everything up (datawise)
        this.initialize();

        // check the entity - different displays for different formats
        // Compressed file
        if (this._selectedTableEntity.getHasGZipDataFile() || this._selectedTableEntity.getHasTarDataFile()
                || this._selectedTableEntity.getHasZipDataFile()) {
            displayText = "Selected entity is a compressed file.  \n"
                    + "Preview not implemented for output format: " + this.dataOutputFormat.getExpression();
            if (this._dataOutputFormat instanceof Eml200DataOutputFormatUnzippedFileName) {
                Eml200DataOutputFormatUnzippedFileName temp = (Eml200DataOutputFormatUnzippedFileName) this._dataOutputFormat;
                displayText = "Files: \n";
                for (int i = 0; i < temp.getTargetFilePathInZip().length; i++) {
                    displayText += temp.getTargetFilePathInZip()[i] + "\n";
                }
            }

        }
        // SPATIALRASTERENTITY or SPATIALVECTORENTITY are "image entities"
        // as far as the parser is concerned
        else if (this._selectedTableEntity.getIsImageEntity()) {
            // use the content of the cache file
            displayText = new String(this.getSelectedCachedDataItem().getData());
        }
        // TABLEENTITY
        else {
            // holds the rows for the table on disk with some in memory
            String vectorTempDir = DotKeplerManager.getInstance().getCacheDirString();
            // + "vector"
            // + File.separator;
            PersistentVector rowData = new PersistentVector(vectorTempDir);

            // go through the rows and add them to the persistent vector
            // model
            Vector row = this.gotRowVectorFromSource();
            while (!row.isEmpty()) {
                rowData.addElement(row);
                row = this.gotRowVectorFromSource();
            }
            // the column headers for the table
            Vector columns = this.getColumns();

            /*
             * with java 6, there is a more built-in sorting mechanism that
             * does not require the custom table sorter class
             */
            TableModel tableModel = new PersistentTableModel(rowData, columns);
            TableSorter tableSorter = new TableSorter(tableModel);
            jtable = new JTable(tableSorter) {
                // make this table read-only by overriding the default
                // implementation
                public boolean isCellEditable(int row, int col) {
                    return false;
                }
            };
            // sets up the listeners for sorting and such
            tableSorter.setTableHeader(jtable.getTableHeader());
            // set up the listener to trash persisted data when done
            frame.addWindowListener(new PersistentTableModelWindowListener((PersistentTableModel) tableModel));
        }
    } catch (Exception e) {
        displayText = "Problem encountered while generating preview: \n" + e.getMessage();
        log.error(displayText);
        e.printStackTrace();
    }

    // make sure there is a jtable, otherwise show just a text version of
    // the data
    if (jtable != null) {
        jtable.setVisible(true);
        // jtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        scrollPane = new JScrollPane(jtable);
    } else {
        JTextArea textArea = new JTextArea();
        textArea.setColumns(80);
        textArea.setText(displayText);
        textArea.setVisible(true);
        scrollPane = new JScrollPane(textArea);
    }
    scrollPane.setVisible(true);
    panel.setOpaque(true);
    panel.add(scrollPane, BorderLayout.CENTER);
    frame.setContentPane(panel);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:org.isatools.gui.datamanager.exportisa.ExportISAGUI.java

public void createGUI() {
    // header image
    add(UIHelper.wrapComponentInPanel(new JLabel(panelHeader, SwingConstants.RIGHT)), BorderLayout.NORTH);

    // add a checkable jtree with investigations & studies...
    JPanel availableSubmissionsContainer = new JPanel(new BorderLayout());
    availableSubmissionsContainer.setOpaque(false);

    JPanel optionsContainer = new JPanel();
    optionsContainer.setLayout(new BoxLayout(optionsContainer, BoxLayout.LINE_AXIS));
    optionsContainer.setOpaque(false);//from  w  w w .ja v a 2s . c  o m

    JPanel optionsAndInformationPanel = new JPanel();
    optionsAndInformationPanel.setLayout(new BoxLayout(optionsAndInformationPanel, BoxLayout.PAGE_AXIS));
    optionsAndInformationPanel.setOpaque(false);

    JLabel fileInformation = UIHelper.createLabel("<html><i>where</i> to save the isatab files?</html>",
            UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR);
    fileInformation.setVerticalAlignment(JLabel.TOP);

    JPanel fileLocationOptionContainer = new JPanel();
    fileLocationOptionContainer.setLayout(new BoxLayout(fileLocationOptionContainer, BoxLayout.PAGE_AXIS));
    fileLocationOptionContainer.setOpaque(false);

    // add component for selection of output to repository or output to folder...
    fileLocationOptionGroup = new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true);
    fileLocationOptionGroup.addOptionItem("BII repository", true);
    fileLocationOptionGroup.addOptionItem("Local file system");

    localDirectoryLocation = new FileSelectionUtil("select output directory", createFileChooser(),
            UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR);
    localDirectoryLocation.setVisible(false);
    localDirectoryLocation.setPreferredSize(new Dimension(150, 20));

    fileLocationOptionGroup.addPropertyChangeListener("optionSelectionChange", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            localDirectoryLocation
                    .setVisible(fileLocationOptionGroup.getSelectedItem().equals("Local file system"));
            revalidate();
        }
    });

    fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(fileInformation));
    fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(fileLocationOptionGroup));
    fileLocationOptionContainer.add(Box.createVerticalStrut(5));
    fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(localDirectoryLocation));

    optionsContainer.add(fileLocationOptionContainer);

    JPanel dataFileExportOptionContainer = new JPanel();
    dataFileExportOptionContainer.setLayout(new BoxLayout(dataFileExportOptionContainer, BoxLayout.PAGE_AXIS));
    dataFileExportOptionContainer.setOpaque(false);

    JLabel dataFileExportInformation = UIHelper.createLabel("<html>export data files?</html>",
            UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR);
    dataFileExportInformation.setVerticalAlignment(JLabel.TOP);

    dataFileExportOptionGroup = new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true);
    dataFileExportOptionGroup.addOptionItem("yes", true);
    dataFileExportOptionGroup.addOptionItem("no");

    dataFileExportOptionContainer.add(UIHelper.wrapComponentInPanel(dataFileExportInformation));
    dataFileExportOptionContainer.add(UIHelper.wrapComponentInPanel(dataFileExportOptionGroup));
    dataFileExportOptionContainer.add(Box.createVerticalStrut(25));

    optionsContainer.add(dataFileExportOptionContainer);

    optionsAndInformationPanel.add(Box.createVerticalStrut(5));
    optionsAndInformationPanel.add(optionsContainer);
    optionsAndInformationPanel.add(Box.createVerticalStrut(10));

    JLabel information = UIHelper.createLabel(
            "<html>please <i>select</i> the submissions to be exported...</html>", UIHelper.VER_12_BOLD,
            UIHelper.LIGHT_GREY_COLOR);
    information.setVerticalAlignment(JLabel.TOP);

    optionsAndInformationPanel.add(UIHelper.wrapComponentInPanel(information));
    optionsAndInformationPanel.add(Box.createVerticalStrut(5));

    availableSubmissionsContainer.add(optionsAndInformationPanel, BorderLayout.NORTH);

    retrieveAndProcessStudyInformation();

    JScrollPane treeScroller = new JScrollPane(studyAvailabilityTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    treeScroller.getViewport().setOpaque(false);
    treeScroller.setOpaque(false);
    treeScroller.setBorder(new EmptyBorder(1, 1, 1, 1));

    treeScroller.setPreferredSize(new Dimension(380, 250));

    availableSubmissionsContainer.add(treeScroller, BorderLayout.CENTER);
    add(availableSubmissionsContainer, BorderLayout.CENTER);
    add(createSouthPanel(), BorderLayout.SOUTH);
}

From source file:org.isatools.gui.datamanager.exportisa.ExportISAGUI.java

private JPanel createSouthPanel() {
    JPanel southPanel = new JPanel(new BorderLayout());
    southPanel.setOpaque(false);

    errorDisplay = new JLabel(warningIcon);
    UIHelper.renderComponent(errorDisplay, UIHelper.VER_11_BOLD, UIHelper.LIGHT_GREY_COLOR, false);
    errorDisplay.setVisible(false);//from  ww  w  .  j a v a 2  s. co  m

    southPanel.add(UIHelper.wrapComponentInPanel(errorDisplay), BorderLayout.NORTH);

    southPanel.add(createBackToMainMenuButton(), BorderLayout.WEST);

    final JLabel exportISAButton = new JLabel(exportISAIcon);
    exportISAButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            exportISAButton.setIcon(exportISAIcon);

            if (!selectedOutputFolderExists() && !exportToRepository()) {
                localDirectoryLocation.setBackgroundToError();
            } else {
                if (studyAvailabilityTree.getCheckedStudies(studyAvailabilityTree.getRoot()).size() == 0) {
                    errorDisplay.setText("<html>please select <i>at least one study</i> to export!</html>");
                    errorDisplay.setVisible(true);
                } else {
                    errorDisplay.setVisible(false);
                    firePropertyChange("doISATabExport", "", "doExport");
                }
            }
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            exportISAButton.setIcon(exportISAIcon);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            exportISAButton.setIcon(exportISAIconOver);
        }
    });

    southPanel.add(exportISAButton, BorderLayout.EAST);

    return southPanel;
}

From source file:org.isatools.gui.datamanager.studyaccess.StudyAccessionGUI.java

private JPanel createEmptyDbPanel() {
    JPanel errorPanel = new JPanel();
    errorPanel.setLayout(new BoxLayout(errorPanel, BoxLayout.PAGE_AXIS));
    errorPanel.setOpaque(false);

    errorPanel.add(new JLabel(noStudiesPresentInfo), JLabel.CENTER);

    // add button to go back to main menu!

    JPanel buttonPanel = new JPanel(new BorderLayout());
    buttonPanel.setOpaque(false);/*from  w w w  .  jav a2  s . co  m*/

    buttonPanel.add(createBackToMainMenuButton(), BorderLayout.WEST);

    errorPanel.add(Box.createVerticalStrut(20));
    errorPanel.add(buttonPanel);

    return errorPanel;
}

From source file:org.isatools.gui.datamanager.studyaccess.StudyAccessionGUI.java

private JPanel createStudyAccessionLoadErrorPanel() {
    JPanel errorPanel = new JPanel();
    errorPanel.setLayout(new BoxLayout(errorPanel, BoxLayout.PAGE_AXIS));
    errorPanel.setOpaque(false);
    errorPanel.add(new JLabel(connectionProblemInfo), JLabel.CENTER);
    return errorPanel;
}

From source file:org.isatools.gui.datamanager.studyaccess.StudyAccessionGUI.java

private JPanel createStudySelectionPanel() {

    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));
    container.setOpaque(false);

    JPanel studyAccessionSelector = new JPanel();
    studyAccessionSelector.setLayout(new BorderLayout());
    studyAccessionSelector.setOpaque(false);

    JLabel information = new JLabel(unloadStudyHeader);
    information.setHorizontalAlignment(SwingConstants.RIGHT);
    information.setVerticalAlignment(SwingConstants.TOP);

    studyAccessionSelector.add(information, BorderLayout.NORTH);

    retrieveAndProcessStudyInformation();

    JScrollPane treeScroller = new JScrollPane(studyAvailabilityTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    treeScroller.getViewport().setOpaque(false);
    treeScroller.setOpaque(false);/*  ww w .ja  v a  2 s . co  m*/
    treeScroller.setBorder(new EmptyBorder(1, 1, 1, 1));

    treeScroller.setPreferredSize(new Dimension(380, 210));

    studyAccessionSelector.add(treeScroller);

    container.add(studyAccessionSelector);

    // and need a convert button!
    JPanel buttonCont = new JPanel(new BorderLayout());
    buttonCont.setOpaque(false);

    final JLabel unload = new JLabel(this.unloadButton, JLabel.RIGHT);

    unload.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            unload.setIcon(unloadButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            unload.setIcon(StudyAccessionGUI.this.unloadButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            Set<String> studiesToUnload = studyAvailabilityTree
                    .getCheckedStudies(studyAvailabilityTree.getRoot());
            log.info("going to unload: ");
            for (String acc : studiesToUnload) {
                log.info("study with acc " + acc);
            }
            doUnloading(studiesToUnload);
        }

    });
    buttonCont.add(unload, BorderLayout.EAST);

    buttonCont.add(createBackToMainMenuButton(), BorderLayout.WEST);

    container.add(buttonCont);

    return container;
}

From source file:org.isatools.isacreator.filechooser.FileChooserUI.java

private JPanel createTopPanel() {

    final JTextField uri = new RoundedJTextField(20);
    final JTextField username = new RoundedJTextField(20);
    final JPasswordField password = new RoundedJPasswordField(20);

    final JPanel topContainer = new JPanel();
    topContainer.setLayout(new BoxLayout(topContainer, BoxLayout.PAGE_AXIS));
    topContainer.setBackground(UIHelper.BG_COLOR);

    HUDTitleBar titlePanel = new HUDTitleBar(null, null, true);
    add(titlePanel, BorderLayout.NORTH);
    titlePanel.installListeners();//  w w  w .  j  a v a  2  s.c om

    topContainer.add(titlePanel);

    JPanel buttonPanel = new JPanel(new GridLayout(1, 1));
    buttonPanel.setOpaque(false);

    JPanel fileSystemPanel = new JPanel();
    fileSystemPanel.setLayout(new BoxLayout(fileSystemPanel, BoxLayout.LINE_AXIS));
    fileSystemPanel.setBackground(UIHelper.BG_COLOR);

    localFsChoice = new JLabel(localFileSystemIcon, JLabel.LEFT);
    localFsChoice.setBackground(UIHelper.BG_COLOR);
    localFsChoice.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    localFsChoice.setIcon(localFileSystemIconOver);
                    remoteFsChoice.setIcon(remoteFileSystemIcon);
                    ftpConnectionContainer.setVisible(false);
                    topContainer.revalidate();
                    status.setText("");
                    fileBrowser = new LocalBrowser();
                    try {
                        updateTree(fileBrowser.getHomeDirectory());
                    } catch (IOException e) {
                        FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false,
                                FileBrowserTreeNode.DIRECTORY);
                        updateTree(defaultFTPNode);
                    }

                }
            });

        }
    });

    fileSystemPanel.add(localFsChoice);
    fileSystemPanel.add(Box.createHorizontalStrut(5));

    remoteFsChoice = new JLabel(remoteFileSystemIcon, JLabel.LEFT);
    remoteFsChoice.setBackground(UIHelper.BG_COLOR);
    remoteFsChoice.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    localFsChoice.setIcon(localFileSystemIcon);
                    remoteFsChoice.setIcon(remoteFileSystemIconOver);
                    ftpConnectionContainer.setVisible(true);
                    topContainer.revalidate();
                }
            });
            // immediately try to call FTP manager to get last sessions details
            final FTPAuthentication lastSession;
            if ((lastSession = ftpManager.getLastSession()) != null) {
                Thread remoteConnector = new Thread(new Runnable() {
                    public void run() {
                        connectToFTP(lastSession.getUri(), lastSession.getUsername(),
                                lastSession.getPassword());
                    }
                });
                remoteConnector.start();
            } else {
                errorAction("no ftp location");
            }

        }
    });

    fileSystemPanel.add(remoteFsChoice);
    fileSystemPanel.add(Box.createHorizontalStrut(5));

    status = UIHelper.createLabel("", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR);
    status.setHorizontalAlignment(JLabel.RIGHT);

    fileSystemPanel.add(status);

    buttonPanel.add(fileSystemPanel);

    topContainer.add(buttonPanel);

    // now create panel to configure the FTP site
    ftpConnectionContainer = new JPanel(new GridLayout(1, 1));
    ftpConnectionContainer.setBackground(UIHelper.BG_COLOR);

    JPanel userAuthFTP = new JPanel();
    userAuthFTP.setLayout(new BoxLayout(userAuthFTP, BoxLayout.LINE_AXIS));
    userAuthFTP.setOpaque(false);

    // add field to add URI
    JPanel uriPanel = new JPanel(new GridLayout(1, 2));
    uriPanel.setBackground(UIHelper.BG_COLOR);

    JLabel uriLab = UIHelper.createLabel("FTP URI: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR);
    UIHelper.renderComponent(uri, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    uriPanel.add(uriLab);
    uriPanel.add(uri);

    userAuthFTP.add(uriPanel);

    // add field to add username
    JPanel usernamePanel = new JPanel(new GridLayout(1, 2));
    usernamePanel.setBackground(UIHelper.BG_COLOR);

    JLabel usernameLab = UIHelper.createLabel("Username: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR);

    UIHelper.renderComponent(username, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    uriPanel.add(usernameLab);
    uriPanel.add(username);

    userAuthFTP.add(usernamePanel);

    // add field to add password
    JPanel passwordPanel = new JPanel(new GridLayout(1, 2));
    passwordPanel.setBackground(UIHelper.BG_COLOR);

    JLabel passwordLab = UIHelper.createLabel("Password: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR);

    UIHelper.renderComponent(password, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    passwordPanel.add(passwordLab);
    passwordPanel.add(password);

    userAuthFTP.add(passwordPanel);

    JLabel connectLab = new JLabel(connectIcon);
    connectLab.setOpaque(false);
    connectLab.setToolTipText("<html><b>Connect</b><p>Connect to the FTP source defined!</p></html>");

    connectLab.addMouseListener(new CommonMouseAdapter() {
        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            if (uri.getText() != null && !uri.getText().trim().equals("")) {
                String user = (username.getText() != null) ? username.getText() : "";
                String pass = (password.getPassword() != null) ? new String(password.getPassword()) : "";

                final FTPAuthentication newFTPLocation = new FTPAuthentication(uri.getText(), user, pass);

                Thread remoteConnector = new Thread(new Runnable() {
                    public void run() {
                        connectToFTP(newFTPLocation.getUri(), newFTPLocation.getUsername(),
                                newFTPLocation.getPassword());
                    }
                });
                remoteConnector.start();
            }
        }

    });

    userAuthFTP.add(connectLab);

    JLabel historyLab = new JLabel(viewHistoryIcon);
    historyLab.setOpaque(false);
    historyLab.setToolTipText(
            "<html><b>Search previously connected to FTP locations</b><p>Connect to a previously defined FTP location</p></html>");
    historyLab.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            SelectFromFTPHistory selectFTP = new SelectFromFTPHistory();
            selectFTP.addPropertyChangeListener("locationSelected", new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent event) {

                    if (event.getNewValue() != null) {
                        final FTPAuthentication ftpRecord = ftpManager
                                .retrieveFTPAuthenticationObject(event.getNewValue().toString());
                        Thread remoteConnector = new Thread(new Runnable() {
                            public void run() {
                                connectToFTP(ftpRecord.getUri(), ftpRecord.getUsername(),
                                        ftpRecord.getPassword());
                            }
                        });
                        remoteConnector.start();
                    }

                }
            });
            selectFTP.createGUI();
            showJDialogAsSheet(selectFTP);
        }

    });

    userAuthFTP.add(historyLab);

    ftpConnectionContainer.add(userAuthFTP);

    ftpConnectionContainer.setVisible(false);

    topContainer.add(ftpConnectionContainer);

    return topContainer;
}

From source file:org.isatools.isacreator.filechooser.FileChooserUI.java

/**
 * Create the Navigation Tree panel/*from w ww.  ja va 2s .  c  o m*/
 *
 * @return @see JPanel containing the navigation tree to browse a file system.
 */
private JPanel createNavTree() {
    JPanel treeContainer = new JPanel(new BorderLayout());
    treeContainer.setBackground(UIHelper.BG_COLOR);
    treeContainer
            .setBorder(new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR));

    JPanel navigationControls = new JPanel();
    navigationControls.setLayout(new BoxLayout(navigationControls, BoxLayout.LINE_AXIS));
    navigationControls.setOpaque(false);

    final JLabel navToParentDir = new JLabel(upIcon);
    navToParentDir.setOpaque(false);
    navToParentDir.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            navToParentDir.setIcon(upIcon);
            try {
                updateTree(fileBrowser.getParentDirectory());
            } catch (IOException e) {
                errorAction("problem occurred!");
            }
        }

        public void mouseEntered(MouseEvent event) {
            super.mouseEntered(event);
            navToParentDir.setIcon(upIconOver);
        }

        public void mouseExited(MouseEvent event) {
            super.mouseExited(event);
            navToParentDir.setIcon(upIcon);
        }
    });

    navigationControls.add(navToParentDir);
    navigationControls.add(Box.createHorizontalStrut(5));

    final JLabel navToHomeDir = new JLabel(homeIcon);
    navToHomeDir.setOpaque(false);
    navToHomeDir.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            navToHomeDir.setIcon(homeIcon);
            try {
                updateTree(fileBrowser.getHomeDirectory());

            } catch (IOException e) {
                if (e instanceof ConnectionException) {
                    status.setText("<html>status: not connected!</html>");
                }
                FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false,
                        FileBrowserTreeNode.DIRECTORY);
                updateTree(defaultFTPNode);
            }
        }

        public void mouseEntered(MouseEvent event) {
            super.mouseEntered(event);
            navToHomeDir.setIcon(homeIconOver);
        }

        public void mouseExited(MouseEvent event) {
            super.mouseExited(event);
            navToHomeDir.setIcon(homeIcon);
        }
    });

    navigationControls.add(navToHomeDir);
    navigationControls.add(Box.createGlue());

    treeContainer.add(navigationControls, BorderLayout.NORTH);

    try {
        treeModel = new DefaultTreeModel(fileBrowser.getHomeDirectory());
        directoryTree = new JTree(treeModel);
        directoryTree.setFont(UIHelper.VER_11_PLAIN);
        directoryTree.setCellRenderer(new FileSystemTreeCellRenderer());
    } catch (IOException e) {
        FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false,
                FileBrowserTreeNode.DIRECTORY);
        updateTree(defaultFTPNode);
    }

    directoryTree.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            int selRow = directoryTree.getRowForLocation(event.getX(), event.getY());

            TreePath selPath = directoryTree.getPathForLocation(event.getX(), event.getY());

            if (selRow != -1) {
                final FileBrowserTreeNode node = (FileBrowserTreeNode) selPath.getLastPathComponent();

                if (SwingUtilities.isLeftMouseButton(event)) {

                    if (event.getClickCount() == 2) {
                        if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) {

                            String newPath;
                            if (fileBrowser instanceof LocalBrowser) {
                                newPath = ((File) fileBrowser.getDirFiles().get(node.toString())).getPath();
                            } else {
                                newPath = node.toString();
                            }
                            updateTree(fileBrowser.changeDirectory(newPath));
                        }

                        // else, if a leaf node, then add file to to list
                        if (node.isLeaf() && (node.getType() != FileBrowserTreeNode.DIRECTORY)) {
                            String extension = node.toString().substring(node.toString().lastIndexOf(".") + 1)
                                    .trim().toUpperCase();

                            FileChooserFile toAdd = null;

                            for (Object o : fileBrowser.getFileMap().get(extension)) {
                                String fileName;
                                String filePath;
                                if (fileBrowser instanceof LocalBrowser) {
                                    File file = (File) o;
                                    fileName = file.getName();
                                    filePath = file.getPath();

                                    if (fileName.equals(node.toString())) {
                                        toAdd = new CustomFile(filePath);
                                        break;
                                    }
                                } else {
                                    FTPFile ftpFile = (FTPFile) o;
                                    fileName = ftpFile.getName();
                                    filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator
                                            + ftpFile.getName();

                                    if (fileName.equals(node.toString())) {
                                        toAdd = new CustomFTPFile(ftpFile, filePath);
                                        break;
                                    }
                                }

                            }

                            if (toAdd != null && !checkIfInList(toAdd)) {
                                selectedFiles.addFileItem(toAdd);
                            }
                        }
                    }
                } else {
                    if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) {

                        // show popup to add the directory to the selected files
                        JPopupMenu popup = new JPopupMenu();

                        JMenuItem addDirectory = new JMenuItem("add directory");
                        addDirectory.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent ae) {

                                Object fileToAdd = fileBrowser.getDirFiles().get(node.toString());
                                FileChooserFile toAdd;

                                if (fileToAdd instanceof File) {
                                    toAdd = new CustomFile(((File) fileToAdd).getPath());
                                } else {
                                    FTPFile ftpFile = (FTPFile) fileToAdd;
                                    String filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator
                                            + ftpFile.getName();

                                    toAdd = new CustomFTPFile(ftpFile, filePath);
                                }

                                if (!checkIfInList(toAdd)) {
                                    selectedFiles.addDirectoryItem(toAdd);
                                }
                            }
                        });

                        popup.add(addDirectory);
                        popup.show(directoryTree, event.getX(), event.getY());
                    }
                }
            }
        }

    });

    BasicTreeUI ui = new BasicTreeUI() {
        public Icon getCollapsedIcon() {
            return null;
        }

        public Icon getExpandedIcon() {
            return null;
        }
    };

    directoryTree.setUI(ui);
    directoryTree.setFont(UIHelper.VER_12_PLAIN);

    JScrollPane treeScroll = new JScrollPane(directoryTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    treeScroll.setPreferredSize(new Dimension(300, 200));
    treeScroll.setBorder(new EmptyBorder(0, 0, 0, 0));
    treeContainer.add(treeScroll, BorderLayout.CENTER);

    IAppWidgetFactory.makeIAppScrollPane(treeScroll);

    return treeContainer;
}

From source file:org.isatools.isacreator.gui.DataEntryForm.java

/**
 * Create a field panel which has a grid layout, and is opaque
 *
 * @param rows    - Number of rows to be added for the field
 * @param columns - Number of columns to be added
 * @return JPanel with a GridLayout with the rows and columns specified
 *//*www.  j av  a  2  s. c o  m*/
public JPanel createFieldPanel(int rows, int columns) {
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(rows, columns));
    panel.setOpaque(false);
    return panel;
}

From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java

public void createGUI() {
    JPanel headerPanel = new JPanel(new GridLayout(1, 3));
    headerPanel.setBackground(UIHelper.BG_COLOR);

    viewSwitch = UIHelper.createLabel(VIEW_VIZ_TEXT, UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR);
    viewSwitch.setHorizontalAlignment(JLabel.RIGHT);
    viewSwitch.addMouseListener(this);

    nodeTypeSwitch = UIHelper.createLabel(VIEW_NODE_NAMES, UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR);
    nodeTypeSwitch.setHorizontalAlignment(JLabel.RIGHT);
    nodeTypeSwitch.addMouseListener(this);

    JPanel buttonPanel = new JPanel(new GridLayout(2, 1));
    buttonPanel.setOpaque(false);

    buttonPanel.add(viewSwitch);//from  w w  w .ja v  a2  s  .  com
    buttonPanel.add(nodeTypeSwitch);

    nodeTypeSwitch.setVisible(false);

    headerPanel.add(new JLabel(new ImageIcon(getClass().getResource("/images/visualization/assayinfo.png")),
            JLabel.LEFT));
    headerPanel.add(UIHelper.createLabel(assayAnalysis.getA().getAssayReference(), UIHelper.VER_14_BOLD,
            UIHelper.LIGHT_GREEN_COLOR, JLabel.CENTER));

    if (treatmentGroups.size() > 0) {
        headerPanel.add(buttonPanel);
    } else {
        // fill up allocation 3 slots in any case, otherwise view will be unbalanced!
        viewSwitch.setText("");
        headerPanel.add(viewSwitch);
    }

    add(headerPanel, BorderLayout.NORTH);

    swappableContainer.add(prepareAssayInformation());

    add(swappableContainer, BorderLayout.CENTER);
}