Java Code Examples for javax.swing.JPanel.remove()

The following are Jave code examples for showing how to use remove() of the javax.swing.JPanel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: s-store   File: RandomDistributionEditorManager.java   View Source Code Vote up 7 votes
public static void clear(JPanel paneColEdit)
{
    if (paneColEdit.getComponentCount() == 1)
    {
        paneColEdit.remove(0);
        paneColEdit.updateUI();
    }
}
 
Example 2
Project: AgentWorkbench   File: DynForm.java   View Source Code Vote up 6 votes
@Override
protected void removeMultiple(DefaultMutableTreeNode node){
	
	// --- Remind all needed informations -------------------------------------------
	DefaultMutableTreeNode previousNode = node.getPreviousNode();
	DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
	
	DynType dt = (DynType) node.getUserObject();
	JPanel deletePanel = dt.getPanel();
	JPanel parentPanel = (JPanel) deletePanel.getParent();
	
	int movement = (deletePanel.getHeight() + 2) * (-1);
	
	// --- Remove node from the parent node and panel -------------------------------
	DynType dyntype = (DynType) node.getUserObject();
	node.setUserObject(null);
	parentNode.remove(node);
	this.getTreeNodesByDynType().remove(dyntype);
	
	// --- remove the panel from the parent -----------------------------------------
	parentPanel.remove(deletePanel);
	parentPanel.validate();
	this.setPanelBounds(parentPanel);
	
	// --- Now move the rest of the elements on the form ----------------------------
	this.moveAfterAddOrRemove(movement, previousNode);

	// --- refresh the GUI ----------------------------------------------------------
	this.adjustPreferredSize();
	
}
 
Example 3
Project: enigma-vk   File: Gui.java   View Source Code Vote up 6 votes
private void finishRename(JTextField text, boolean saveName) {
	String newName = text.getText();
	if (saveName && newName != null && newName.length() > 0) {
		try {
			m_controller.rename(m_reference, newName);
		} catch (IllegalNameException ex) {
			text.setBorder(BorderFactory.createLineBorder(Color.red, 1));
			text.setToolTipText(ex.getReason());
			GuiTricks.showToolTipNow(text);
		}
		return;
	}
	
	// abort the rename
	JPanel panel = (JPanel)m_infoPanel.getComponent(0);
	panel.remove(panel.getComponentCount() - 1);
	panel.add(GuiTricks.unboldLabel(new JLabel(m_reference.getNamableName(), JLabel.LEFT)));
	
	m_editor.grabFocus();
	
	redraw();
}
 
Example 4
Project: sstore-soft   File: RandomDistributionEditorManager.java   View Source Code Vote up 5 votes
public static void clear(JPanel paneColEdit)
{
    if (paneColEdit.getComponentCount() == 1)
    {
        paneColEdit.remove(0);
        paneColEdit.updateUI();
    }
}
 
Example 5
Project: enigma-vk   File: Gui.java   View Source Code Vote up 5 votes
private void startRename() {
	
	// init the text box
	final JTextField text = new JTextField();
	text.setText(m_reference.getNamableName());
	text.setPreferredSize(new Dimension(360, text.getPreferredSize().height));
	text.addKeyListener(new KeyAdapter() {
		@Override
		public void keyPressed(KeyEvent event) {
			switch (event.getKeyCode()) {
				case KeyEvent.VK_ENTER:
					finishRename(text, true);
				break;
				
				case KeyEvent.VK_ESCAPE:
					finishRename(text, false);
				break;
			}
		}
	});
	
	// find the label with the name and replace it with the text box
	JPanel panel = (JPanel)m_infoPanel.getComponent(0);
	panel.remove(panel.getComponentCount() - 1);
	panel.add(text);
	text.grabFocus();
	text.selectAll();
	
	redraw();
}