List of usage examples for javax.swing JPanel remove
public void remove(int index)
From source file:tvbrowser.ui.mainframe.MainFrame.java
public void updateToolbar() { JPanel contentPane = (JPanel) getContentPane(); if (mToolBarPanel != null) { contentPane.remove(mToolBarPanel); }//from w w w . j av a2s . c om mToolBarModel = DefaultToolBarModel.getInstance(); mToolBar = new ToolBar(mToolBarModel); mToolBar.setOpaque(false); String location = mToolBar.getToolbarLocation(); if (Settings.propIsToolbarVisible.getBoolean()) { if (mToolBarPanel == null) { mToolBarPanel = new JPanel(new BorderLayout()) { public void updateUI() { super.updateUI(); setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, getBackground().darker())); } }; addContextMenuMouseListener(mToolBarPanel); mSearchField = new SearchField(); } else { mToolBarPanel.removeAll(); } if (location.compareTo(BorderLayout.NORTH) == 0) { mToolBarPanel.add(MoreButton.wrapToolBar(mToolBar, this), BorderLayout.CENTER); if (Settings.propIsSearchFieldVisible.getBoolean()) { mToolBarPanel.add(mSearchField, BorderLayout.EAST); } } else { mToolBarPanel.add(MoreButton.wrapToolBar(mToolBar, this), BorderLayout.WEST); if (Settings.propIsSearchFieldVisible.getBoolean()) { mToolBarPanel.add(mSearchField, BorderLayout.SOUTH); } } contentPane.add(mToolBarPanel, location); } contentPane.invalidate(); contentPane.updateUI(); }