| |

VerySource

 Forgot password?
 Register
Search
View: 848|Reply: 5

Questions about JPanel?

[Copy link]

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-4 08:30:01
| Show all posts |Read mode
I used the drawLine function on JPanel to draw a series of lines. Now I want to clear these lines. How do I clear them?
Reply

Use magic Report

0

Threads

39

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-1-4 11:51:01
| Show all posts
Draw another line with the background color
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-4 13:27:01
| Show all posts
However, if I have already drawn a lot of lines, I cannot always record the same path. Are you doing reverse order operations?
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-4 23:12:02
| Show all posts
clearRect () clears everything.
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-5 15:24:01
| Show all posts
How to call it? Where is it called?
Reply

Use magic Report

1

Threads

20

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-1-5 16:57:01
| Show all posts
clearRect
public abstract void clearRect (int x,
                               int y,
                               int width,
                               int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface. This operation does not use the current paint mode.
Beginning with Java 1.1, the background color of offscreen images may be system dependent. Applications should use setColor followed by fillRect to ensure that an offscreen image is cleared to a specific color.


Parameters:
x-the x coordinate of the rectangle to clear.
y-the y coordinate of the rectangle to clear.
width-the width of the rectangle to clear.
height-the height of the rectangle to clear.





for example:
g.clearRect (0, 0, 400, 400);
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list