Example usage for javax.swing JLayeredPane repaint

List of usage examples for javax.swing JLayeredPane repaint

Introduction

In this page you can find the example usage for javax.swing JLayeredPane repaint.

Prototype

public void repaint() 

Source Link

Document

Repaints this component.

Usage

From source file:LayeredPaneDemo.java

public void close() {
    if (getParent() instanceof JLayeredPane) {
        JLayeredPane jlp = (JLayeredPane) getParent();
        jlp.remove(InnerFrame.this);
        jlp.repaint();
    }/*  ww w.j a v a2  s  .  c  o m*/
}

From source file:ecosim.gui.SummaryPane.java

/**
 *  Private method to build the text pane.
 *
 *  @return A JLayeredPane containing the text pane.
 *//*from w  w w.ja va 2s. c om*/
private JLayeredPane makeTextPane() {
    final String ls = System.getProperty("line.separator");
    final String fmt = "Outgroup: %s" + ls + "Number: %,d" + ls + "Length: %,d" + ls + "Diversity: %.2f" + ls;

    final JLayeredPane pane = new JLayeredPane();
    final JTextArea summaryTextArea = new JTextArea(String.format(fmt, summary.getOutgroup(), summary.getNu(),
            summary.getLength(), summary.getDiversity()));
    summaryTextArea.setBackground(getBackground());
    pane.setBorder(BorderFactory.createTitledBorder("Sequences"));
    pane.setLayout(new FlowLayout(0));
    pane.add(summaryTextArea);
    // Watch for changes to the Summary object.
    summary.addObserver(new Observer() {
        public void update(Observable o, Object obj) {
            Summary s = (Summary) obj;
            ParameterEstimate estimate = s.getEstimate();
            summaryTextArea
                    .setText(String.format(fmt, s.getOutgroup(), s.getNu(), s.getLength(), s.getDiversity()));
            pane.repaint();
        }
    });
    return pane;
}

From source file:ecosim.gui.SummaryPane.java

/**
 *  Private method to build the table pane.
 *
 *  @return A JLayeredPane containing the table pane.
 *///from ww w  .ja v  a2s  .  co  m
private JLayeredPane makeTablePane() {
    String[] columnNames = { "", "Estimate", "Hillclimbing", "Low", "High" };
    Integer[] columnWidths = { 250, 60, 60, 60, 60 };
    Object[][] rowData = { { "Number of putative ecotypes (npop)", null, null, null, null },
            { "Rate of ecotype formation (omega)", null, null, null, null },
            { "Rate of periodic selection (sigma)", null, null, null, null } };
    final JLayeredPane pane = new JLayeredPane();
    final JTable table = new JTable(rowData, columnNames) {
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    final JTableHeader header = table.getTableHeader();
    pane.setLayout(new BorderLayout());
    header.setReorderingAllowed(false);
    TableColumnModel cm = table.getColumnModel();
    for (int i = 0; i < columnWidths.length; i++) {
        TableColumn column = cm.getColumn(i);
        column.setMinWidth(columnWidths[i]);
        if (i == 0) {
            column.setCellRenderer(new DefaultTableCellRenderer() {
                public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                        boolean hasFocus, int row, int column) {
                    Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
                            row, column);
                    cell.setBackground(header.getBackground());
                    cell.setForeground(header.getForeground());
                    return cell;
                }
            });
        }
    }
    pane.add(table.getTableHeader(), "North");
    pane.add(table, "Center");
    // Watch for changes to the Summary object.
    summary.addObserver(new Observer() {
        public void update(Observable o, Object obj) {
            Summary s = (Summary) obj;
            ParameterEstimate estimate = s.getEstimate();
            ParameterSet hillclimbing = s.getHillclimbing();
            ParameterSet[] ci = s.getConfidenceInterval();
            if (estimate != null) {
                ParameterSet e = estimate.getResult();
                table.setValueAt(e.getNpop(), 0, 1);
                table.setValueAt(String.format("%.4f", e.getOmega()), 1, 1);
                table.setValueAt(String.format("%.4f", e.getSigma()), 2, 1);
            }
            if (hillclimbing != null) {
                table.setValueAt(hillclimbing.getNpop(), 0, 2);
                table.setValueAt(String.format("%.4f", hillclimbing.getOmega()), 1, 2);
                table.setValueAt(String.format("%.4f", hillclimbing.getSigma()), 2, 2);
            }
            if (ci[0].getNpop() != null) {
                table.setValueAt(ci[0].getNpop(), 0, 3);
                table.setValueAt(ci[1].getNpop(), 0, 4);
            }
            if (ci[1].getOmega() != null) {
                table.setValueAt(String.format("%.4f", ci[0].getOmega()), 1, 3);

                String fmt = "%.4f";
                if (ci[1].getOmega() > 10.0D) {
                    fmt = "%.1f";
                } else if (ci[1].getOmega() > 1.0D) {
                    fmt = "%.2f";
                }
                table.setValueAt(String.format(fmt, ci[1].getOmega()), 1, 4);
            }
            if (ci[1].getSigma() != null) {
                table.setValueAt(String.format("%.4f", ci[0].getSigma()), 2, 3);
                if (ci[1].getSigma() > 100.0D - MasterVariables.EPSILON) {
                    table.setValueAt("100", 2, 4);
                } else {
                    String fmt = "%.4f";
                    if (ci[1].getSigma() > 10.0D) {
                        fmt = "%.1f";
                    } else if (ci[1].getSigma() > 1.0D) {
                        fmt = "%.2f";
                    }
                    table.setValueAt(String.format(fmt, ci[1].getSigma()), 2, 4);
                }
            }
            pane.repaint();
        }
    });
    return pane;
}