Solved

Java clear part canvas

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

Title # Comments Views Activity
factorial example 4 47
java jdbc batch example 8 41
check java version using powershell 13 169
Eclipse for Java EE development 2 27
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

839 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