List of usage examples for javax.swing JPanel removeAll
public void removeAll()
From source file:savant.snp.SNPFinderPlugin.java
/** * Refresh list of canvases./* w ww . j ava2 s . c o m*/ */ private void updateTrackCanvasMap() { if (viewTrackToCanvasMap == null) { viewTrackToCanvasMap = new HashMap<TrackAdapter, JPanel>(); } // TODO: should get rid of old JPanels here! // START for (JPanel p : viewTrackToCanvasMap.values()) { p.removeAll(); } viewTrackToCanvasMap.clear(); // END Map<TrackAdapter, JPanel> newmap = new HashMap<TrackAdapter, JPanel>(); for (TrackAdapter t : TrackUtils.getTracks()) { if (t.getDataSource().getDataFormat() == DataFormat.ALIGNMENT) { if (viewTrackToCanvasMap.containsKey(t)) { newmap.put(t, viewTrackToCanvasMap.get(t)); viewTrackToCanvasMap.remove(t); } else { //System.out.println("putting " + t.getName() + " in BAM map"); newmap.put(t, t.getLayerCanvas(this)); } } } viewTrackToCanvasMap = newmap; }
From source file:savant.snp.SNPFinderPlugin.java
/** * Draw piles on panel.//from w w w . j a v a 2 s .c o m */ private void drawPiles(List<Pileup> piles, JPanel p) { p.removeAll(); PileupPanel pup = new PileupPanel(piles); pup.setTransparency(this.transparency); p.setLayout(new BorderLayout()); p.add(pup, BorderLayout.CENTER); this.repaintPileupPanels(); }
From source file:ua.com.fielden.platform.example.swing.egi.EgiExample.java
private void addTotalsFooterTo(final EntityGridInspector egi, final JPanel topPanel) { // final JPanel panel = new JPanel(new MigLayout("insets 0", "[]", "[]0[]push[]")); // panel.add(egi.getTableHeader(), "grow, wrap"); // panel.add(egi, "grow, wrap"); final JScrollPane scrollPane = new JScrollPane(egi); topPanel.add(scrollPane, "grow, wrap"); final JPanel footer = new JPanel(new MigLayout("nogrid, insets 0")); // footer.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); final List<JComponent> totalsComponents = new ArrayList<JComponent>(); for (int i = 0; i < egi.getColumnCount(); i++) { final TableColumn column = egi.getColumnModel().getColumn(i); final JComponent totalsComponent = i % 2 == 0 ? new JTextField("totals " + i) : new JLabel(); totalsComponent.setPreferredSize(new Dimension(column.getPreferredWidth(), 30)); footer.add(totalsComponent, "grow"); totalsComponents.add(totalsComponent); }//from w w w . j a v a2s . c o m final JScrollPane footerPane = new JScrollPane(footer, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); topPanel.add(footerPane, "grow, wrap, h 40::"); topPanel.add(scrollPane.getHorizontalScrollBar(), "grow, wrap"); scrollPane.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(final AdjustmentEvent e) { footerPane.getViewport().setViewPosition(new Point(e.getValue(), 0)); } }); egi.getColumnModel().addColumnModelListener(new TableColumnModelListener() { @Override public void columnAdded(final TableColumnModelEvent e) { } @Override public void columnMarginChanged(final ChangeEvent e) { final TableColumn column = egi.getTableHeader().getResizingColumn(); if (column != null) { final JComponent totalsComponent = totalsComponents .get(egi.convertColumnIndexToView(column.getModelIndex())); totalsComponent.setPreferredSize(new Dimension(column.getWidth(), totalsComponent.getHeight())); footer.revalidate(); } } @Override public void columnMoved(final TableColumnModelEvent e) { final JComponent fromComponent = totalsComponents.get(e.getFromIndex()); totalsComponents.set(e.getFromIndex(), totalsComponents.get(e.getToIndex())); totalsComponents.set(e.getToIndex(), fromComponent); footer.removeAll(); for (int i = 0; i < egi.getColumnCount(); i++) { footer.add(totalsComponents.get(i), "grow, gap 0 0 0 0"); } footer.revalidate(); } @Override public void columnRemoved(final TableColumnModelEvent e) { } @Override public void columnSelectionChanged(final ListSelectionEvent e) { } }); // // return panel; }