Solved

Java clear part canvas

Posted on 2010-09-15
5
756 Views
Last Modified: 2013-11-23
Hi all

I'm new to Java and learning

If I was to clear the canvas I would use removeAll()

how can I remove objects only from the bottom half of my canvas and specify the x y of what part I want to clear

Thanks
0
Comment
Question by:markavo
  • 3
5 Comments
 
LVL 26

Expert Comment

by:ksivananth
ID: 33689034
you need to provide the impl,

1. travese all the components in the canvas
2. compare the co-ordiante of the components in the canvas against your x, y
3. if it is after that, remove that component
0
 
LVL 37

Expert Comment

by:zzynx
ID: 33689208
>> specify the x y of what part I want to clear
Why would you want to do that?

When I read this, I think you're working a bit unusual.
That's why I ask you the previous question.

If I know what components I need to remove at some point in time, I would keep references to them.
Then to remove them I can simply call

remove( getMyComponent1() );
remove( getMyComponent2() );
...
remove( getMyComponentN() );
0
 

Author Comment

by:markavo
ID: 33695631
Hi

Thank you , can you give me an example please how i would reference for example

GRect rect = new GRect (x,y, height, width) ;
add(rect);

so rect holds a new Grect

this would remove the object ---- remove(rect);

How would i pass the reference through to methods so i can remove objects from within a method and call remove(rect)

help appreciated
0
 
LVL 37

Accepted Solution

by:
zzynx earned 250 total points
ID: 33699111
>> How would i pass the reference through to methods so i can remove objects from within a method and call remove(rect)

GRect rect = new GRect (x,y, height, width) ;
add(rect);

....

yourMethod1(rect);
...
yourMethod2(rect);

with

private yourMethod1(GRect rect) {
   ....
   remove(rect);
   ....
}

and

private yourMethod2(GRect rect) {
   ....
   remove(rect);
   ....
}
0
 
LVL 37

Expert Comment

by:zzynx
ID: 33723881
Thanx 4 axxepting
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question