Example usage for javax.swing JTabbedPane addTab

List of usage examples for javax.swing JTabbedPane addTab

Introduction

In this page you can find the example usage for javax.swing JTabbedPane addTab.

Prototype

public void addTab(String title, Component component) 

Source Link

Document

Adds a component represented by a title and no icon.

Usage

From source file:brainflow.app.toplevel.BrainFlow.java

private void initControlPanel() {

    //JideTabbedPane tabbedPane = new JideTabbedPane();
    JTabbedPane tabbedPane = new JTabbedPane();

    DockableFrame dframe = DockWindowManager.getInstance().createDockableFrame("Tool Box", "icons/types.gif",
            DockContext.STATE_FRAMEDOCKED, DockContext.DOCK_SIDE_EAST);

    ColorAdjustmentControl colorAdjustmentControl = new ColorAdjustmentControl();

    LayerInfoControl layerInfoControl = new LayerInfoControl();

    MaskControl maskControl = new MaskControl();

    tabbedPane.addTab("Adjust", new JScrollPane(colorAdjustmentControl.getComponent()));
    tabbedPane.addTab("Mask", maskControl.getComponent());
    tabbedPane.addTab("Info", new JScrollPane(layerInfoControl.getComponent()));
    tabbedPane.addTab("Clustering", new ClusterPresenter().getComponent());

    dframe.getContentPane().add(tabbedPane);

    dframe.setPreferredSize(new Dimension(300, 500));
    brainFrame.getDockingManager().addFrame(dframe);

}

From source file:org.biojava.bio.view.MotifAnalyzer.java

public void displayCharts(String fileName) throws IOException {
    JFrame chartsFrame = new JFrame("Charts Analysis");
    chartsFrame.setSize(700, 600);//from   ww  w. j a  va2s  . c  om
    JTabbedPane tabs = new JTabbedPane();
    chartsFrame.add(tabs);

    JPanel image1 = new JPanel(new BorderLayout());
    image1.add(new JLabel(new ImageIcon(ImageIO.read(new File(fileName)))));
    image1.setBackground(Color.white);
    tabs.addTab("Chart ", image1);

    chartsFrame.setVisible(true);

}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Creates a tab pane for the given GridJob.
 * //from   ww  w.  java 2  s.c om
 * @param jobId JobId
 */
protected void createJobTab(final String jobId) {

    // Request Job Profile
    final InternalClusterJobService jobService = ClusterManager.getInstance().getJobService();
    final GridJobProfile profile = jobService.getProfile(jobId);

    // Job Start Time
    final long startTime = System.currentTimeMillis();

    final JPanel jobPanel = new JPanel();
    jobPanel.setLayout(new BorderLayout(10, 10));

    // Progess Panel
    JPanel progressPanel = new JPanel();
    progressPanel.setLayout(new BorderLayout(10, 10));
    progressPanel.setBorder(BorderFactory.createTitledBorder("Progress"));
    jobPanel.add(progressPanel, BorderLayout.NORTH);

    final JProgressBar progressBar = new JProgressBar();
    progressBar.setStringPainted(true);
    progressPanel.add(progressBar, BorderLayout.CENTER);
    addUIElement("jobs." + jobId + ".progress", progressBar); // Add to components map

    // Buttons Panel
    JPanel buttonsPanel = new JPanel();
    jobPanel.add(buttonsPanel, BorderLayout.SOUTH);
    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    // Terminate Button
    JButton terminateButton = new JButton("Terminate");
    terminateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new Thread(new Runnable() {

                public void run() {

                    // Job Name = Class Name
                    String name = profile.getJob().getClass().getSimpleName();

                    // Request user confirmation
                    int option = JOptionPane.showConfirmDialog(ClusterMainUI.this,
                            "Are you sure to terminate GridJob " + name + "?", "Nebula - Terminate GridJob",
                            JOptionPane.YES_NO_OPTION);

                    if (option == JOptionPane.NO_OPTION)
                        return;

                    // Attempt Cancel
                    boolean result = profile.getFuture().cancel();

                    // Notify results
                    if (result) {
                        JOptionPane.showMessageDialog(ClusterMainUI.this,
                                "Grid Job '" + name + "terminated successfully.", "Nebula - Job Terminated",
                                JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(ClusterMainUI.this,
                                "Failed to terminate Grid Job '" + name, "Nebula - Job Termination Failed",
                                JOptionPane.WARNING_MESSAGE);
                    }
                }

            }).start();
        }
    });
    buttonsPanel.add(terminateButton);
    addUIElement("jobs." + jobId + ".terminate", terminateButton); // Add to components map

    // Close Tab Button
    JButton closeButton = new JButton("Close Tab");
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    removeJobTab(jobId);
                }
            });
        }
    });
    closeButton.setEnabled(false);

    buttonsPanel.add(closeButton);
    addUIElement("jobs." + jobId + ".closetab", closeButton); // Add to components map

    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new GridBagLayout());
    jobPanel.add(centerPanel, BorderLayout.CENTER);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weightx = 1.0;

    /* -- Job Information -- */

    JPanel jobInfoPanel = new JPanel();
    jobInfoPanel.setBorder(BorderFactory.createTitledBorder("Job Information"));
    jobInfoPanel.setLayout(new GridBagLayout());
    c.gridy = 0;
    c.ipady = 30;
    centerPanel.add(jobInfoPanel, c);

    GridBagConstraints c1 = new GridBagConstraints();
    c1.fill = GridBagConstraints.BOTH;
    c1.weightx = 1;
    c1.weighty = 1;

    // Name
    jobInfoPanel.add(new JLabel("Name :"), c1);
    JLabel jobNameLabel = new JLabel();
    jobInfoPanel.add(jobNameLabel, c1);
    jobNameLabel.setText(profile.getJob().getClass().getSimpleName());
    addUIElement("jobs." + jobId + ".job.name", jobNameLabel); // Add to components map

    // Gap
    jobInfoPanel.add(new JLabel(), c1);

    // Type
    jobInfoPanel.add(new JLabel("Type :"), c1);
    JLabel jobType = new JLabel();
    jobType.setText(getJobType(profile.getJob()));
    jobInfoPanel.add(jobType, c1);
    addUIElement("jobs." + jobId + ".job.type", jobType); // Add to components map

    // Job Class Name
    c1.gridy = 1;
    c1.gridwidth = 1;
    jobInfoPanel.add(new JLabel("GridJob Class :"), c1);
    c1.gridwidth = GridBagConstraints.REMAINDER;
    JLabel jobClassLabel = new JLabel();
    jobClassLabel.setText(profile.getJob().getClass().getName());
    jobInfoPanel.add(jobClassLabel, c1);
    addUIElement("jobs." + jobId + ".job.class", jobClassLabel); // Add to components map

    /* -- Execution Information -- */

    JPanel executionInfoPanel = new JPanel();
    executionInfoPanel.setBorder(BorderFactory.createTitledBorder("Execution Statistics"));
    executionInfoPanel.setLayout(new GridBagLayout());
    c.gridy = 1;
    c.ipady = 30;
    centerPanel.add(executionInfoPanel, c);

    GridBagConstraints c3 = new GridBagConstraints();
    c3.weightx = 1;
    c3.weighty = 1;
    c3.fill = GridBagConstraints.BOTH;

    // Start Time
    executionInfoPanel.add(new JLabel("Job Status :"), c3);
    final JLabel statusLabel = new JLabel("Initializing");
    executionInfoPanel.add(statusLabel, c3);
    addUIElement("jobs." + jobId + ".execution.status", statusLabel); // Add to components map

    // Status Update Listener
    profile.getFuture().addGridJobStateListener(new GridJobStateListener() {
        public void stateChanged(final GridJobState newState) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    statusLabel.setText(StringUtils.capitalize(newState.toString().toLowerCase()));
                }
            });
        }
    });

    executionInfoPanel.add(new JLabel(), c3); // Space Holder

    // Percent Complete
    executionInfoPanel.add(new JLabel("Completed % :"), c3);
    final JLabel percentLabel = new JLabel("-N/A-");
    executionInfoPanel.add(percentLabel, c3);
    addUIElement("jobs." + jobId + ".execution.percentage", percentLabel); // Add to components map

    c3.gridy = 1;

    // Start Time
    executionInfoPanel.add(new JLabel("Start Time :"), c3);
    JLabel startTimeLabel = new JLabel(DateFormat.getInstance().format(new Date(startTime)));
    executionInfoPanel.add(startTimeLabel, c3);
    addUIElement("jobs." + jobId + ".execution.starttime", startTimeLabel); // Add to components map

    executionInfoPanel.add(new JLabel(), c3); // Space Holder

    // Elapsed Time
    executionInfoPanel.add(new JLabel("Elapsed Time :"), c3);
    JLabel elapsedTimeLabel = new JLabel("-N/A-");
    executionInfoPanel.add(elapsedTimeLabel, c3);
    addUIElement("jobs." + jobId + ".execution.elapsedtime", elapsedTimeLabel); // Add to components map

    c3.gridy = 2;

    // Tasks Deployed (Count)
    executionInfoPanel.add(new JLabel("Tasks Deployed :"), c3);
    JLabel tasksDeployedLabel = new JLabel("-N/A-");
    executionInfoPanel.add(tasksDeployedLabel, c3);
    addUIElement("jobs." + jobId + ".execution.tasks", tasksDeployedLabel); // Add to components map

    executionInfoPanel.add(new JLabel(), c3); // Space Holder

    // Results Collected (Count)
    executionInfoPanel.add(new JLabel("Results Collected :"), c3);
    JLabel resultsCollectedLabel = new JLabel("-N/A-");
    executionInfoPanel.add(resultsCollectedLabel, c3);
    addUIElement("jobs." + jobId + ".execution.results", resultsCollectedLabel); // Add to components map

    c3.gridy = 3;

    // Remaining Tasks (Count)
    executionInfoPanel.add(new JLabel("Remaining Tasks :"), c3);
    JLabel remainingTasksLabel = new JLabel("-N/A-");
    executionInfoPanel.add(remainingTasksLabel, c3);
    addUIElement("jobs." + jobId + ".execution.remaining", remainingTasksLabel); // Add to components map

    executionInfoPanel.add(new JLabel(), c3); // Space Holder

    // Failed Tasks (Count)
    executionInfoPanel.add(new JLabel("Failed Tasks :"), c3);
    JLabel failedTasksLabel = new JLabel("-N/A-");
    executionInfoPanel.add(failedTasksLabel, c3);
    addUIElement("jobs." + jobId + ".execution.failed", failedTasksLabel); // Add to components map

    /* -- Submitter Information -- */
    UUID ownerId = profile.getOwner();
    GridNodeDelegate owner = ClusterManager.getInstance().getClusterRegistrationService()
            .getGridNodeDelegate(ownerId);

    JPanel ownerInfoPanel = new JPanel();
    ownerInfoPanel.setBorder(BorderFactory.createTitledBorder("Owner Information"));
    ownerInfoPanel.setLayout(new GridBagLayout());
    c.gridy = 2;
    c.ipady = 10;
    centerPanel.add(ownerInfoPanel, c);

    GridBagConstraints c2 = new GridBagConstraints();

    c2.fill = GridBagConstraints.BOTH;
    c2.weightx = 1;
    c2.weighty = 1;

    // Host Name
    ownerInfoPanel.add(new JLabel("Host Name :"), c2);
    JLabel hostNameLabel = new JLabel(owner.getProfile().getName());
    ownerInfoPanel.add(hostNameLabel, c2);
    addUIElement("jobs." + jobId + ".owner.hostname", hostNameLabel); // Add to components map

    // Gap
    ownerInfoPanel.add(new JLabel(), c2);

    // Host IP Address
    ownerInfoPanel.add(new JLabel("Host IP :"), c2);
    JLabel hostIPLabel = new JLabel(owner.getProfile().getIpAddress());
    ownerInfoPanel.add(hostIPLabel, c2);
    addUIElement("jobs." + jobId + ".owner.hostip", hostIPLabel); // Add to components map

    // Owner UUID
    c2.gridy = 1;
    c2.gridx = 0;
    ownerInfoPanel.add(new JLabel("Owner ID :"), c2);
    JLabel ownerIdLabel = new JLabel(profile.getOwner().toString());
    c2.gridx = 1;
    c2.gridwidth = 4;
    ownerInfoPanel.add(ownerIdLabel, c2);
    addUIElement("jobs." + jobId + ".owner.id", ownerIdLabel); // Add to components map

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            // Create Tab
            addUIElement("jobs." + jobId, jobPanel);
            JTabbedPane tabs = getUIElement("tabs");
            tabs.addTab(profile.getJob().getClass().getSimpleName(), jobPanel);
            tabs.revalidate();
        }
    });

    // Execution Information Updater Thread
    new Thread(new Runnable() {

        boolean initialized = false;
        boolean unbounded = false;

        public void run() {

            // Unbounded, No Progress Supported
            if ((!initialized) && profile.getJob() instanceof UnboundedGridJob<?>) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        progressBar.setIndeterminate(true);
                        progressBar.setStringPainted(false);

                        // Infinity Symbol
                        percentLabel.setText(String.valueOf('\u221e'));

                    }
                });
                initialized = true;
                unbounded = true;
            }

            // Update Job Info
            while (true) {

                try {
                    // 500ms Interval
                    Thread.sleep(500);

                } catch (InterruptedException e) {
                    log.warn("Interrupted Progress Updater Thread", e);
                }

                final int totalCount = profile.getTotalTasks();
                final int tasksRem = profile.getTaskCount();
                final int resCount = profile.getResultCount();
                final int failCount = profile.getFailedCount();

                showBusyIcon();

                // Task Information
                JLabel totalTaskLabel = getUIElement("jobs." + jobId + ".execution.tasks");
                totalTaskLabel.setText(String.valueOf(totalCount));

                // Result Count
                JLabel resCountLabel = getUIElement("jobs." + jobId + ".execution.results");
                resCountLabel.setText(String.valueOf(resCount));

                // Remaining Task Count
                JLabel remLabel = getUIElement("jobs." + jobId + ".execution.remaining");
                remLabel.setText(String.valueOf(tasksRem));

                // Failed Task Count
                JLabel failedLabel = getUIElement("jobs." + jobId + ".execution.failed");
                failedLabel.setText(String.valueOf(failCount));

                // Elapsed Time
                JLabel elapsedLabel = getUIElement("jobs." + jobId + ".execution.elapsedtime");
                elapsedLabel.setText(TimeUtils.timeDifference(startTime));

                // Job State
                final JLabel statusLabel = getUIElement("jobs." + jobId + ".execution.status");

                // If not in Executing Mode
                if ((!profile.getFuture().isJobFinished())
                        && profile.getFuture().getState() != GridJobState.EXECUTING) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {

                            // Progress Bar
                            progressBar.setIndeterminate(true);
                            progressBar.setStringPainted(false);

                            // Status Text
                            String state = profile.getFuture().getState().toString();
                            statusLabel.setText(StringUtils.capitalize(state.toLowerCase()));

                            // Percentage Label
                            percentLabel.setText(String.valueOf('\u221e'));
                        }
                    });
                } else { // Executing Mode : Progress Information

                    // Job Finished, Stop
                    if (profile.getFuture().isJobFinished()) {
                        showIdleIcon();
                        return;
                    }

                    // Double check for status label
                    if (!statusLabel.getText().equalsIgnoreCase("executing")) {
                        SwingUtilities.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                String newstate = profile.getFuture().getState().toString();
                                statusLabel.setText(StringUtils.capitalize(newstate.toLowerCase()));
                            }

                        });
                    }

                    if (!unbounded) {

                        final int percentage = (int) (profile.percentage() * 100);

                        //final int failCount = profile.get
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {

                                // If finished at this point, do not update
                                if (progressBar.getValue() == 100) {
                                    return;
                                }

                                // If ProgressBar is in indeterminate
                                if (progressBar.isIndeterminate()) {
                                    progressBar.setIndeterminate(false);
                                    progressBar.setStringPainted(true);
                                }

                                // Update Progress Bar / Percent Label
                                progressBar.setValue(percentage);
                                percentLabel.setText(percentage + " %");

                            }
                        });
                    }
                }

            }
        }
    }).start();

    // Job End Hook to Execute Job End Actions
    ServiceEventsSupport.addServiceHook(new ServiceHookCallback() {

        public void onServiceEvent(final ServiceMessage event) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {

                    JButton close = getUIElement("jobs." + jobId + ".closetab");
                    JButton terminate = getUIElement("jobs." + jobId + ".terminate");
                    terminate.setEnabled(false);
                    close.setEnabled(true);

                    JProgressBar progress = getUIElement("jobs." + jobId + ".progress");
                    JLabel percentage = getUIElement("jobs." + jobId + ".execution.percentage");

                    progress.setEnabled(false);

                    // If Successfully Finished
                    if (event.getType() == ServiceMessageType.JOB_END) {

                        if (profile.getFuture().getState() != GridJobState.FAILED) {
                            // If Not Job Failed
                            progress.setValue(100);
                            percentage.setText("100 %");
                        } else {
                            // If Failed
                            percentage.setText("N/A");
                        }

                        // Stop (if) Indeterminate Progress Bar
                        if (progress.isIndeterminate()) {
                            progress.setIndeterminate(false);
                            progress.setStringPainted(true);
                        }
                    } else if (event.getType() == ServiceMessageType.JOB_CANCEL) {

                        if (progress.isIndeterminate()) {
                            progress.setIndeterminate(false);
                            progress.setStringPainted(false);
                            percentage.setText("N/A");
                        }
                    }

                    showIdleIcon();
                }
            });
        }

    }, jobId, ServiceMessageType.JOB_CANCEL, ServiceMessageType.JOB_END);
}

From source file:gui.LauncherFrame.java

/**
 * creates a text pane containing text and adds it to a tabbed frame
 * //from   w  ww  .  j  ava 2  s  .c  o  m
 * @param tabbedPane - the tabbed frame to add the text panel to
 * @param tabName  - title of the text panel tab
 * @param filename - name of file containing the text to add to the text panel
 */
private void addTextTab(javax.swing.JTabbedPane tabbedPane, String tabName, String filename) {

    File textfile = new File(filename);
    if (!textfile.isFile()) {
        debug.print(DebugMessage.StatusType.Error, "File is not valid: " + filename);
        return;
    }
    if (tabName == null || tabName.isEmpty()) {
        debug.print(DebugMessage.StatusType.Error, "Invalid name for tab: " + tabName);
        return;
    }

    BufferedReader in = null;
    try {
        // create a text area and place it in a scrollable panel
        javax.swing.JTextArea fileText = new javax.swing.JTextArea(0, 0);
        fileText.setLineWrap(true);
        fileText.setWrapStyleWord(true);
        javax.swing.JScrollPane fileScroll = new javax.swing.JScrollPane(fileText);

        // place the scroll pane in the tabbed pane
        tabbedPane.addTab(tabName, fileScroll);

        // now read the file contents into the text area
        in = new BufferedReader(new FileReader(textfile));
        String line = in.readLine();
        while (line != null) {
            fileText.append(line + "\n");
            line = in.readLine();
        }
        fileText.setCaretPosition(0); // set position to start of file
    } catch (FileNotFoundException ex) {
        debug.print(DebugMessage.StatusType.Error, ex + "<FILE_NOT_FOUND> - accessing " + tabName + " file");
    } catch (IOException ex) {
        debug.print(DebugMessage.StatusType.Error, ex + "<IO_EXCEPTION>");
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException ex) {
                debug.print(DebugMessage.StatusType.Error, ex + "<IO_EXCEPTION>");
            }
        }
    }
}

From source file:AppearanceExplorer.java

JPanel guiPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Setup", setupPanel());
    tabbedPane.addTab("ColoringAttributes", coloringAttrEditor);
    tabbedPane.addTab("PointAttributes", pointAttrEditor);
    tabbedPane.addTab("LineAttributes", lineAttrEditor);
    tabbedPane.addTab("PolygonAttributes", polygonAttrEditor);
    tabbedPane.addTab("RenderingAttributes", renderAttrEditor);
    tabbedPane.addTab("TransparencyAttributes", transpAttrEditor);
    tabbedPane.addTab("Material", materialEditor);
    tabbedPane.addTab("Texture2D", texture2DEditor);
    tabbedPane.addTab("TextureAttributes", textureAttrEditor);
    tabbedPane.addTab("TexCoordGeneration", texGenEditor);
    panel.add("Center", tabbedPane);

    return panel;
}

From source file:userinterface.graph.GraphOptionsPanel.java

/** This method is called from within the constructor to
 * initialize the form.// ww w  .ja va 2 s  .  c  om
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
//javax.swing.JPanel jPanel6;
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;
    javax.swing.JTabbedPane tabbedPanel;

    tabbedPanel = new javax.swing.JTabbedPane();
    graphOptionsPanel = new javax.swing.JPanel();
    innerGraphOptionsPanel = new javax.swing.JPanel();
    axisOptionsPanel = new javax.swing.JPanel();
    innerAxesOptionsPanel = new javax.swing.JPanel();
    axesOptionPanelSplitPane = new javax.swing.JSplitPane();
    axesTopPanel = new javax.swing.JPanel();
    axesInnerTopPanel = new javax.swing.JPanel();
    axesLabel = new javax.swing.JLabel();
    axesListPanel = new javax.swing.JPanel();
    axesInnerListPanel = new javax.swing.JPanel();
    axesListScrollPane = new javax.swing.JScrollPane();
    axesBottomPanel = new javax.swing.JPanel();
    seriesOptionsPanel = new javax.swing.JPanel();
    seriesOptionPanelSplitPane = new javax.swing.JSplitPane();
    seriesTopPanel = new javax.swing.JPanel();
    seriesInnerTopPanel = new javax.swing.JPanel();
    seriesLabel = new javax.swing.JLabel();
    seriesListPanel = new javax.swing.JPanel();
    seriesInnerListPanel = new javax.swing.JPanel();
    seriesListScrollPane = new javax.swing.JScrollPane();
    seriesButtonPanel = new javax.swing.JPanel();
    addSeries = new javax.swing.JButton();
    removeSeries = new javax.swing.JButton();
    moveUp = new javax.swing.JButton();
    moveDown = new javax.swing.JButton();
    viewData = new javax.swing.JButton();
    seriesBottomPanel = new javax.swing.JPanel();
    displayOptionsPanel = new javax.swing.JPanel();
    innerDisplayOptionsPanel = new javax.swing.JPanel();

    setLayout(new java.awt.BorderLayout());

    tabbedPanel.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            tabbedPanelStateChanged(evt);
        }
    });

    graphOptionsPanel.setLayout(new java.awt.BorderLayout());

    graphOptionsPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    innerGraphOptionsPanel.setLayout(new java.awt.BorderLayout());

    innerGraphOptionsPanel.add(graphPropertiesTable, java.awt.BorderLayout.CENTER);
    graphOptionsPanel.add(innerGraphOptionsPanel, java.awt.BorderLayout.CENTER);

    tabbedPanel.addTab("Graph", graphOptionsPanel);

    axisOptionsPanel.setLayout(new java.awt.BorderLayout());

    axisOptionsPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    innerAxesOptionsPanel.setLayout(new java.awt.BorderLayout());

    axesOptionPanelSplitPane.setDividerLocation(80);
    axesOptionPanelSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    axesTopPanel.setLayout(new java.awt.BorderLayout());

    axesTopPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    axesInnerTopPanel.setLayout(new java.awt.BorderLayout());

    axesLabel.setText("Select Axis:");
    axesInnerTopPanel.add(axesLabel, java.awt.BorderLayout.NORTH);

    axesListPanel.setLayout(new java.awt.GridBagLayout());

    axesInnerListPanel.setLayout(new java.awt.BorderLayout());

    axesListScrollPane.setMaximumSize(new java.awt.Dimension(32767, 120));
    axesListScrollPane.setMinimumSize(new java.awt.Dimension(20, 22));
    axesListScrollPane.setPreferredSize(new java.awt.Dimension(3, 120));
    axesListScrollPane.setViewportView(axesList);
    axesInnerListPanel.add(axesListScrollPane, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.75;
    gridBagConstraints.weighty = 1.0;
    axesListPanel.add(axesInnerListPanel, gridBagConstraints);

    axesInnerTopPanel.add(axesListPanel, java.awt.BorderLayout.CENTER);

    axesTopPanel.add(axesInnerTopPanel, java.awt.BorderLayout.CENTER);

    axesOptionPanelSplitPane.setLeftComponent(axesTopPanel);

    axesBottomPanel.setLayout(new java.awt.BorderLayout());

    axesBottomPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    axesBottomPanel.add(axisPropertiesTable, BorderLayout.CENTER);

    axesOptionPanelSplitPane.setRightComponent(axesBottomPanel);

    innerAxesOptionsPanel.add(axesOptionPanelSplitPane, java.awt.BorderLayout.CENTER);

    axisOptionsPanel.add(innerAxesOptionsPanel, java.awt.BorderLayout.CENTER);

    tabbedPanel.addTab("Axes", axisOptionsPanel);

    seriesOptionsPanel.setLayout(new java.awt.BorderLayout());

    seriesOptionsPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    seriesOptionPanelSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    seriesTopPanel.setLayout(new java.awt.BorderLayout());

    seriesTopPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    seriesInnerTopPanel.setLayout(new java.awt.BorderLayout());

    seriesLabel.setText("Select Series:");
    seriesInnerTopPanel.add(seriesLabel, java.awt.BorderLayout.NORTH);

    seriesListPanel.setLayout(new java.awt.GridBagLayout());

    seriesInnerListPanel.setLayout(new java.awt.BorderLayout());

    seriesListScrollPane.setMaximumSize(new java.awt.Dimension(32767, 120));
    seriesListScrollPane.setMinimumSize(new java.awt.Dimension(20, 22));
    seriesListScrollPane.setPreferredSize(new java.awt.Dimension(3, 120));
    seriesListScrollPane.setViewportView(seriesList);

    seriesInnerListPanel.add(seriesListScrollPane, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.75;
    gridBagConstraints.weighty = 1.0;
    seriesListPanel.add(seriesInnerListPanel, gridBagConstraints);

    seriesButtonPanel.setLayout(new java.awt.GridLayout(5, 1, 5, 5));

    seriesButtonPanel.setMaximumSize(new java.awt.Dimension(2147483647, 105));
    addSeries.setText("Add");
    addSeries.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    addSeries.setMinimumSize(new java.awt.Dimension(5, 25));
    addSeries.setPreferredSize(new java.awt.Dimension(5, 25));
    addSeries.setIcon(GUIPrism.getIconFromImage("smallAdd.png"));
    addSeries.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            addSeriesActionPerformed(evt);
        }
    });

    seriesButtonPanel.add(addSeries);

    removeSeries.setText("Remove");
    removeSeries.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    removeSeries.setMinimumSize(new java.awt.Dimension(5, 25));
    removeSeries.setPreferredSize(new java.awt.Dimension(5, 25));
    removeSeries.setIcon(GUIPrism.getIconFromImage("smallRemove.png"));
    removeSeries.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            removeSeriesActionPerformed(evt);
        }
    });

    seriesButtonPanel.add(removeSeries);

    moveUp.setText("Move Up");
    moveUp.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    moveUp.setMinimumSize(new java.awt.Dimension(5, 25));
    moveUp.setPreferredSize(new java.awt.Dimension(5, 25));
    moveUp.setIcon(GUIPrism.getIconFromImage("smallArrowUp.png"));
    moveUp.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            moveUpActionPerformed(evt);
        }
    });

    seriesButtonPanel.add(moveUp);

    moveDown.setText("Move Down");
    moveDown.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    moveDown.setMinimumSize(new java.awt.Dimension(5, 25));
    moveDown.setPreferredSize(new java.awt.Dimension(5, 25));
    moveDown.setIcon(GUIPrism.getIconFromImage("smallArrowDown.png"));
    moveDown.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            moveDownActionPerformed(evt);
        }
    });

    seriesButtonPanel.add(moveDown);

    if (theModel instanceof Graph)
        viewData.setText("Edit Data");
    else if (theModel instanceof Histogram || theModel instanceof Graph3D)
        viewData.setText("View Data");

    viewData.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    viewData.setIcon(GUIPrism.getIconFromImage("smallEditData.png"));
    viewData.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            viewDataActionPerformed(evt);
        }
    });

    seriesButtonPanel.add(viewData);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
    gridBagConstraints.weightx = 0.25;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
    seriesListPanel.add(seriesButtonPanel, gridBagConstraints);

    seriesInnerTopPanel.add(seriesListPanel, java.awt.BorderLayout.CENTER);

    seriesTopPanel.add(seriesInnerTopPanel, java.awt.BorderLayout.CENTER);

    seriesOptionPanelSplitPane.setLeftComponent(seriesTopPanel);

    seriesBottomPanel.setLayout(new java.awt.BorderLayout());

    seriesBottomPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    seriesBottomPanel.add(seriesPropertiesTable, BorderLayout.CENTER);
    seriesOptionPanelSplitPane.setRightComponent(seriesBottomPanel);

    seriesOptionsPanel.add(seriesOptionPanelSplitPane, java.awt.BorderLayout.CENTER);

    tabbedPanel.addTab("Series", seriesOptionsPanel);

    displayOptionsPanel.setLayout(new java.awt.BorderLayout());

    displayOptionsPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    innerDisplayOptionsPanel.setLayout(new java.awt.BorderLayout());

    innerDisplayOptionsPanel.add(displayPropertiesTable, java.awt.BorderLayout.CENTER);

    displayOptionsPanel.add(innerDisplayOptionsPanel, java.awt.BorderLayout.CENTER);

    tabbedPanel.addTab("Display", displayOptionsPanel);

    add(tabbedPanel, java.awt.BorderLayout.CENTER);

}

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_//from   w w  w.  jav  a2  s  . com
 *
 *
 * @throws RemoteException _more_
 * @throws VisADException _more_
 */
private void makeWidgets() throws VisADException, RemoteException {
    JTabbedPane tabbedPane = new JTabbedPane();

    tabbedPane.addTab("Dashboard", doMakeDashboardPanel());
    tabbedPane.addTab("Values", doMakeValuesPanel());
    tabbedPane.addTab("Description", doMakeDescriptionPanel());
    tabbedPane.addTab("Viewpoint", doMakeViewpointPanel());
    tabbedPane.addTab("Points", doMakePointsPanel());

    JComponent innerContents = GuiUtils.topCenterBottom(animationWidget.getContents(), tabbedPane,
            doMakeNavigationPanel());

    if (!showAnimation) {
        animationWidget.getContents().setVisible(false);
    }
    JComponent menuBar = doMakeMenuBar();
    innerContents = GuiUtils.inset(innerContents, 5);
    contents = GuiUtils.topCenter(menuBar, innerContents);
    animation.setCurrent(currentIndex);
}

From source file:regresiones.RegresionMultiple.java

private void pintar(Double[] Yestimada, JTabbedPane resultados, Double[][] auxiliar) {
    // mostramos resultados para la pestaa resultados***********************************************************************
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(Color.white);
    JLabel titulo = new JLabel("Resultados");//creamos el titulo
    panel.add(titulo, BorderLayout.PAGE_START);//lo agregamos al inicio
    jtable = new JTable();//creamos la tabla a mostrar
    jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
    jtable.setFont(new java.awt.Font("Arial", 1, 14));
    jtable.setColumnSelectionAllowed(true);
    jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
    jtable.setInheritsPopupMenu(true);//w w w  .j  a  v a 2  s.c o m
    jtable.setMinimumSize(new java.awt.Dimension(80, 80));
    String[] titulos = { "X1", "X2", "Y", "Y estimada", "X1^2", "X2^2", "X1*Y", "X2*Y", "Y-Y estimada" };//los titulos de la tabla
    arregloFinal = new String[N][9];
    DecimalFormat formato = new DecimalFormat("0.00");
    for (int i = 0; i < N; i++) {//armamos el arreglo
        arregloFinal[i][0] = datos[i][0] + "";
        arregloFinal[i][1] = datos[i][1] + "";
        arregloFinal[i][2] = datos[i][2] + "";
        arregloFinal[i][3] = formato.format(Yestimada[i]);
        arregloFinal[i][4] = formato.format(auxiliar[i][0]);
        arregloFinal[i][5] = formato.format(auxiliar[i][1]);
        arregloFinal[i][6] = formato.format(auxiliar[i][2]);
        arregloFinal[i][7] = formato.format(auxiliar[i][3]);
        arregloFinal[i][8] = formato.format(auxiliar[i][4]);
    }
    DefaultTableModel TableModel = new DefaultTableModel(arregloFinal, titulos);
    jtable.setModel(TableModel);
    JScrollPane jScrollPane1 = new JScrollPane();
    jScrollPane1.setViewportView(jtable);
    jtable.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    panel.add(jScrollPane1, BorderLayout.CENTER);
    JPanel panel2 = new JPanel(new GridLayout(0, 6));//creo un panel con rejilla de 4 columnas
    JLabel etiquetaN = new JLabel("N");
    JTextField cajaN = new JTextField();
    cajaN.setText(N + "");
    cajaN.setEditable(false);

    JLabel etiquetaK = new JLabel("K");
    JTextField cajaK = new JTextField();
    cajaK.setText("2");
    cajaK.setEditable(false);

    JLabel etiquetab0 = new JLabel("b0");
    JTextField cajab0 = new JTextField();
    cajab0.setText(formato.format(b0) + "");
    cajab0.setEditable(false);

    JLabel etiquetab1 = new JLabel("b1");
    JTextField cajab1 = new JTextField();
    cajab1.setText(formato.format(b1) + "");
    cajab1.setEditable(false);

    JLabel etiquetab2 = new JLabel("b2");
    JTextField cajab2 = new JTextField();
    cajab2.setText(formato.format(b2) + "");
    cajab2.setEditable(false);

    JLabel etiquetaSe = new JLabel("Se");
    JTextField cajaSe = new JTextField();
    cajaSe.setText(Se + "");
    cajaSe.setEditable(false);
    cajaSe.setAutoscrolls(true);

    JButton botonI = new JButton("Exportar a PDF");
    botonI.addActionListener(this);

    panel2.add(etiquetaN);
    panel2.add(cajaN);
    panel2.add(etiquetaK);
    panel2.add(cajaK);
    panel2.add(etiquetab2);
    panel2.add(etiquetab0);
    panel2.add(cajab0);
    panel2.add(etiquetab1);
    panel2.add(cajab1);
    panel2.add(etiquetab2);
    panel2.add(cajab2);
    panel2.add(etiquetaSe);
    panel2.add(cajaSe);
    panel2.add(botonI);
    panel.add(panel2, BorderLayout.SOUTH);//agrego el panel2 con rejilla en el panel principal al sur
    resultados.addTab("resultado", panel);
    //**************************************************************************************
    //intervalos de confianza
    JPanel intervalos = new JPanel(new BorderLayout());
    JPanel variables = new JPanel(new GridLayout(0, 2));
    JLabel variableX1 = new JLabel("X1");
    cajaVariableX1 = new JTextField();
    JLabel variableX2 = new JLabel("X2");
    cajaVariableX2 = new JTextField();
    boton = new JButton("calcular");
    boton.addActionListener(this);
    JLabel variableEfectividad = new JLabel("Efectividad");
    String[] efectividades = { "80", "85", "90", "95", "99" };
    combo = new JComboBox(efectividades);
    variables.add(variableX1);
    variables.add(cajaVariableX1);
    variables.add(variableX2);
    variables.add(cajaVariableX2);
    variables.add(variableEfectividad);
    variables.add(combo);
    variables.add(boton);
    intervalos.add(variables, BorderLayout.NORTH);
    jtable2 = new JTable();//creamos la tabla a mostrar
    jtable2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
    jtable2.setFont(new java.awt.Font("Arial", 1, 14));
    jtable2.setColumnSelectionAllowed(true);
    jtable2.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
    jtable2.setInheritsPopupMenu(true);
    jtable2.setMinimumSize(new java.awt.Dimension(80, 80));
    String[] titulos2 = { "Y estimada", "Li", "Ls" };//los titulos de la tabla
    String[][] pruebaIntervalos = { { "", "", "" } };
    DefaultTableModel TableModel2 = new DefaultTableModel(pruebaIntervalos, titulos2);
    jtable2.setModel(TableModel2);
    JScrollPane jScrollPane2 = new JScrollPane();
    jScrollPane2.setViewportView(jtable2);
    jtable2.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    intervalos.add(jScrollPane2, BorderLayout.CENTER);
    resultados.addTab("intervalos", intervalos);
    //***************************************************************************
    JPanel graficas = new JPanel(new GridLayout(0, 1));
    XYDataset dataset = createSampleDataset(Yestimada, 1);
    JFreeChart chart = ChartFactory.createXYLineChart("Grafica 1 - X1", "X", "Y", dataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);
    plot.setRenderer(renderer);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    graficas.add(chartPanel);//agregamos la primer grafica
    //********** creamos la segunda grafica
    XYDataset dataset2 = createSampleDataset(Yestimada, 2);
    JFreeChart chart2 = ChartFactory.createXYLineChart("Grafica 2 -X2", "X", "Y", dataset2,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot2 = (XYPlot) chart2.getPlot();
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, true);
    renderer2.setSeriesShapesVisible(0, true);
    renderer2.setSeriesLinesVisible(1, true);
    renderer2.setSeriesShapesVisible(1, true);
    plot2.setRenderer(renderer2);
    final ChartPanel chartPanel2 = new ChartPanel(chart2);
    chartPanel2.setPreferredSize(new java.awt.Dimension(500, 300));
    graficas.add(chartPanel2);
    resultados.addTab("graficas", graficas);
}

From source file:regresiones.EstadisticaDescriptiva.java

private void pintar(JTabbedPane panel1, Double[][] tabla) {
    JPanel panel = new JPanel(new BorderLayout());
    //tabla/*w w  w.  j  ava 2s.  co  m*/
    jtable = new JTable();//creamos la tabla a mostrar
    jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
    jtable.setFont(new java.awt.Font("Arial", 1, 14));
    jtable.setColumnSelectionAllowed(true);
    jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
    jtable.setInheritsPopupMenu(true);
    jtable.setMinimumSize(new java.awt.Dimension(80, 80));
    String[] titulos = { "i", "Li", "Ls", "Xi", "Fi", "Fa", "Fr", "Fra", "XiFi", "|Xi-X|Fi", "(Xi-X)^2 Fi" };//los titulos de la tabla
    DefaultTableModel TableModel = new DefaultTableModel(formato(tabla), titulos);
    jtable.setModel(TableModel);

    JScrollPane jScrollPane1 = new JScrollPane();
    jScrollPane1.setViewportView(jtable);
    jtable.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    panel.add(jScrollPane1, BorderLayout.CENTER);
    //campos
    JPanel medidas = new JPanel(new GridLayout(0, 6));

    JLabel etiquetaMax = new JLabel("Maximo");
    JTextField cajaMax = new JTextField();
    cajaMax.setText(MAXIMO + "");
    cajaMax.setEditable(false);

    JLabel etiquetaMin = new JLabel("Minimo");
    JTextField cajaMin = new JTextField();
    cajaMin.setText(MINIMO + "");
    cajaMin.setEditable(false);

    JLabel etiquetaN = new JLabel("N");
    JTextField cajaN = new JTextField();
    cajaN.setText(N + "");
    cajaN.setEditable(false);

    JLabel etiquetaRango = new JLabel("Rango");
    JTextField cajaRango = new JTextField();
    cajaRango.setText(MAXIMO - MINIMO + "");
    cajaRango.setEditable(false);

    JLabel etiquetaIntervalos = new JLabel("Intervalos");
    JTextField cajaIntervalos = new JTextField();
    cajaIntervalos.setText(INTERVALOS + "");
    cajaIntervalos.setEditable(false);

    JLabel etiquetaAmp = new JLabel("Amplitud");
    JTextField cajaAmp = new JTextField();
    cajaAmp.setText(AMPLITUD + "");
    cajaAmp.setEditable(false);

    JLabel etiquetaRamp = new JLabel("Rango Ampliado");
    JTextField cajaRamp = new JTextField();
    cajaRamp.setText(RANGOAMPLIADO + "");
    cajaRamp.setEditable(false);

    JLabel etiquetaDifRam = new JLabel("Dif Rangos");
    JTextField cajaDifRam = new JTextField();
    cajaDifRam.setText(DIFERENCIARANGOS + "");
    cajaDifRam.setEditable(false);

    JLabel etiquetaLIPI = new JLabel("LIPI");
    JTextField cajaLIPI = new JTextField();
    cajaLIPI.setText(LIPI + "");
    cajaLIPI.setEditable(false);

    JLabel etiquetaLSUI = new JLabel("LSUI");
    JTextField cajaLSUI = new JTextField();
    cajaLSUI.setText(LSUI + "");
    cajaLSUI.setEditable(false);

    JLabel etiquetaDM = new JLabel("Desv media");
    JTextField cajaDM = new JTextField();
    cajaDM.setText(DM + "");
    cajaDM.setEditable(false);

    JLabel etiquetaV = new JLabel("Varianza");
    JTextField cajaV = new JTextField();
    cajaV.setText(VARIANZA + "");
    cajaV.setEditable(false);

    JLabel etiquetaDE = new JLabel("Desv estandar");
    JTextField cajaDE = new JTextField();
    cajaDE.setText(DE + "");
    cajaDE.setEditable(false);

    JLabel etiquetaMe = new JLabel("Media");
    JTextField cajaMe = new JTextField();
    cajaMe.setText(MEDIA + "");
    cajaMe.setEditable(false);

    JLabel etiquetaMEDIANA = new JLabel("Mediana");
    JTextField cajaMEDIANA = new JTextField();
    cajaMEDIANA.setText(MEDIANA + "");
    cajaMEDIANA.setEditable(false);

    JLabel etiquetaModa = new JLabel("Moda");
    JTextField cajaModa = new JTextField();
    cajaModa.setText(MODA + "");
    cajaModa.setEditable(false);

    JButton boton = new JButton("Exportar a PDF");
    boton.addActionListener(this);

    medidas.add(etiquetaMax);
    medidas.add(cajaMax);
    medidas.add(etiquetaMin);
    medidas.add(cajaMin);
    medidas.add(etiquetaN);
    medidas.add(cajaN);

    medidas.add(etiquetaRango);
    medidas.add(cajaRango); //Jhony        
    medidas.add(etiquetaIntervalos);
    medidas.add(cajaIntervalos);
    medidas.add(etiquetaAmp);
    medidas.add(cajaAmp);
    medidas.add(etiquetaRamp);
    medidas.add(cajaRamp);
    medidas.add(etiquetaDifRam);
    medidas.add(cajaDifRam);
    medidas.add(etiquetaLIPI); //lipi
    medidas.add(cajaLIPI);

    medidas.add(etiquetaLSUI);
    medidas.add(cajaLSUI);
    medidas.add(etiquetaDM); //DESVIACION MEDIA
    medidas.add(cajaDM);
    medidas.add(etiquetaV); //VARIANZA
    medidas.add(cajaV);
    medidas.add(etiquetaDE); //DESVIACION ESTANDAR
    medidas.add(cajaDE);
    medidas.add(etiquetaMe); //MEDIA
    medidas.add(cajaMe);
    medidas.add(etiquetaMEDIANA); // mediana
    medidas.add(cajaMEDIANA);
    medidas.add(etiquetaModa); //moda
    medidas.add(cajaModa);
    medidas.add(boton);
    //SECCION DE GRAFICAS

    JFreeChart Grafica;
    DefaultCategoryDataset Datos = new DefaultCategoryDataset();
    //Buscar las pociciones de  LI       LS      Fa
    //                         0,1      0,2     0,5
    //agregar los valores a la grafica
    for (int i = 0; i < INTERVALOS; i++) {

        Datos.addValue(tabla[i][3], "frecuencia", tabla[i][1] + " - " + tabla[i][2]);
    }

    Grafica = ChartFactory.createLineChart("Histograma", "Frecuencia", "Li Ls", Datos, PlotOrientation.VERTICAL,
            true, true, false);

    ChartPanel p = new ChartPanel(Grafica);

    // termina seccion de grafica

    panel.add(medidas, BorderLayout.SOUTH);
    //panel.add(jScrollPane1, BorderLayout.CENTER); 
    panel1.addTab("Resultados", panel);
    panel1.addTab("Grafica", p);
}

From source file:regresiones.RegresionSimple.java

public void Resolver(JTabbedPane resultados) {

    for (int i = 0; i < 9; i++) {
        sumatorias[i] = 0.0;//w ww  . j a v  a  2  s .c o m
    }
    try {
        System.out.println("TOTAL DE DATOS: " + N);
        for (int i = 0; i < N; i++) {
            xiyi[i] = datos[i][0] * datos[i][1];
            System.out.println("X*Y" + i + ": " + xiyi[i]);
            x2[i] = datos[i][0] * datos[i][0]; //elevamos al cuadrado las x's
            y2[i] = datos[i][1] * datos[i][1]; //elevamos al cuadrado las y's
            sumatorias[0] += datos[i][0]; //sumatoria de x
            sumatorias[1] += datos[i][1]; //sumatoria de y

        }
        //sumatoria de xi*yi
        for (int j = 0; j < N; j++) {
            sumatorias[2] += xiyi[j];
        }

        //sumatoria de x^2
        for (int j = 0; j < N; j++) {
            sumatorias[3] += x2[j];
        }

        //sumatoria de y^2
        for (int j = 0; j < N; j++) {
            sumatorias[4] += y2[j];
        }

        mediax = sumatorias[0] / N;
        mediay = sumatorias[1] / N;

        System.out.println("RAIS 25: " + Math.sqrt(25));

        DecimalFormat df = new DecimalFormat("##.##");
        df.setRoundingMode(RoundingMode.DOWN);
        System.out.println("redondeo x^2-- " + df.format(sumatorias[3]));
        System.out.println("redondeo y^2-- " + df.format(sumatorias[4]));
        redondeoSumatoriax2 = Double.parseDouble(df.format(sumatorias[3]));
        redondeoSumatoriay2 = Double.parseDouble(df.format(sumatorias[4]));
        dxy = ((sumatorias[2]) / N) - mediax * mediay;
        dy = Math.sqrt(((redondeoSumatoriay2 / N) - (mediay * mediay)));
        dx = Math.sqrt(((redondeoSumatoriax2 / N) - (mediax * mediax)));

        b1 = ((sumatorias[2] * N) - sumatorias[0] * sumatorias[1])
                / ((sumatorias[3] * N) - (sumatorias[0] * sumatorias[0]));
        b0 = (sumatorias[1] / N) - ((b1 * sumatorias[0]) / N);

        // Y ESTIMADA
        for (int i = 0; i < N; i++) {
            yEstimada[i] = b0 + (b1 * datos[i][0]);
        }

        Se = Math.sqrt((sumatorias[4] - (b0 * sumatorias[1]) - (b1 * sumatorias[2])) / (N - 2));
        r = dxy / (dx * dy);
        System.out.println("sum x: " + sumatorias[0]);
        System.out.println("sum y: " + sumatorias[1]);
        System.out.println("sum x*y: " + sumatorias[2]);
        System.out.println("sum x^2: " + sumatorias[3]);
        System.out.println("sum y^2: " + sumatorias[4]);
        System.out.println("DX7: " + dxy);
        System.out.println("DY: " + dy);
        System.out.println("DX: " + dx);
        System.out.println("B0: " + b0);
        System.out.println("B1: " + b1);

        // mostramos resultados para la pestaa resultados***********************************************************************
        JPanel panel = new JPanel(new BorderLayout());
        panel.setBackground(Color.white);
        JLabel titulo = new JLabel("Resultados");//creamos el titulo
        panel.add(titulo, BorderLayout.PAGE_START);//lo agregamos al inicio
        jtable = new JTable();//creamos la tabla a mostrar
        jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
        jtable.setFont(new java.awt.Font("Arial", 1, 14));
        jtable.setColumnSelectionAllowed(true);
        jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
        jtable.setInheritsPopupMenu(true);
        jtable.setMinimumSize(new java.awt.Dimension(80, 80));
        String[] titulos = { "X", "Y", "Xi*Yi", "X2", "Y2", "Y estimada" };//los titulos de la tabla
        arregloFinal = new String[N][6];
        DecimalFormat formato = new DecimalFormat("0.00");
        for (int i = 0; i < N; i++) {//armamos el arreglo
            arregloFinal[i][0] = datos[i][0] + ""; //X
            arregloFinal[i][1] = datos[i][1] + "";//Y
            arregloFinal[i][2] = formato.format(xiyi[i]);
            arregloFinal[i][3] = formato.format(x2[i]);
            arregloFinal[i][4] = formato.format(y2[i]);
            arregloFinal[i][5] = formato.format(yEstimada[i]);
        }
        DefaultTableModel TableModel = new DefaultTableModel(arregloFinal, titulos);
        jtable.setModel(TableModel);
        JScrollPane jScrollPane1 = new JScrollPane();
        jScrollPane1.setViewportView(jtable);
        jtable.getColumnModel().getSelectionModel()
                .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        panel.add(jScrollPane1, BorderLayout.CENTER);
        JPanel panel2 = new JPanel(new GridLayout(0, 4));//creo un panel con rejilla de 4 columnas
        JLabel etiquetaN = new JLabel("N");
        JTextField cajaN = new JTextField();
        cajaN.setText(N + "");
        JLabel etiquetab0 = new JLabel("b0");
        JTextField cajab0 = new JTextField();
        cajab0.setText(b0 + "");
        JLabel etiquetab1 = new JLabel("b1");
        JTextField cajab1 = new JTextField();
        cajab1.setText(b1 + "");
        JLabel etiquetadxy = new JLabel("DXy");
        JTextField cajadxy = new JTextField();
        cajadxy.setText(dxy + "");
        JLabel etiquetadx = new JLabel("DX");
        JTextField cajadx = new JTextField();
        cajadx.setText(dx + "");
        JLabel etiquetady = new JLabel("DY");
        JTextField cajady = new JTextField();
        cajady.setText(dy + "");
        JLabel etiquetaR = new JLabel("R");
        JTextField cajaR = new JTextField();
        cajaR.setText(r + "");
        JLabel etiquetaSE = new JLabel("SE");
        JTextField cajaSE = new JTextField();
        cajaSE.setText(Se + "");
        JButton boton = new JButton("Exportar a PDF");
        boton.addActionListener(this);
        panel2.add(etiquetaN);
        panel2.add(cajaN);
        panel2.add(etiquetab0);
        panel2.add(cajab0);
        panel2.add(etiquetab1);
        panel2.add(cajab1);
        panel2.add(etiquetadxy);
        panel2.add(cajadxy);
        panel2.add(etiquetadx);
        panel2.add(cajadx);
        panel2.add(etiquetady);
        panel2.add(cajady);
        panel2.add(etiquetaR);
        panel2.add(cajaR);
        panel2.add(etiquetaSE);
        panel2.add(cajaSE);
        panel2.add(boton);
        panel.add(panel2, BorderLayout.SOUTH);//agrego el panel2 con rejilla en el panel principal al sur
        resultados.addTab("resultado", panel);
        //**************************************************************************************
        //intervalos de confianza
        JPanel intervalos = new JPanel(new BorderLayout());
        JPanel variables = new JPanel(new GridLayout(0, 2));
        JLabel variableX1 = new JLabel("X1");
        cajaVariableX1 = new JTextField();
        boton = new JButton("calcular");
        boton.addActionListener(this);
        JLabel variableEfectividad = new JLabel("Efectividad");
        String[] efectividades = { "80", "85", "90", "95", "99" };
        combo = new JComboBox(efectividades);
        variables.add(variableX1);
        variables.add(cajaVariableX1);
        variables.add(variableEfectividad);
        variables.add(combo);
        variables.add(boton);//comentario
        //cometario2
        intervalos.add(variables, BorderLayout.NORTH);
        jtable2 = new JTable();//creamos la tabla a mostrar
        jtable2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
        jtable2.setFont(new java.awt.Font("Arial", 1, 14));
        jtable2.setColumnSelectionAllowed(true);
        jtable2.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
        jtable2.setInheritsPopupMenu(true);
        jtable2.setMinimumSize(new java.awt.Dimension(80, 80));
        String[] titulos2 = { "Y estimada", "Li", "Ls" };//los titulos de la tabla
        String[][] pruebaIntervalos = { { "", "", "" } };
        DefaultTableModel TableModel2 = new DefaultTableModel(pruebaIntervalos, titulos2);
        jtable2.setModel(TableModel2);
        JScrollPane jScrollPane2 = new JScrollPane();
        jScrollPane2.setViewportView(jtable2);
        jtable2.getColumnModel().getSelectionModel()
                .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        intervalos.add(jScrollPane2, BorderLayout.CENTER);
        resultados.addTab("intervalos", intervalos);
        // ***********************************************************************
        JPanel graficas = new JPanel(new GridLayout(0, 1));
        XYDataset dataset = createSampleDataset();
        JFreeChart chart = ChartFactory.createXYLineChart("Grafica", "X", "Y", dataset,
                PlotOrientation.VERTICAL, true, false, false);
        XYPlot plot = (XYPlot) chart.getPlot();
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setSeriesLinesVisible(0, true);
        renderer.setSeriesShapesVisible(0, true);
        renderer.setSeriesLinesVisible(1, true);
        renderer.setSeriesShapesVisible(1, true);
        plot.setRenderer(renderer);
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
        graficas.add(chartPanel);//agregamos la primer grafica
        resultados.addTab("Graficas", graficas);
        //IMPRIMIR JTABLE
        /* MessageFormat headerFormat = new MessageFormat("MI CABECERA");
         MessageFormat footerFormat = new MessageFormat("- Pgina {0} -");
         jtable.print(PrintMode.FIT_WIDTH, headerFormat, footerFormat);
         */

    } catch (Exception e) {
        e.printStackTrace();
    }
}