Example usage for javax.swing BorderFactory createCompoundBorder

List of usage examples for javax.swing BorderFactory createCompoundBorder

Introduction

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

Prototype

public static CompoundBorder createCompoundBorder(Border outsideBorder, Border insideBorder) 

Source Link

Document

Creates a compound border specifying the border objects to use for the outside and inside edges.

Usage

From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java

private void initDatasetSelectionPanel() {
    datasetSelectionPanel = new JPanel();
    datasetSelectionPanel// w ww  .  j av  a 2  s .c o m
            .setPreferredSize(new Dimension(DATA_SELECTION_PANEL_WIDTH, DATA_SELECTION_PANEL_HEIGHT));
    datasetSelectionPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Data Selection"), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    if (!dao.isGuestMode()) {
        datasetSelectionPanel.add(datasetLabel);
        datasetSelectionPanel.add(datasetCombo);

        datasetCombo.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                hidePanel(interpolationParamsSelectionPanel);
                hidePanel(miningFunctionSelectionPanel);
                hidePanel(miningFunctionParamsSelectionPanel);
                hidePanel(displayInstructionPanel);
                hidePanel(performancePanel);
                hidePanel(displayStatsPanel);
                hidePanel(selectIndividualsPanel);
                hidePanel(selectTimespanPanel);

                useLocalCopyButton.setEnabled(true);
                downloadOnlineButton.setEnabled(true);
                instructionLabel.setText("");
                String selectedDataset = (String) datasetCombo.getSelectedItem();
                if (isFileDownloaded(selectedDataset)) {
                    useLocalCopyButton.setVisible(true);
                } else {
                    useLocalCopyButton.setVisible(false);
                }
            }
        });

        useLocalCopyButton = new JButton("Use local copy");
        downloadOnlineButton = new JButton("Download from server");
        useLocalCopyButton.setVisible(false);
        datasetSelectionPanel.add(useLocalCopyButton);
        datasetSelectionPanel.add(downloadOnlineButton);

        useLocalCopyButton.addActionListener(this);
        downloadOnlineButton.addActionListener(this);

    }
    functionCombo.addActionListener(this);
    loadDatasetButton = new JButton("Load local dataset");
    datasetSelectionPanel.add(loadDatasetButton);
    loadDatasetButton.addActionListener(this);
}

From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java

private void initDisplayStatsPanel() {
    displayStatsPanel = new JPanel();
    displayStatsPanel.setPreferredSize(new Dimension(DISPLAY_STATS_PANEL_WIDTH, DISPLAY_STATS_PANEL_HEIGHT));
    displayStatsPanel.setBorder(/*from w w  w .  j av a  2s  .  co  m*/
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(DISPLAY_STATS_PANEL_TITLE),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    stats = new JLabel();
    downloadDatasetProgressPanel = new JPanel();
    downloadDatasetProgressPanel
            .setPreferredSize(new Dimension(DOWNLOAD_PROGRESS_PANEL_WIDTH, DOWNLOAD_PROGRESS_PANEL_HEIGHT));
    downloadDatasetProgressPanel.add(downloadDatasetProgressBar);
    displayStatsPanel.add(downloadDatasetProgressPanel);
    displayStatsPanel.add(stats);
    displayStatsPanel.add(selectIndividualsPanel);
    displayStatsPanel.add(selectTimespanPanel);
    hidePanel(displayStatsPanel);
}

From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java

private void initMiningFunctionsSelectionPanel() {
    miningFunctionSelectionPanel = new JPanel();
    miningFunctionSelectionPanel.setPreferredSize(
            new Dimension(MINING_FUNC_SELECTION_PANEL_WIDTH, MINING_FUNC_SELECTION_PANEL_HEIGHT));
    miningFunctionSelectionPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Mining Function"), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    miningFunctionSelectionPanel.add(functionLabel);
    miningFunctionSelectionPanel.add(functionCombo);
    miningFunctionSelectionPanel.add(miningFucntionHelpButton);
    miningFucntionHelpButton.addActionListener(new ActionListener() {
        @Override//from   w ww. jav  a 2 s.c  o  m
        public void actionPerformed(ActionEvent e) {
            try {
                String workingDir = System.getProperty("user.dir").replace("\\", "/");

                Desktop.getDesktop().browse(new URI("file://" + workingDir + "/index.html#functions"));
            } catch (URISyntaxException ex) {
                Logger.getLogger(ParametersSelectionFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(ParametersSelectionFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    hidePanel(miningFunctionSelectionPanel);
}

From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java

private void initMiningFunctionParametersSelectionPanel() {
    miningFunctionParamsSelectionPanel = new JPanel();
    sigLevelParamsPanel = new JPanel();
    plotMapParamsPanel = new JPanel();

    plotDensityMapPanel = new JPanel();
    plotDensityMapPanel//  w ww .j a v  a  2 s  . c om
            .setPreferredSize(new Dimension(PLOT_MAP_PARAMS_PANEL_WIDTH, PLOT_MAP_PARAMS_PANEL_HEIGHT));
    /*Fei*/
    followingParamsPanel = new JPanel();
    followingParamsPanel
            .setPreferredSize(new Dimension(FOLLOWING_PARAMS_PANEL_WIDTH, FOLLOWING_PARAMS_PANEL_HEIGHT));
    /**/
    miningFunctionParamsSelectionPanel.setPreferredSize(
            new Dimension(MINING_FUNC_PARAMS_SELECTION_PANEL_WIDTH, MINING_FUNC_PARAMS_SELECTION_PANEL_HEIGHT));
    sigLevelParamsPanel
            .setPreferredSize(new Dimension(SIG_LEVEL_PARAMS_PANEL_WIDTH, SIG_LEVEL_PARAMS_PANEL_HEIGHT));
    plotMapParamsPanel
            .setPreferredSize(new Dimension(PLOT_MAP_PARAMS_PANEL_WIDTH, PLOT_MAP_PARAMS_PANEL_HEIGHT));
    miningFunctionParamsSelectionPanel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Mining Function Parameters"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // add sigLevel params comps to its panel
    sigLevelParamsPanel.add(numRoundLabel);
    sigLevelParamsPanel.add(numRoundCombo);
    sigLevelParamsPanel.add(distThresLabel);
    distThresTextedField.setText(Double.toString(DEFAULT_DIST_THRES_ATT));
    sigLevelParamsPanel.add(distThresTextedField);
    sigLevelParamsPanel.add(miningFucntionParamsHelpButton);
    sigLevelParamsPanel.setVisible(false);

    // add plot map params comps to its panel
    plotMapParamsPanel.add(saveKmlButton);
    plotMapParamsPanel.setVisible(false);
    /*Fei*/
    // add following params comps to its panel
    followingParamsPanel.add(this.lMaxThresLabel);
    followingParamsPanel.add(this.lMaxLabelTextedField);

    this.dMaxLabelTextedField.setText(Double.toString(DEFAULT_DIST_THRES));
    this.lMaxLabelTextedField.setText(Double.toString(DEFAULT_TIME_THRES));
    this.minIntervalLengthField.setText(Double.toString(DEFAULT_MIN_LENGTH));
    followingParamsPanel.add(this.dMaxThresLabel);
    followingParamsPanel.add(this.dMaxLabelTextedField);
    followingParamsPanel.add(this.minIntervalLengthLabel);
    followingParamsPanel.add(this.minIntervalLengthField);
    followingParamsPanel.add(this.miningFunctionParamsHelpButtonFollowing);
    followingParamsPanel.setVisible(false);
    miningFunctionParamsSelectionPanel.add(followingParamsPanel);

    plotDensityMapPanel.add(saveDensityMapButton);
    plotDensityMapPanel.setVisible(false);
    miningFunctionParamsSelectionPanel.add(plotDensityMapPanel);

    this.miningFunctionParamsHelpButtonFollowing.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                String workingDir = System.getProperty("user.dir").replace("\\", "/");

                Desktop.getDesktop().browse(new URI("file://" + workingDir + "/index.html#following"));
            } catch (URISyntaxException ex) {
                Logger.getLogger(ParametersSelectionFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(ParametersSelectionFrame.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    });
    /**/

    miningFunctionParamsSelectionPanel.add(sigLevelParamsPanel);
    miningFunctionParamsSelectionPanel.add(plotMapParamsPanel);
    /*   miningFucntionParamsHelpButton.addActionListener(
        new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JFrame helpTextFrame = new JFrame("Mining Function Parameters Help");
                helpTextFrame.setSize(HELP_TEXT_JFRAME_WIDTH, HELP_TEXT_JFRAME_HEIGHT);
                JTextArea text = new JTextArea();
                text.setEditable(false);
                text.setCursor(null);
                text.setOpaque(false);
                text.setFocusable(false);
                text.setLineWrap(true);
                text.setWrapStyleWord(true);
                text.setPreferredSize(
                        new Dimension(HELP_TEXT_JFRAME_WIDTH - 20,
                        HELP_TEXT_JFRAME_HEIGHT - 20));
                text.setText(genMiningFunctionParameterHelpText());
                JPanel panel = new JPanel();
                panel.setPreferredSize(
                        new Dimension(HELP_TEXT_JFRAME_WIDTH,
                        HELP_TEXT_JFRAME_HEIGHT));
                panel.add(text);
                helpTextFrame.add(panel);
                helpTextFrame.setVisible(true);
                panel.setPreferredSize(
                        new Dimension(HELP_TEXT_JFRAME_WIDTH,
                        HELP_TEXT_JFRAME_HEIGHT));
                panel.add(text);
                helpTextFrame.add(panel);
                helpTextFrame.setVisible(true);
            }
        });*/

    miningFucntionParamsHelpButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                //JFrame help = new Browser();
                // help.setLocation(this.getX() + this.getWidth(), this.getY());
                // help.setVisible(true);
                //javafxPanel.setScene(scene);
                String workingDir = System.getProperty("user.dir").replace("\\", "/");

                Desktop.getDesktop().browse(new URI("file://" + workingDir + "/index.html#significance"));
                // long spentTime2 = 1;

                //javafxPanel.setScene(scene);

                //javafxPanel.setVisible(true);
            } catch (IOException ex) {
                Logger.getLogger(ParametersSelectionFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (URISyntaxException ex) {
                Logger.getLogger(ParametersSelectionFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    hidePanel(miningFunctionParamsSelectionPanel);
}

From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java

private void showPanel(JPanel panel, String title) {
    if (panel != null) {
        panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title),
                BorderFactory.createEmptyBorder(5, 5, 5, 5)));
        panel.setVisible(true);/*from ww w . j a v  a  2s . com*/
    }
}

From source file:uk.nhs.cfh.dsp.srth.desktop.modules.resultexplanationpanel.QueryStatisticsCollectionPanel.java

/**
 * Inits the components./*from w  w  w.  j  a  va2s . c o  m*/
 */
public synchronized void initComponents() {

    resultCountLabel = new JXLabel(
            "<html><b>Number of patients satisfying criteria in the query : </b></html>");
    resultCountLabel.setHorizontalTextPosition(SwingConstants.LEFT);
    queryTimeLabel = new JXLabel("<html><b>Time taken to return results for query : </b></html>");
    queryTimeLabel.setHorizontalTextPosition(SwingConstants.LEFT);

    // create panels and add labels
    JPanel countPanel = new JPanel();
    countPanel.setLayout(new BoxLayout(countPanel, BoxLayout.LINE_AXIS));
    countPanel.add(resultCountLabel);
    countPanel.add(Box.createHorizontalGlue());
    JPanel timePanel = new JPanel();
    timePanel.setLayout(new BoxLayout(timePanel, BoxLayout.LINE_AXIS));
    timePanel.add(Box.createHorizontalGlue());
    timePanel.add(queryTimeLabel);
    JPanel labelsPanel = new JPanel();
    labelsPanel.setLayout(new BoxLayout(labelsPanel, BoxLayout.PAGE_AXIS));
    labelsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    labelsPanel.add(countPanel);
    labelsPanel.add(timePanel);
    // add empty panel for spacing
    labelsPanel.add(new JXLabel(" "));

    JPanel humanReadableLabelPanel = new JPanel(new BorderLayout());
    humanReadableLabelPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(),
            BorderFactory.createTitledBorder("Query Text")));
    humanReadableLabel = new JXLabel();
    humanReadableLabel.setLineWrap(true);
    humanReadableLabelPanel.add(humanReadableLabel, BorderLayout.CENTER);

    JPanel upperPanel = new JPanel(new BorderLayout());
    upperPanel.add(humanReadableLabelPanel, BorderLayout.CENTER);
    upperPanel.add(labelsPanel, BorderLayout.SOUTH);

    commentedStepsTextArea = new JTextArea();
    commentedStepsTextArea.setLineWrap(true);
    commentedStepsTextArea.setEditable(false);
    commentedStepsTextArea.setWrapStyleWord(true);
    // create panel for comments text area
    JPanel commentsPanel = createStatementsPanel(commentedStepsTextArea, "SQL Steps");

    sqlStatementsTextArea = new JTextArea();
    sqlStatementsTextArea.setLineWrap(true);
    sqlStatementsTextArea.setEditable(false);
    sqlStatementsTextArea.setWrapStyleWord(true);
    // create panel for sql statements
    JPanel sqlPanel = createStatementsPanel(sqlStatementsTextArea, "SQL Statements");

    // create a tabbed pane to contain the statements panels
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.addTab("Steps", null, commentsPanel, "Commented steps executed in generating the result");
    tabbedPane.addTab("SQL", null, sqlPanel, "SQL Statements used in generating the result");

    // add components to this panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder());
    setPreferredSize(new Dimension(550, 450));
    add(upperPanel, BorderLayout.NORTH);
    add(tabbedPane, BorderLayout.CENTER);
}

From source file:uk.nhs.cfh.dsp.srth.desktop.modules.resultexplanationpanel.QueryStatisticsCollectionPanel.java

/**
 * Creates the statements panel./*from  www. ja  v a  2s . c o  m*/
 * 
 * @param textArea the text area
 * @param title the title
 * 
 * @return the j panel
 */
private synchronized JPanel createStatementsPanel(final JTextArea textArea, String title) {

    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(),
            BorderFactory.createTitledBorder(title)));

    // create buttons for copy and export
    JButton copyButton = new JButton(new AbstractAction("Copy") {

        public void actionPerformed(ActionEvent event) {
            StringSelection selection = new StringSelection(textArea.getSelectedText());
            // get contents of text area and copy to system clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            clipboard.setContents(selection, QueryStatisticsCollectionPanel.this);
        }
    });

    JButton exportButton = new JButton(new AbstractAction("Export") {

        public void actionPerformed(ActionEvent event) {
            // open a file dialog and export the contents
            FileDialog fd = new FileDialog(applicationService.getFrameView().getActiveFrame(),
                    "Select file to export to", FileDialog.SAVE);
            fd.setVisible(true);

            String fileName = fd.getFile();
            String fileDirectory = fd.getDirectory();

            if (fileDirectory != null && fileName != null) {
                File file = new File(fileDirectory, fileName);
                try {
                    String contents = textArea.getText();
                    FileWriter fw = new FileWriter(file);
                    fw.flush();
                    fw.write(contents);
                    fw.close();
                    // inform user
                    //                  manager.getStatusMessageLabel().setText("Successfully saved contents to file "+fileName);
                    logger.info("Successfully saved contents to file " + fileName);

                } catch (IOException e) {
                    logger.warn(e.fillInStackTrace());
                    //                  manager.getStatusMessageLabel().setText("Errors saving contents to file "+fileName);
                }
            }
        }
    });
    // create buttons panel
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS));
    buttonsPanel.add(Box.createHorizontalStrut(200));
    buttonsPanel.add(copyButton);
    buttonsPanel.add(exportButton);

    panel.add(buttonsPanel, BorderLayout.SOUTH);
    panel.add(new JScrollPane(textArea), BorderLayout.CENTER);

    return panel;
}