Hej guys!
I have a little problem with layouting Swing components. I just need to add JTree: tree to the UPPER corner of JScrollPane: scrollpanesearch, and 4 buttons to the BOTTOM corner. What I have now is JTree: tree on the LEFT, and 4 buttons on the RIGHT (see Figure attached to this post).
JScrollPane scrollpanesearch = new JScrollPane(new TreeEditTest(), ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollpanesearch.setBounds(20, 40, 300, 400);
public TreeEditTest() {
// construct tree
TreeNode root = makeSampleTree();
model = new DefaultTreeModel(root);
tree = new JTree(model);
tree.setEditable(false);
// add scroll pane with tree to content pane
JScrollPane scrollPane = new JScrollPane(tree,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(scrollPane);
// make button panel
JPanel panel = new JPanel();
addSiblingButton = new JButton("Add Sibling");
addSiblingButton.addActionListener(this);
panel.add(addSiblingButton);
addChildButton = new JButton("Add Child");
addChildButton.addActionListener(this);
panel.add(addChildButton);
deleteButton = new JButton("Delete");
deleteButton.addActionListener(this);
panel.add(deleteButton);
editButton = new JButton("Edit");
editButton.addActionListener(this);
panel.add(editButton);
add(panel);
}
Any advises will be appreciated. Plz help.