Example usage for javax.swing JPanel repaint

List of usage examples for javax.swing JPanel repaint

Introduction

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

Prototype

public void repaint() 

Source Link

Document

Repaints this component.

Usage

From source file:us.paulevans.basicxslt.XSLRow.java

/**
 * Removes all the checked rows from aRows
 * @param aRows// w w w .  j a va2 s  . c  o  m
 * @return
 */
public static int removeChecked(List aRows) {

    int loop, size, numRemoved;
    XSLRow xslRow;
    JPanel parent;

    numRemoved = 0;
    size = aRows.size();
    parent = null;
    for (loop = size - 1; loop >= 0; loop--) {
        xslRow = (XSLRow) aRows.get(loop);
        parent = xslRow.parent;
        if (xslRow.removeCb.isSelected()) {
            xslRow.parent.remove(xslRow.insertBtn);
            xslRow.parent.remove(xslRow.label);
            xslRow.parent.remove(xslRow.textField);
            xslRow.parent.remove(xslRow.browseBtn);
            xslRow.parent.remove(xslRow.removeCb);
            xslRow.parent.remove(xslRow.action);
            xslRow.parent.remove(xslRow.indicatorLabel);
            aRows.remove(loop);
            numRemoved++;
        }
    }
    if (numRemoved > 0) {
        parent.repaint();
        parent.revalidate();
    }
    size = aRows.size();
    for (loop = 0; loop < size; loop++) {
        ((XSLRow) aRows.get(loop)).setIndex(loop);
    }
    return numRemoved;
}

From source file:Widgets.Simulation.java

protected JPanel trajectoryTabb() {
    JPanel trajectoryPanel = new JPanel();

    //judge if converged
    //final JLabel convergePanel = new JLabel();   
    plot.removeAllPlots();//from   w  ww. ja  va2  s  .co  m

    plot.setAxisLabel(0, "t");
    plot.setAxisLabel(1, "Expression Level");
    plot.setPreferredSize(new Dimension(440, 390));

    //ArrayList<DoubleMatrix2D> timeSeries_ = grn.getTimeSeries();
    //ArrayList<DoubleMatrix1D> timeScale_ = grn.getTimeScale();

    //display multiple time series
    //combobox
    //generate time series List
    String[] timeSeriesList = new String[grn.getTimeSeries().size()];

    for (int i = 0; i < grn.getTimeSeries().size(); i++)
        timeSeriesList[i] = Integer.toString(i);

    JLabel selectPanelName = new JLabel("Select trajectory: ");
    JPanel selectPanel = new JPanel();
    //selectPanel.setPreferredSize(new Dimension(1000,10));
    final JComboBox<String> combo = new JComboBox<String>(timeSeriesList);

    //view window
    final JPanel trajectoryViewPanel = new JPanel();
    //trajectoryViewPanel.setPreferredSize(new Dimension(990,500));

    plot.setPreferredSize(new Dimension(440, 350));
    double[] t = grn.getTimeScale().get(0).toArray();
    for (int k = 0; k < grn.getTimeSeries().get(0).columns(); k++)
        plot.addLinePlot(grn.getNode(k).getLabel(), t, grn.getTimeSeries().get(0).viewColumn(k).toArray());
    plot.addLegend("SOUTH");
    plot.repaint();

    //combobox action             
    combo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int row = combo.getSelectedIndex();

            plot.removeAllPlots();

            double[] t = grn.getTimeScale().get(row).toArray();
            for (int k = 0; k < grn.getTimeSeries().get(row).columns(); k++) {
                plot.addLinePlot(grn.getNode(k).getLabel(), t,
                        grn.getTimeSeries().get(row).viewColumn(k).toArray());
            }

            trajectoryViewPanel.repaint();
            trajectoryViewPanel.setVisible(true);
        }
    });

    selectPanel.setLayout(new BoxLayout(selectPanel, BoxLayout.X_AXIS));
    selectPanel.add(selectPanelName);
    selectPanel.add(combo);
    trajectoryViewPanel.add(plot);

    //set layout
    trajectoryPanel.setLayout(new GridBagLayout());
    NetLand.addComponent(trajectoryPanel, trajectoryViewPanel, 0, 0, 1, 1, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, 0, 1);
    NetLand.addComponent(trajectoryPanel, selectPanel, 0, 1, 1, 1, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, 1, 0);
    //NetLand.addComponent(trajectoryPanel, convergePanel, 0, 2, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, 1, 0);

    return trajectoryPanel;
}