So i ve managed to create different shapes in my GUI window. But how would i go about deleting a certain shape or line from the window when I press delete on my GUI screen?

Recommended Answers

All 2 Replies

Draw over it with the background color.

I managed to solve this myself but thanks to masijade for his help.
What you have to do is delete the value from the binary search tree and then update the tree.
Here's the code that I have which is attached to a "Delete" button on my GUI:

JButton delete = new JButton("Delete");
delete.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
                {			
	        deleteIt(checkTree());	// Get item to be deleted
				
		Shapes widget;		// Update the BST with the info
		widget = new Shapes();

		myFrame.add(widget);
		myFrame.validate();
				
		}
	});

myFrame is actually the name of the frame for my GUI. The shapes class draws all the shapes that I need.

Hope this helps anyone that needs it. If you need more help send me a message :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.