java.awt.Container#removeAll ( )源码实例Demo

下面列出了java.awt.Container#removeAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ghidra   文件: SelectionManagerTest.java
private void createTable(boolean isThreaded) {
	if (frame == null) {
		frame = new JFrame("GTree Test");
	}

	if (isThreaded) {
		table = new GTable(threadedModel);
	}
	else {
		table = new GTable(model);
	}

	Container contentPane = frame.getContentPane();
	contentPane.removeAll();
	contentPane.setLayout(new BorderLayout());
	frame.getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
	frame.setSize(1000, 400);
	frame.setVisible(true);

	waitForTableModel();
}
 
源代码2 项目: jasperreports   文件: JRViewer.java
/**
*/
private void emptyContainer(Container container)
{
	Component[] components = container.getComponents();

	if (components != null)
	{
		for(int i = 0; i < components.length; i++)
		{
			if (components[i] instanceof Container)
			{
				emptyContainer((Container)components[i]);
			}
		}
	}

	components = null;
	container.removeAll();
	container = null;
}
 
private void layoutContentPane() {
	Container pane = getContentPane();
	pane.removeAll();
	pane.add(distinguishedNameChooser, "left, spanx, wrap");
	if (editable) {
		// when no DN was given, the default and reset button do exactly the same thing
		if (distinguishedName == null || distinguishedName.getRDNs().length == 0) {
			pane.add(jbReset, "right, spanx, wrap");
		} else {
			pane.add(jbReset, "right, spanx, split 2");
			pane.add(jbDefault, "wrap");
		}
	}
	pane.add(new JSeparator(), "spanx, growx, wrap");
	pane.add(jpButtons, "right, spanx");

	pack();
	validate();
	repaint();
}
 
源代码4 项目: nordpos   文件: JRViewer.java
/**
*/
private void emptyContainer(Container container)
{
	Component[] components = container.getComponents();

	if (components != null)
	{
		for(int i = 0; i < components.length; i++)
		{
			if (components[i] instanceof Container)
			{
				emptyContainer((Container)components[i]);
			}
		}
	}

	components = null;
	container.removeAll();
	container = null;
}
 
源代码5 项目: ShootPlane   文件: MainFrame.java
public void loadGame() throws LineUnavailableException, UnsupportedAudioFileException, IOException {
Container c = this.getContentPane();
c.removeAll();
this.repaint();
if (this.gameLoadingPanel == null) {
    this.gameLoadingPanel = new GameLoadingPanel();
}

BoxLayout boxLayout = new BoxLayout(c, BoxLayout.Y_AXIS);
c.setLayout(boxLayout);
c.add(Box.createVerticalGlue());
c.add(this.gameLoadingPanel);
c.add(Box.createVerticalGlue());
this.gameLoadingPanel.loadingGame();

this.startGame();
   }
 
源代码6 项目: netcdf-java   文件: IndependentWindow.java
public void setComponent(Component comp) {
  Container cp = getContentPane();
  cp.removeAll();
  cp.add(comp, BorderLayout.CENTER);
  try {
    pack();
  } catch (IllegalArgumentException e) {
    // Ticket ID: HEM-237554
    // I'm using IceWM window manager under Linux, and it does not support changing the icon on the top left side of
    // the window.
    // This crashes the whole thing. I dont think this should be a fatal exception.
    // It would be helpful for future releases to catch this exception and let the program go ahead without the icon.
    log.error("Possible problem setting icon (?)", e);
  }
}
 
源代码7 项目: netbeans   文件: AdditionalWizardPanel.java
/** Resets panel back after monitoring search. Implements <code>ProgressMonitor</code> interface method. */
public void reset() {
    Container container = (Container) getComponent();
    
    if(!container.isAncestorOf(getUI())) {
        container.removeAll();
        GridBagConstraints constraints = new GridBagConstraints();
        constraints.weightx = 1.0;
        constraints.weighty = 1.0;
        constraints.fill = GridBagConstraints.BOTH;
        container.add(getUI(), constraints);
    }
}
 
源代码8 项目: netbeans   文件: BasicReplaceResultsPanel.java
void displayIssues(IssuesPanel issuesPanel) {
    if (issuesPanel != null) {
        showRefreshButton();
        removeButtons(btnNext, btnPrev, btnFlatView, btnTreeView,
                btnExpand, showDetailsButton);
        Container p = getContentPanel();
        p.removeAll();
        p.add(issuesPanel);
        validate();
        repaint();
    }
}
 
源代码9 项目: pumpernickel   文件: BoxTabbedPaneUI.java
private void installExtraComponents(Container container,
		List<JComponent> components, boolean forceReinstall) {
	if (components == null)
		components = new ArrayList<>();
	Component[] oldComponents = container.getComponents();
	if (!Arrays.asList(oldComponents).equals(components)) {
		forceReinstall = true;
	}

	if (forceReinstall) {
		container.removeAll();
		GridBagConstraints c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 100;
		c.weightx = 1;
		c.weighty = 1;
		c.fill = GridBagConstraints.BOTH;
		for (JComponent jc : components) {
			container.add(jc, c);
			if (tabs.getTabPlacement() == SwingConstants.LEFT) {
				c.gridy--;
			} else if (tabs.getTabPlacement() == SwingConstants.RIGHT) {
				c.gridy++;
			} else {
				c.gridx++;
			}
			jc.removeComponentListener(extraComponentListener);
			jc.addComponentListener(extraComponentListener);

			for (Component oldComponent : oldComponents) {
				if (components.contains(oldComponent)) {
					oldComponent
							.removeComponentListener(extraComponentListener);
				}
			}
		}
		container.revalidate();
	}
	refreshExtraContainerVisibility();
}
 
源代码10 项目: jpexs-decompiler   文件: MainPanel.java
private void disposeInner(Container container) {
    for (Component c : container.getComponents()) {
        if (c instanceof Container) {
            Container c2 = (Container) c;
            disposeInner(c2);
        }
    }

    container.removeAll();
    container.setLayout(null);
    if (container instanceof TagEditorPanel) {
        Helper.emptyObject(container);
    }
}
 
源代码11 项目: magarena   文件: MagicInfoWindow.java
private void refreshLayout() {
    final Container content = getContentPane();
    content.removeAll();
    final int titleHeight = title.getFontMetrics(body.getFont()).getMaxAscent();
    content.add(title, "h " + (titleHeight + 4) + "!");

    final String bodyText = body.getText();
    final String plainText = bodyText.replace("<html>", "").replace("</html>", "").replace("<br>", "");
    body.setText(plainText);
    final FontMetrics fontMetrics = body.getFontMetrics(body.getFont());
    body.setText(bodyText);

    final int maxWidth = 380;
    final String[] lineText = bodyText.replace("<html>", "").replace("</html>", "").trim().split("\r\n|\r|\n|<br>");
    int totalLines = 0;
    int totalWidth = 0;
    for (String text : lineText) {
        totalLines++;
        final int textWidth = fontMetrics.stringWidth(text.trim().isEmpty() ? "." : text);
        double calc1 = textWidth / ((double) maxWidth);
        final double calc2 = Math.ceil(calc1);
        long calc3 = Math.round(calc2);
        final int textLines = (int) (textWidth == 0 ? 1 : calc3 - 1);
        totalLines += textLines;
        final int W = textWidth > maxWidth ? maxWidth : textWidth;
        if (W > totalWidth) {
            totalWidth = W;
        }
    }

    final int lineHeight = fontMetrics.getMaxAscent() + fontMetrics.getMaxDescent();
    final int totalHeight = (totalLines + 1) * lineHeight;

    body.setMinimumSize(new Dimension(0, 0));
    body.setPreferredSize(new Dimension(totalWidth, totalHeight));
    body.setMaximumSize(new Dimension(maxWidth, totalHeight));

    content.add(body, "w 0:" + totalWidth + ":" + maxWidth + ", h " + totalHeight + "!");
    revalidate();
}
 
源代码12 项目: ShootPlane   文件: MainFrame.java
private void popupMenuPanel() {
Container c = this.getContentPane();
c.removeAll();
this.repaint();
if (this.popupMenuPanel == null) {
    this.popupMenuPanel = new PopupMenuPanel(this);
}
BoxLayout boxLayout = new BoxLayout(c, BoxLayout.Y_AXIS);
c.setLayout(boxLayout);
c.add(Box.createVerticalGlue());
c.add(this.popupMenuPanel);
c.add(Box.createVerticalGlue());
this.validate();
   }
 
源代码13 项目: ShootPlane   文件: MainFrame.java
private void startGame() throws LineUnavailableException, UnsupportedAudioFileException, IOException {
Container c = this.getContentPane();
c.removeAll();
this.repaint();
BorderLayout borderLayout = new BorderLayout();
c.setLayout(borderLayout);
this.gamePlayingPanel = new GamePlayingPanel();
c.add(this.gamePlayingPanel, BorderLayout.CENTER);
this.gamePlayingPanel.startGame();
long startTime = System.currentTimeMillis();
while (this.gamePlayingPanel.getMyPlane().isAlive()) {
    try {
	Thread.sleep(Config.GAME_PANEL_REPAINT_INTERVAL);
    } catch (InterruptedException e) {
	e.printStackTrace();
    }
}
long endTime = System.currentTimeMillis();
// add to score list
this.addScore(this.gamePlayingPanel.getScore(), endTime - startTime);
int option = JOptionPane.showConfirmDialog(this, "Game Over, Score:" + this.gamePlayingPanel.getScore()
	+ ", Start Again?", "Game Over", JOptionPane.YES_NO_OPTION);
switch (option) {
case JOptionPane.YES_OPTION:
    loadGame();
    break;
case JOptionPane.NO_OPTION:
    stopGame();
    break;
}
   }
 
源代码14 项目: ShootPlane   文件: MainFrame.java
private void popupScorePanel(List<Score> sortedScoreList) {
Container c = this.getContentPane();
c.removeAll();
this.repaint();
if (this.popupScorePanel == null) {
    this.popupScorePanel = new Top10ScorePanel(this);
}
this.popupScorePanel.loadScore(sortedScoreList);
BoxLayout boxLayout = new BoxLayout(c, BoxLayout.Y_AXIS);
c.setLayout(boxLayout);
c.add(Box.createVerticalGlue());
c.add(this.popupScorePanel);
c.add(Box.createVerticalGlue());
this.validate();
   }
 
源代码15 项目: SPIM_Registration   文件: GUIHelper.java
/**
	 * A copy of Curtis's method
	 * 
	 * https://github.com/openmicroscopy/bioformats/blob/v4.4.8/components/loci-plugins/src/loci/plugins/util/WindowTools.java#L72
	 * 
	 *
	 * @param pane
	 */
	public static void addScrollBars(Container pane) {
//        * <dependency>
//        * <groupId>${bio-formats.groupId}</groupId>
//        * <artifactId>loci_plugins</artifactId>
//        * <version>${bio-formats.version}</version>
//        * </dependency>

		GridBagLayout layout = (GridBagLayout) pane.getLayout();

		// extract components
		int count = pane.getComponentCount();
		Component[] c = new Component[count];
		GridBagConstraints[] gbc = new GridBagConstraints[count];
		for (int i = 0; i < count; i++) {
			c[i] = pane.getComponent(i);
			gbc[i] = layout.getConstraints(c[i]);
		}

		// clear components
		pane.removeAll();
		layout.invalidateLayout(pane);

		// create new container panel
		Panel newPane = new Panel();
		GridBagLayout newLayout = new GridBagLayout();
		newPane.setLayout(newLayout);
		for (int i = 0; i < count; i++) {
			newLayout.setConstraints(c[i], gbc[i]);
			newPane.add(c[i]);
		}

		// HACK - get preferred size for container panel
		// NB: don't know a better way:
		// - newPane.getPreferredSize() doesn't work
		// - newLayout.preferredLayoutSize(newPane) doesn't work
		Frame f = new Frame();
		f.setLayout(new BorderLayout());
		f.add(newPane, BorderLayout.CENTER);
		f.pack();
		final Dimension size = newPane.getSize();
		f.remove(newPane);
		f.dispose();

		// compute best size for scrollable viewport
		size.width += 25;
		size.height += 15;
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		int maxWidth = 7 * screen.width / 8;
		int maxHeight = 3 * screen.height / 4;
		if (size.width > maxWidth)
			size.width = maxWidth;
		if (size.height > maxHeight)
			size.height = maxHeight;

		// create scroll pane
		ScrollPane scroll = new ScrollPane() {
			private static final long serialVersionUID = 1L;

			public Dimension getPreferredSize() {
				return size;
			}
		};
		scroll.add(newPane);

		// add scroll pane to original container
		GridBagConstraints constraints = new GridBagConstraints();
		constraints.gridwidth = GridBagConstraints.REMAINDER;
		constraints.fill = GridBagConstraints.BOTH;
		constraints.weightx = 1.0;
		constraints.weighty = 1.0;
		layout.setConstraints(scroll, constraints);
		pane.add(scroll);
	}