Example usage for javax.swing JPanel removeAll

List of usage examples for javax.swing JPanel removeAll

Introduction

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

Prototype

public void removeAll() 

Source Link

Document

Removes all the components from this container.

Usage

From source file:CorrelationLambdaTest.java

@Test

public void crossCorrelationGraphicTest() {

    CategoryTableXYDataset serie = new CategoryTableXYDataset();
    serie.setNotify(false);//from  w ww  .  ja  v  a2s  .c om
    double step = 1.0 / discretization;
    double startPosition = step * framePosition;
    //100 ? - 100 , 50 ? - 50 , 25 ?- 25 
    Transform t = new Transform(new FastWaveletTransform(new Haar1()));
    double[] signal = testData.get1DSimpleSignal(1.5, 500, 32768, 5000);
    double[] data = crossCorrelationCoefficient(signal, window);

    //        double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128));

    //        double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32));
    //        double[] data = testData.get1DSignal(100, 200, frameWidth, discretization);
    //        double[] data = math.lpf(70, step,128);
    for (int i = 0; i < data.length; i++) {
        serie.add(startPosition, data[i], "");
        startPosition += step;
    }
    JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "wave", serie);
    chart.removeLegend();
    chart.setAntiAlias(false);

    XYPlot plot = chart.getXYPlot();
    //plot.setRangeGridlinePaint(Color.BLACK);
    org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis();
    org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis();
    double start = framePosition * 1.0 / discretization;
    double max = start + frameWidth * 1.0 / discretization;
    xAxis.setRange(start, max);
    ChartPanel chartPanel = new ChartPanel(chart);

    JPanel p = new JPanel(new BorderLayout());

    p.removeAll();
    p.add(chartPanel);
    p.validate();
    //1. Create the frame.
    JFrame frame = new JFrame("FrameDemo");

    //2. Optional: What happens when the frame closes?
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //3. Create components and put them in the frame.
    //...create emptyLabel...
    frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER);
    frame.getContentPane().add(p, BorderLayout.CENTER);

    //4. Size the frame.
    frame.pack();

    //5. Show it.
    frame.setVisible(true);
}

From source file:com.intel.stl.ui.main.view.NodeStatesPie.java

protected void fillLengendPanel(JPanel panel, PieDataset dataset, Color[] colors) {
    panel.removeAll();
    GridBagConstraints gc = new GridBagConstraints();

    gc.fill = GridBagConstraints.BOTH;
    int size = dataset.getItemCount();
    stateLabels = new JLabel[size];
    for (int i = 0; i < size; i++) {
        gc.insets = new Insets(2, 5, 2, 2);
        gc.weightx = 0;/*from w w w. j  a  v a 2  s  .co  m*/
        gc.gridwidth = 1;

        JLabel label = new JLabel(dataset.getKey(i).toString(),
                Util.generateImageIcon(colors[i], 8, new Insets(1, 1, 1, 1)), JLabel.LEFT);
        label.setFont(UIConstants.H5_FONT);
        label.setForeground(UIConstants.INTEL_DARK_GRAY);
        panel.add(label, gc);

        gc.gridwidth = GridBagConstraints.REMAINDER;
        gc.weightx = 0;
        stateLabels[i] = new JLabel();
        stateLabels[i].setForeground(UIConstants.INTEL_DARK_GRAY);
        stateLabels[i].setFont(UIConstants.H3_FONT);
        panel.add(stateLabels[i], gc);
    }
}

From source file:com.polivoto.vistas.acciones.Datos.java

public void setBarChartIn(JPanel panel) {
    CategoryDataset dataset = crearDatasetBar();
    JFreeChart chart = createChartBar(dataset);
    ChartPanel barChart = new ChartPanel(chart);
    barChart.setBounds(panel.getVisibleRect());
    panel.removeAll();
    panel.add(barChart);//from   ww w . ja  va  2 s .c  om
    panel.repaint();
}

From source file:com.romraider.logger.ecu.ui.handler.dash.DialGaugeStyle.java

private void refreshChart(final JPanel panel) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JFreeChart chart = buildChart();
            ChartPanel chartPanel = new ChartPanel(chart);
            chartPanel.setPreferredSize(getChartSize());
            panel.removeAll();
            panel.add(chartPanel);/*  ww  w.  j  a v a  2  s.  co  m*/
            panel.revalidate();
        }
    });
}

From source file:com.enderville.enderinstaller.ui.Installer.java

private void buildOptionsPane() {

    JPanel p = getMainPane();
    p.removeAll();

    JPanel leftPane = new JPanel(new MigLayout(new LC().fill(), new AC().index(1).fill().grow(),
            new AC().index(0).fill().grow().index(1).fill().grow()));
    leftPane.add(new JLabel("Please select which optional mods you would like to install."),
            new CC().spanX().wrap());
    leftPane.add(new JLabel("Presets: "), new CC());
    leftPane.add(getPresetDropdown(), new CC().grow().wrap());
    leftPane.add(new JScrollPane(getModTree()), new CC().spanX().spanY().grow().wrap());

    p.setLayout(new MigLayout(new LC().fill(), new AC().index(0).fill().grow().index(1).fill().grow(),
            new AC().fill()));
    p.add(leftPane, new CC().grow().width(":300:"));
    p.add(getModDescriptionPane(), new CC().grow().width(":300:300").wrap());

    p.validate();/*from   w ww .  j  av a 2 s. c  o  m*/
    p.repaint();
}

From source file:com.enderville.enderinstaller.ui.Installer.java

private void loadModDescription(String modName) {
    JPanel p = getModDescriptionPane();
    p.removeAll();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));

    final String extras = InstallerConfig.getExtraModsFolder();
    final String modFolderName = FilenameUtils.concat(extras, modName);
    File modFolder = new File(modFolderName);
    if (!modFolder.exists()) {
        LOGGER.error("Mod folder for " + modName + " does not exist.");
    }/*from  ww w  .j a  va 2s.  c  om*/
    File descrFile = new File(FilenameUtils.concat(modFolderName, "description.txt"));
    File imgFile = new File(FilenameUtils.concat(modFolderName, "image.png"));
    if (!descrFile.exists() && !imgFile.exists()) {
        p.add(new JLabel("<html>No description for:<br>" + modName + "</html>"));
    } else {
        if (imgFile.exists()) {
            try {
                JLabel label = new JLabel();
                BufferedImage img = ImageIO.read(imgFile);
                label.setIcon(new ImageIcon(img));
                p.add(label);
            } catch (IOException e) {
                LOGGER.error("Error reading image file: " + imgFile.getPath(), e);
            }
        }
        if (descrFile.exists()) {
            StringBuilder buffer = new StringBuilder();
            try {
                BufferedReader r = new BufferedReader(new FileReader(descrFile));
                String l = null;
                while ((l = r.readLine()) != null) {
                    buffer.append(l + "\n");
                }
                r.close();
                JEditorPane area = new JEditorPane();
                area.setContentType("text/html");
                area.setText(buffer.toString());
                area.setEditable(false);
                area.addHyperlinkListener(this);
                area.setCaretPosition(0);
                p.add(new JScrollPane(area));
            } catch (IOException e) {
                LOGGER.error("Error reading description file: " + descrFile.getPath(), e);
            }
        }
    }

    p.validate();
    p.repaint();
}

From source file:com.polivoto.vistas.acciones.Datos.java

public void setPieChartIn(JPanel panel) {
    PieDataset dataset = crearDatasetPie();
    JFreeChart chart = null;//  w  w  w  . j a  v a 2s.co m
    try {
        chart = crearChartPie(dataset, ac.getPreguntas().getJSONObject(pox).getString("pregunta"));
    } catch (JSONException ex) {
        ex.printStackTrace();
    }
    ChartPanel pie = new ChartPanel(chart);
    pie.setBounds(panel.getVisibleRect());
    panel.removeAll();
    panel.add(pie);
    panel.repaint();
}

From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java

private void refreshQuickOpenPanel(JPanel panel, List<Action> quickOpenActionList, List<File> fileList) {
    panel.removeAll();
    quickOpenActionList.clear();//from   ww w .  j a  va2  s  .c  o  m
    if (fileList.isEmpty()) {
        JLabel noneLabel = new JLabel("None");
        noneLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
        panel.add(noneLabel);
    } else {
        for (File file : fileList) {
            Action quickOpenAction = new QuickOpenAction(file);
            quickOpenActionList.add(quickOpenAction);
            JButton quickOpenButton = new JButton(quickOpenAction);
            quickOpenButton.setHorizontalAlignment(SwingConstants.LEFT);
            quickOpenButton.setMargin(new Insets(0, 0, 0, 0));
            panel.add(quickOpenButton);
        }
    }
}

From source file:edu.ku.brc.af.core.NavBox.java

/**
 * /*from   w  w  w  .ja  v  a2  s .  c  o m*/
 */
private void reAddItems() {
    JPanel panelToLayout = scrollable ? itemsPanel : this;
    panelToLayout.removeAll();

    String rowDef = "";
    if (items.size() > 0) {
        rowDef = UIHelper.createDuplicateJGoodiesDef("p", "1px", items.size()) + ",";
    }
    rowDef += "f:p:g";

    int row = 1;
    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", rowDef), panelToLayout);
    for (int i = 0; i < items.size(); i++) {
        pb.add(items.get(i).getUIComponent(), cc.xy(1, row));
        row += 2;
    }
}

From source file:ec.nbdemetra.ui.demo.ComponentsDemo.java

public ComponentsDemo() {
    initStaticResources();/* ww w .  jav  a 2  s  . c o  m*/

    final Map<Id, Component> demoData = lookupComponents();

    final JPanel main = new JPanel(new BorderLayout());
    final JTree tree = new JTree();
    tree.setRootVisible(false);
    tree.setCellRenderer(new IdRenderer(demoData));

    IdsTree.fill(tree, Lists.newArrayList(demoData.keySet()));
    expandAll(tree);

    tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            TreePath p = tree.getSelectionPath();
            if (p != null) {
                main.removeAll();
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) p.getLastPathComponent();
                Id id = IdsTree.translate(node);
                Component c = demoData.get(id);
                main.add(c != null ? c : new JPanel());
                main.validate();
                main.repaint();
            }
        }
    });

    JTsList dragDrop = new JTsList();
    dragDrop.setShowHeader(false);
    dragDrop.setInformation(new ITsList.InfoType[] { ITsList.InfoType.TsIdentifier, ITsList.InfoType.Data });
    dragDrop.setPreferredSize(new Dimension(200, 200));
    dragDrop.setTsAction(DemoTsActions.DO_NOTHING);

    JSplitPane left = NbComponents.newJSplitPane(JSplitPane.VERTICAL_SPLIT, NbComponents.newJScrollPane(tree),
            dragDrop);
    JSplitPane splitPane = NbComponents.newJSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, main);
    splitPane.getLeftComponent().setPreferredSize(new Dimension(200, 400));

    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
}