本文整理汇总了Java中javax.swing.tree.MutableTreeNode.insert方法的典型用法代码示例。如果您正苦于以下问题:Java MutableTreeNode.insert方法的具体用法?Java MutableTreeNode.insert怎么用?Java MutableTreeNode.insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.MutableTreeNode
的用法示例。
在下文中一共展示了MutableTreeNode.insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveUp
import javax.swing.tree.MutableTreeNode; //导入方法依赖的package包/类
@Override
public void moveUp(GenericTreeModel<T> model, T node)
{
MutableTreeNode parent = (MutableTreeNode) node.getParent();
parent.insert(node, parent.getIndex(node) - 1);
}
示例2: moveDown
import javax.swing.tree.MutableTreeNode; //导入方法依赖的package包/类
@Override
public void moveDown(GenericTreeModel<T> model, T node)
{
MutableTreeNode parent = (MutableTreeNode) node.getParent();
parent.insert(node, parent.getIndex(node) - 1);
}
示例3: CreateAtom
import javax.swing.tree.MutableTreeNode; //导入方法依赖的package包/类
/**
* Create the frame.
*/
public CreateAtom(final AlloyAtom beforeAtom) {
this.beforeAtom = beforeAtom;
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setTitle("Create Atom");
this.setBounds(100, 100, 450, 300);
this.getContentPane().setLayout(new BorderLayout());
this.contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
this.getContentPane().add(this.contentPanel, BorderLayout.CENTER);
this.contentPanel.setLayout(new BorderLayout(0, 0));
{
final MutableTreeNode univ = new DefaultMutableTreeNode("Univ");
this.tree = new JTree(univ);
this.tree.setBorder(new MatteBorder(1, 1, 1, 1, new Color(0, 0, 0)));
this.contentPanel.add(this.tree, BorderLayout.CENTER);
this.tree.setCellRenderer(new CellRenderer());
final List<MutableTreeNode> topElement = Utility.getTypeHierarchyForTree();
for (final MutableTreeNode mutableTreeNode : topElement) {
univ.insert(mutableTreeNode, univ.getChildCount());
}
final TreeNode root = (TreeNode) this.tree.getModel().getRoot();
this.expandAll(this.tree, new TreePath(root));
}
if (this.beforeAtom == null) {
final JPanel panel = new JPanel();
this.contentPanel.add(panel, BorderLayout.NORTH);
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
{
final JLabel lblNewLabel = new JLabel("Atom Name : ");
panel.add(lblNewLabel);
}
{
this.textField = new JTextField();
panel.add(this.textField);
this.textField.setColumns(30);
}
}
{
final JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
final JButton okButton = new JButton("OK");
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent arg0) {
if (CreateAtom.this.performFinish()) {
Visualization.getInstance(null).revalidate();
CreateAtom.this.disposeThis();
}
}
});
okButton.setActionCommand("OK");
buttonPane.add(okButton);
this.getRootPane().setDefaultButton(okButton);
}
{
final JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
CreateAtom.this.disposeThis();
}
});
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
}
示例4: leftShift
import javax.swing.tree.MutableTreeNode; //导入方法依赖的package包/类
/**
* Overloads the left shift operator to provide an easy way to add
* nodes to a MutableTreeNode.<p>
*
* @param self a MutableTreeNode
* @param node a node to be added to the treeNode.
* @return same treeNode, after the value was added to it.
* @since 1.6.4
*/
public static MutableTreeNode leftShift(MutableTreeNode self, MutableTreeNode node) {
self.insert(node, self.getChildCount());
return self;
}
示例5: putAt
import javax.swing.tree.MutableTreeNode; //导入方法依赖的package包/类
/**
* Allow MutableTreeNode to work with subscript operators.<p>
* <b>WARNING:</b> this operation does not replace the node at the
* specified index, rather it inserts the node at that index, thus
* increasing the size of the treeNode by 1.<p>
*
* @param self a MutableTreeNode
* @param index an index
* @param node the node to insert at the given index
* @since 1.6.4
*/
public static void putAt(MutableTreeNode self, int index, MutableTreeNode node) {
self.insert(node, index);
}