本文整理汇总了Java中javax.swing.JPanel.remove方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.remove方法的具体用法?Java JPanel.remove怎么用?Java JPanel.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPanel
的用法示例。
在下文中一共展示了JPanel.remove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clear
import javax.swing.JPanel; //导入方法依赖的package包/类
public static void clear(JPanel paneColEdit)
{
if (paneColEdit.getComponentCount() == 1)
{
paneColEdit.remove(0);
paneColEdit.updateUI();
}
}
示例2: removeMultiple
import javax.swing.JPanel; //导入方法依赖的package包/类
@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();
}
示例3: startRename
import javax.swing.JPanel; //导入方法依赖的package包/类
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();
}
示例4: finishRename
import javax.swing.JPanel; //导入方法依赖的package包/类
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();
}