Solved

Java clear part canvas

Posted on 2010-09-15
5
738 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now