Example usage for javax.swing JPanel setBackground

List of usage examples for javax.swing JPanel setBackground

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:de.burrotinto.jKabel.dispalyAS.DisplayK.java

@Bean(name = "bearbeitenPanel")
public JPanel getBearbeitenPanel(KabelTypAuswahlAAS kabelTypAuswahlAAS, TrommelAuswahlAAS tommelAAs,
        StreckenAAS streckenAAS, Color background) {

    kabelTypAuswahlAAS.addKabelTypListner(tommelAAs);
    kabelTypAuswahlAAS.addKabelTypListner(streckenAAS);

    tommelAAs.addTrommelListner(streckenAAS);

    JPanel l = new JPanel(new GridLayout(1, 2));
    JPanel all = new JPanel(new GridLayout(1, 2));

    JScrollPane kSP = new JScrollPane(kabelTypAuswahlAAS);
    l.add(kSP);/*from  w w  w  . j av  a 2 s.c o m*/
    l.add(new JScrollPane(tommelAAs));
    all.add(l);
    JScrollPane sc = new JScrollPane(streckenAAS);
    sc.setPreferredSize(new Dimension(740, 740));
    all.add(sc);

    kSP.setOpaque(false);
    sc.setOpaque(false);

    l.setBackground(background);
    kabelTypAuswahlAAS.setBackground(background);
    tommelAAs.setBackground(background);
    streckenAAS.setBackground(background);

    try {
        streckenAAS.setLogo(ImageIO.read(new File(ConfigReader.getInstance().getPath() + "logo.jpg")));
    } catch (IOException e) {
        streckenAAS.setLogo(null);
    }
    all.setBackground(background);
    return all;
}

From source file:ac.openmicrolabs.view.gui.OMLLoggerView.java

private JPanel createContentPane(final TimeSeriesCollection t, final String graphTitle,
        final double graphTimeRange, final String[] signals) {

    btmPanel.remove(reportButton);/*from   w w  w . j ava  2  s  . c o m*/

    chanLabel = new JLabel[signals.length];

    int activeSignalCount = 0;
    for (int i = 0; i < signals.length; i++) {
        chanLabel[i] = new JLabel(h.format("label", (char) ((i / PIN_COUNT) + ASCII_OFFSET) + "-0x"
                + String.format("%02x", (i % PIN_COUNT) + SLAVE_BITS).toUpperCase()));
        chanLabel[i].setHorizontalAlignment(JLabel.CENTER);
        if (signals[i] != null) {
            activeSignalCount++;
        } else {
            chanLabel[i].setEnabled(false);
        }
    }

    typeLabel = new JLabel[activeSignalCount];
    valLabel = new JLabel[activeSignalCount];
    minLabel = new JLabel[activeSignalCount];
    maxLabel = new JLabel[activeSignalCount];
    avgLabel = new JLabel[activeSignalCount];

    int index = 0;
    for (int i = 0; i < signals.length; i++) {
        if (signals[i] != null) {
            typeLabel[index] = new JLabel(h.format("body", signals[i]));
            typeLabel[index].setHorizontalAlignment(JLabel.CENTER);
            index++;
        }
    }

    for (int i = 0; i < activeSignalCount; i++) {
        valLabel[i] = new JLabel();
        valLabel[i].setHorizontalAlignment(JLabel.CENTER);
        minLabel[i] = new JLabel();
        minLabel[i].setHorizontalAlignment(JLabel.CENTER);
        maxLabel[i] = new JLabel();
        maxLabel[i].setHorizontalAlignment(JLabel.CENTER);
        avgLabel[i] = new JLabel();
        avgLabel[i].setHorizontalAlignment(JLabel.CENTER);
    }

    // Set up main panel.
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(null);
    mainPanel.setBackground(Color.white);

    // Create graph.
    snsChart = ChartFactory.createTimeSeriesChart(graphTitle, GRAPH_X_LABEL, GRAPH_Y_LABEL, t, true, true,
            false);
    final XYPlot plot = snsChart.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(graphTimeRange);
    axis = plot.getRangeAxis();
    axis.setRange(graphMinY, graphMaxY);

    ChartPanel snsChartPanel = new ChartPanel(snsChart);
    snsChartPanel.setPreferredSize(new Dimension(FRAME_WIDTH - PAD20, GRAPH_HEIGHT - PAD10));

    // Set up graph panel.
    final JPanel graphPanel = new JPanel();
    graphPanel.setSize(FRAME_WIDTH - PAD20, GRAPH_HEIGHT);
    graphPanel.setLocation(0, 0);
    graphPanel.setBackground(Color.white);
    graphPanel.add(snsChartPanel);

    // Set up results panel.
    final JPanel resultsPanel = createResultsPane();

    // Set up scroll pane.
    final JScrollPane scrollPane = new JScrollPane(resultsPanel);
    scrollPane.setSize(FRAME_WIDTH - PAD20, FRAME_HEIGHT - BTM_HEIGHT - GRAPH_HEIGHT + PAD8);
    scrollPane.setLocation(PAD5, GRAPH_HEIGHT);
    scrollPane.setBackground(Color.white);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

    // Set results panel size.
    resultsPanel.setPreferredSize(new Dimension(PAD40 + (signals.length * RESULTS_COL_WIDTH),
            FRAME_HEIGHT - BTM_HEIGHT - GRAPH_HEIGHT - PAD120));
    resultsPanel.revalidate();

    // Set up bottom panel.
    btmPanel.setLayout(null);
    btmPanel.setSize(FRAME_WIDTH, BTM_HEIGHT);
    btmPanel.setLocation(0, this.getHeight() - BTM_HEIGHT);
    btmPanel.setBackground(Color.white);

    // Instantiate bottom panel objects.
    footerLabel.setSize(LABEL_WIDTH, LABEL_HEIGHT);
    footerLabel.setLocation(LABEL_X, LABEL_Y);
    footerLabel.setText("");

    doneButton.setIcon(new ImageIcon("img/22x22/stop.png"));
    doneButton.setSize(DONE_WIDTH, DONE_HEIGHT);
    doneButton.setLocation(FRAME_WIDTH - PAD20 - doneButton.getWidth(), PAD15);

    progressBar = new JProgressBar();
    progressBar.setSize(FRAME_WIDTH - PAD40 - doneButton.getWidth() - footerLabel.getWidth(), PAD20);
    progressBar.setValue(0);
    progressBar.setLocation(footerLabel.getWidth() + PAD10, PAD22);

    // Populate bottom panel.
    btmPanel.add(footerLabel);
    btmPanel.add(progressBar);
    btmPanel.add(doneButton);

    // Populate main panel.
    mainPanel.add(graphPanel);
    mainPanel.add(scrollPane);
    mainPanel.add(btmPanel);

    return mainPanel;
}

From source file:genlib.output.gui.Graph2D.java

/**
 * open a window with one or more plot-collections
 *
 * @param rows count of rows/*from w w w  . j av a  2s  .  c o  m*/
 * @param cols count of columns
 * @param gap size of gaps between Plots (in pixel)
 * @param percentSizeOfScreen the size of the complete window in per-cent of the windows
 * @param plots the plot-collections, can have null's inside,then there is empty space on the window
 * @return the window-object
 * @throws IllegalArgumentException if rows or cols lower than 1, gap lower than 0, percentSizeOfScreen lower than 0.001 or higher than 1 or number of plots not the same as rows*cols
 */
public static Graph2D open(int rows, int cols, int gap, double percentSizeOfScreen, PlotCollection... plots) {
    if (rows <= 0)
        throw new IllegalArgumentException("invalid rows-count: '" + rows + "'.");
    if (cols <= 0)
        throw new IllegalArgumentException("invalid cols-count: '" + cols + "'.");
    if (gap < 0)
        throw new IllegalArgumentException("invalid gap: '" + gap + "'.");
    if (percentSizeOfScreen < 0.001 || percentSizeOfScreen > 1)
        throw new IllegalArgumentException("invalid percentSizeOfScreen: '" + percentSizeOfScreen + "'.");
    if (plots == null || plots.length != rows * cols)
        throw new IllegalArgumentException("length of plots is not rows*cols.");

    //the window-title is a concatenation of all plots
    //but first, we have to ignore all null-plots
    String windowTitle = "";
    List<PlotCollection> plotsNotNull = new ArrayList();
    for (PlotCollection plot : plots)
        if (plot != null)
            plotsNotNull.add(plot);

    if (plotsNotNull.isEmpty())
        windowTitle = "no plots";
    else
        for (int i = 0; i < plotsNotNull.size(); i++)
            windowTitle += (i > 0 ? ", " : "") + plotsNotNull.get(i).title;

    //create the window
    Graph2D ret = new Graph2D(windowTitle);

    //and create the row-col-layout
    JPanel grid = new JPanel();
    grid.setLayout(new GridLayout(rows, cols, gap, gap));
    for (PlotCollection plot : plots)
        if (plot == null)
            grid.add(new JLabel(""));
        else
            grid.add(plot.getGUIElement());

    //some other attributes of the window
    grid.setBackground(Color.BLACK);
    ret.setContentPane(grid);
    ret.pack();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    ret.setSize(new Dimension((int) (screenSize.getWidth() * percentSizeOfScreen),
            (int) (screenSize.getHeight() * percentSizeOfScreen)));
    RefineryUtilities.centerFrameOnScreen(ret);
    ret.setVisible(true);

    return ret;
}

From source file:ac.openmicrolabs.view.gui.OMLLoggerView.java

private JPanel createResultsPane() {
    final JPanel resultsPanel = new JPanel();
    resultsPanel.setLayout(new GridLayout(RESULTS_GRID_ROWS, RESULTS_GRID_COL));
    resultsPanel.setBackground(Color.white);

    resultsPanel.add(new JLabel(""));
    for (JLabel l : chanLabel) {
        resultsPanel.add(l);/* w ww  .j  a va2 s.com*/
    }

    int index = 0;
    resultsPanel.add(new JLabel(""));
    for (JLabel l : chanLabel) {
        if (l.isEnabled()) {
            resultsPanel.add(typeLabel[index]);
            index++;
        } else {
            resultsPanel.add(new JLabel(""));
        }
    }

    resultsPanel.add(valSideLabel);
    index = 0;
    for (JLabel l : chanLabel) {
        if (l.isEnabled()) {
            resultsPanel.add(valLabel[index]);
            index++;
        } else {
            resultsPanel.add(new JLabel(""));
        }
    }

    resultsPanel.add(new JLabel("Min:"));
    index = 0;
    for (JLabel l : chanLabel) {
        if (l.isEnabled()) {
            resultsPanel.add(minLabel[index]);
            index++;
        } else {
            resultsPanel.add(new JLabel(""));
        }
    }

    resultsPanel.add(new JLabel("Max:"));
    index = 0;
    for (JLabel l : chanLabel) {
        if (l.isEnabled()) {
            resultsPanel.add(maxLabel[index]);
            index++;
        } else {
            resultsPanel.add(new JLabel(""));
        }
    }

    resultsPanel.add(avgSideLabel);
    index = 0;
    for (JLabel label : chanLabel) {
        if (label.isEnabled()) {
            resultsPanel.add(avgLabel[index]);
            index++;
        } else {
            resultsPanel.add(new JLabel(""));
        }
    }

    return resultsPanel;
}

From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java

/**
 * Creates the UI panel containing all of the fields necessary to upload
 * the current session data to the web service
 *///from ww w . ja  v  a  2  s  . com
private void createSetupPane() {
    this.setupPanel = new JPanel();
    this.setupPanel.setLayout(new BorderLayout());
    this.setupPanel.setBackground(Color.white);

    try {
        String data = IOUtils.toString(LoginDialog.class.getResourceAsStream("/export2.html"));
        data = data.replace("{LIST}", formatWitnessList());
        JLabel txt = new JLabel(data);
        this.setupPanel.add(txt, BorderLayout.NORTH);
    } catch (IOException e) {
        // dunno. not much that can be done!
    }

    // ugly layout code to follow. avert your eyes
    JPanel data = new JPanel();
    data.setLayout(new BorderLayout());
    data.setBackground(Color.white);

    JPanel names = new JPanel();
    names.setLayout(new BoxLayout(names, BoxLayout.Y_AXIS));
    names.setBackground(Color.white);
    JLabel l = new JLabel("Name:", SwingConstants.RIGHT);
    l.setPreferredSize(new Dimension(100, 20));
    l.setMaximumSize(new Dimension(100, 20));
    l.setAlignmentX(RIGHT_ALIGNMENT);
    names.add(l);
    names.add(Box.createVerticalStrut(5));

    JLabel l2 = new JLabel("Description:", SwingConstants.RIGHT);
    l2.setPreferredSize(new Dimension(100, 20));
    l2.setMaximumSize(new Dimension(100, 20));
    l2.setAlignmentX(RIGHT_ALIGNMENT);
    names.add(l2);
    data.add(names, BorderLayout.WEST);

    JPanel edits = new JPanel();
    edits.setBackground(Color.white);
    edits.setLayout(new BoxLayout(edits, BoxLayout.Y_AXIS));
    this.nameEdit = new JTextField();
    this.nameEdit.setPreferredSize(new Dimension(200, 22));
    this.nameEdit.setMaximumSize(new Dimension(200, 22));
    File saveFile = this.juxtaFrame.getSession().getSaveFile();
    if (saveFile == null) {
        this.nameEdit.setText("new_session");
    } else {
        String name = saveFile.getName();
        this.nameEdit.setText(name.substring(0, name.lastIndexOf('.')));
    }
    edits.add(this.nameEdit);

    this.descriptionEdit = new JTextArea(3, 0);
    this.descriptionEdit.setLineWrap(true);
    this.descriptionEdit.setWrapStyleWord(true);

    JScrollPane sp = new JScrollPane(this.descriptionEdit);
    sp.setPreferredSize(new Dimension(194, 60));
    sp.setMaximumSize(new Dimension(194, 300));
    edits.add(Box.createVerticalStrut(4));
    edits.add(sp);

    data.add(edits, BorderLayout.CENTER);

    this.setupPanel.add(data, BorderLayout.SOUTH);
}

From source file:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java

private void init() {
    setLayout(new BorderLayout());

    contentPanel = new TierDataLayoutPanel();

    dateField = createDateField();//w w  w.  j a v  a2 s  . c o  m
    dateField.getTextField().setColumns(10);
    dateField.setBackground(Color.white);

    mediaLocationField = new MediaSelectionField(getEditor().getProject());
    mediaLocationField.setEditor(getEditor());
    mediaLocationField.getTextField().setColumns(10);
    mediaLocationField.addPropertyChangeListener(FileSelectionField.FILE_PROP, mediaLocationListener);

    participantTable = new JXTable();
    participantTable.setVisibleRowCount(3);

    ComponentInputMap participantTableInputMap = new ComponentInputMap(participantTable);
    ActionMap participantTableActionMap = new ActionMap();

    ImageIcon deleteIcon = IconManager.getInstance().getIcon("actions/delete_user", IconSize.SMALL);
    final PhonUIAction deleteAction = new PhonUIAction(this, "deleteParticipant");
    deleteAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Delete selected participant");
    deleteAction.putValue(PhonUIAction.SMALL_ICON, deleteIcon);
    participantTableActionMap.put("DELETE_PARTICIPANT", deleteAction);
    participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DELETE_PARTICIPANT");
    participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "DELETE_PARTICIPANT");

    removeParticipantButton = new JButton(deleteAction);

    participantTable.setInputMap(WHEN_FOCUSED, participantTableInputMap);
    participantTable.setActionMap(participantTableActionMap);

    addParticipantButton = new JButton(new NewParticipantAction(getEditor(), this));
    addParticipantButton.setFocusable(false);

    ImageIcon editIcon = IconManager.getInstance().getIcon("actions/edit_user", IconSize.SMALL);
    final PhonUIAction editParticipantAct = new PhonUIAction(this, "editParticipant");
    editParticipantAct.putValue(PhonUIAction.NAME, "Edit participant...");
    editParticipantAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Edit selected participant...");
    editParticipantAct.putValue(PhonUIAction.SMALL_ICON, editIcon);
    editParticipantButton = new JButton(editParticipantAct);
    editParticipantButton.setFocusable(false);

    final CellConstraints cc = new CellConstraints();
    FormLayout participantLayout = new FormLayout("fill:pref:grow, pref, pref, pref", "pref, pref, pref:grow");
    JPanel participantPanel = new JPanel(participantLayout);
    participantPanel.setBackground(Color.white);
    participantPanel.add(new JScrollPane(participantTable), cc.xywh(1, 2, 3, 2));
    participantPanel.add(addParticipantButton, cc.xy(2, 1));
    participantPanel.add(editParticipantButton, cc.xy(3, 1));
    participantPanel.add(removeParticipantButton, cc.xy(4, 2));
    participantTable.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            if (arg0.getClickCount() == 2 && arg0.getButton() == MouseEvent.BUTTON1) {
                editParticipantAct.actionPerformed(new ActionEvent(arg0.getSource(), arg0.getID(), "edit"));
            }
        }

    });

    languageField = new LanguageField();
    languageField.getDocument().addDocumentListener(languageFieldListener);

    int rowIdx = 0;
    final JLabel dateLbl = new JLabel("Session Date");
    dateLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(dateLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(dateField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    final JLabel mediaLbl = new JLabel("Media");
    mediaLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(mediaLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(mediaLocationField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    final JLabel partLbl = new JLabel("Participants");
    partLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(partLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(participantPanel, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    final JLabel langLbl = new JLabel("Language");
    langLbl.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPanel.add(langLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx));
    contentPanel.add(languageField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++));

    add(new JScrollPane(contentPanel), BorderLayout.CENTER);

    update();
}

From source file:src.gui.LifelinePanel.java

public void buildBottonToolBar() {

    buttonPanel = new JPanel(new BorderLayout());
    buttonPanel.setBackground(Color.WHITE);

    //JLabel test = new JLabel("<html><a href=\"http://www.google.com\">delete</a></html>");
    JPanel leftpanel = new JPanel(new BorderLayout());
    leftpanel.setBackground(Color.WHITE);

    JButton button = new JButton(editLifeLine);
    button.setToolTipText("Edit lifeline");
    button.setBackground(Color.WHITE);
    button.setBorderPainted(false);/*from w  ww. j ava  2 s .c o m*/
    leftpanel.add(button, BorderLayout.WEST);
    button.setRolloverEnabled(true);

    button = new JButton(deleteLifeLine);
    button.setToolTipText("Delete lifeline");
    button.setBackground(Color.WHITE);
    button.setBorderPainted(false);
    leftpanel.add(button, BorderLayout.EAST);
    button.setRolloverEnabled(true);

    //JLabel editlabel = new JLabel("<html><b><u>edit</u></b> </html>");
    //leftpanel.add(editlabel, BorderLayout.WEST);
    //JLabel deletelabel = new JLabel("<html><b><u>delete</u></b></html>");
    //leftpanel.add(deletelabel, BorderLayout.EAST);

    buttonPanel.add(leftpanel, BorderLayout.EAST);
    this.add(buttonPanel, BorderLayout.SOUTH);

}

From source file:de.codesourcery.eve.skills.ui.components.impl.PriceHistoryComponent.java

@Override
protected JPanel createPanel() {

    dateRangeChooser.setModel(new DefaultComboBoxModel<DisplayRange>(Arrays.asList(DisplayRange.values())));

    dateRangeChooser.setSelectedItem(DisplayRange.WEEK);

    final JPanel controlPanel = new JPanel();
    controlPanel.setBackground(Color.WHITE);
    //      controlPanel.setLayout( new GridBagLayout() );
    //      controlPanel.add( dateRangeChooser , constraints().noResizing().end() );
    controlPanel.add(dateRangeChooser);//from w  ww. j a v a 2s . co  m

    dateRangeChooser.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            changeDateRange((DisplayRange) dateRangeChooser.getSelectedItem());
        }
    });

    // moving avg. chooser
    this.movingAverageChooser
            .setModel(new DefaultComboBoxModel<MovingAverage>(Arrays.asList(MovingAverage.values())));

    this.movingAverageChooser.setSelectedItem(MovingAverage.FIVE_DAYS);
    this.movingAverageChooser.addActionListener(actionListener);
    controlPanel.add(movingAverageChooser);

    final JPanel result = new JPanel();
    result.setBackground(Color.WHITE);
    result.setLayout(new GridBagLayout());

    final JPanel freeChartPanel = createFreeChartPanel(); // attention: chart must always be
    // populated AFTER date range chooser is set up because
    // this calculates earliest/latest dates from dataset

    //      panel.setPreferredSize( new Dimension(500,200 ) );

    result.add(controlPanel, constraints(0, 0).resizeBoth().weightX(0.2).weightY(0.2).end());
    result.add(freeChartPanel, constraints(0, 1).resizeBoth().end());

    return result;
}

From source file:regresiones.RegresionSimple.java

public void Resolver(JTabbedPane resultados) {

    for (int i = 0; i < 9; i++) {
        sumatorias[i] = 0.0;/* w w w . java2 s .com*/
    }
    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();
    }
}

From source file:livecanvas.mesheditor.MeshEditor.java

public MeshEditor() {
    super("Mesh Editor", new ImageIcon(clazz.getResource("res/mesh_editor.png")), new BorderLayout());
    setPreferredSize(new Dimension(1024, 600));
    setBackground(Color.darkGray);

    tools = createTools();/*  w ww  .  j a v  a  2  s.  co m*/
    add(tools, BorderLayout.WEST);

    selectedColor = Color.black;
    JPanel east = new JPanel(new BorderLayout());
    east.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    Layer rootLayer = new Layer("ROOT");
    rootLayer.addSubLayer(new Layer("Layer1"));
    layersView = new LayersView(rootLayer);
    chain(layersView);
    layersView.addListener(this);
    east.add(layersView, BorderLayout.NORTH);
    propertiesPanel = new JPanel(new BorderLayout());
    east.add(propertiesPanel);
    viewpointsView = new ViewpointsView(layersView.getSelectedLayer());
    viewpointsView.addListener(this);
    east.add(viewpointsView, BorderLayout.SOUTH);
    add(east, BorderLayout.EAST);

    JPanel center = new JPanel(new BorderLayout());
    center.setBackground(Color.lightGray);
    canvas = new CanvasMesh(800, 600);
    canvas.setCurrLayer(getRootLayer());
    pointerHandler = new AffineTransformPointerHandler(canvas);
    canvas.setPointerHandler(pointerHandler);
    canvasContainer = new CanvasContainer(canvas);
    rootLayer.setCanvas(canvas);
    center.add(canvasContainer);

    renderImageSettings = new RenderImageSettings();
    settings = new MeshEditorSettings(canvas.getSettings(), layersView.getSettings(), renderImageSettings);

    add(center);
    layersView.layersList.setSelectedIndex(1);
    setSelectedToolType(TOOLS_BRUSH);
}