List of usage examples for javax.swing JPanel revalidate
public void revalidate()
From source file:projectresurrection.Music.java
public void subMenuAll(int type, String menu) { JPanel panel = (JPanel) ((JViewport) ((JScrollPane) pnlSub.getComponent(3)).getComponent(0)) .getComponent(0);/* w ww. jav a 2s. co m*/ JLabel header = (JLabel) pnlSub.getComponent(1); header.setText(menu + " - All"); panel.removeAll(); int y = 10; switch (type) { case 0: List songList = new ArrayList(); List albumList = new ArrayList(((Map) artists.get(menu)).keySet()); Collections.sort(albumList); for (int i = 0; i < albumList.size(); i++) { List albumSongs = new ArrayList(((Map) albums.get(albumList.get(i))).keySet()); Map tracks = new HashMap(); for (int j = 0; j < albumSongs.size(); j++) { String track = ((List) songs.get(albumSongs.get(j))).get(1).toString(); tracks.put(track, albumSongs.get(j)); } List nums = new ArrayList(tracks.keySet()); Collections.sort(nums); List hasTrack = new ArrayList(); List noTrack = new ArrayList(); for (int j = 0; j < nums.size(); j++) { if (nums.get(j).equals("-1")) { noTrack.add(tracks.get(nums.get(j))); } else { hasTrack.add(tracks.get(nums.get(j))); } } for (int j = 0; j < hasTrack.size(); j++) { songList.add(hasTrack.get(j)); } for (int j = 0; j < noTrack.size(); j++) { songList.add(noTrack.get(j)); } } panel.setPreferredSize(new Dimension(349, (20 + (songList.size() * 35)))); List fileList = new ArrayList(); for (int i = 0; i < songList.size(); i++) { fileList.add(((List) songs.get(songList.get(i))).get(0)); } for (int i = 0; i < songList.size(); i++) { int num = i; String song = songList.get(i).toString(); JLabel label = new JLabel(song); label.setOpaque(true); if (i % 2 == 0) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { player.setPlaylist(fileList, num); pnlSub.setVisible(false); pnlPlayer.setVisible(true); try { Thread.sleep(200); } catch (Exception e) { } if (player.isPlaying() == false) { player.toggle(); } } }); panel.add(label); y += 35; } break; } panel.revalidate(); panel.repaint(); }
From source file:savant.chromatogram.ChromatogramPlugin.java
private void updateChromatogram() { if (chromatogram != null) { if (GenomeUtils.isGenomeLoaded() && GenomeUtils.getGenome().isSequenceSet()) { TrackAdapter sequenceTrack = GenomeUtils.getGenome().getSequenceTrack(); JPanel layerCanvas = sequenceTrack.getLayerCanvas(this); if (canvas == null) { layerCanvas.setOpaque(false); layerCanvas.setLayout(new BorderLayout()); canvas = new ChromatogramCanvas(chromatogram, sequenceTrack); layerCanvas.add(canvas, BorderLayout.CENTER); }/*from ww w . ja va2 s . c o m*/ layerCanvas.revalidate(); layerCanvas.repaint(); } } }
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); }// w w w . java2 s .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; }
From source file:us.paulevans.basicxslt.XSLRow.java
/** * Removes all the checked rows from aRows * @param aRows/*from w ww.j a v a2s. c om*/ * @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; }