ilumi kinoko

Greenhorn
+ Follow
since Jan 07, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by ilumi kinoko

Thank you Rob,
I changed it.

That's why my computer make the noise so loud
I thought that's my GPU's sound
12 years ago
hi guys,

My problem has been solved.
Thanks for Stephan van Hulst 's help

anyone who has similar problem can see the code at https://coderanch.com/t/533459/GUI/java/Having-two-paint#2419882

Thanks for JavaRanch and people who devotes to help here
12 years ago
Thank you Stephan!!
Thank you Rob!!

I would never get this done without your help.
I love this place!!!

Thank you again Stephan.
Thank you for your time and help

I feel Very best for completing the code, and understand how it works at the same time

Below is the finished code :
12 years ago
But the compiler told me this line is incorrect

can not find symbol:
drawImage(javax.swing.ImageIcon,int,int,MyCanvas)

I don't know what's wrong
12 years ago

Thank you Stephan

I know what you mean,
But can you tell me the type of "images"?
I thought it's arraylist at first.
But in drawimage it needs ....icon?
I am confused



12 years ago
Sorry for bad description

What i mean is when i press button1 it prints logo1
and shows:

please see the "1" as image icon.
then i press button 2,
then it shows :

where "icon 2"will get the previous x,y position.
and if I press 1 again
it shows :

and so on...

like

<----1
<-----12
<------121


What I want is preserve the previous icons while showing present icon.
but I dont know which function is proper to call

12 years ago
Thank you Stephan
The typo you point out annoys me all day

and Thank you again for let me really know how it works.

YOU ROCK!!

below is the code:



My last question is how can I let the image which i had printed remain?
Every time i use repaint(), the images just gone.

Please tell me thank you.
12 years ago
Thank you Jesper

the pressing button to show image and move problem has been solved.

Answer can see at https://coderanch.com/t/533459/GUI/java/Having-two-paint#2419882

moved to Java ยป Swing / AWT / SWT / JFace

And still has some other problems

like: when i use repaint(), the previous image will gone as it move.
what should I do if I want the previous image remain?

Hope you guys can help me there


Really Thank you
12 years ago
Sorry, i don't get it....

where should I put my MyCanvas class, the graph just won't show up.



I just can't find it
12 years ago
Thank you Stephan,

you are awesome!!

I would never solve the problem without your help even after ages.

can i ask you two more question?

if I want to use another button to show another image,
I have to create new class like ButtonPanel2 and MyCanvas2, right?
Or I just add button2 in ButtonPanel and let MyCanvas class to decide which one to draw?
if the former case is correct, what should i do if i want to share coordinate x and y?
if the latter case is correct, how to set condition to let paintComponent choose which one to draw?

the second question is if I want the previous images remain,
what should i do?
Should I use repaint() or use other function?

Thank you
12 years ago
hi there,

I have some problem on using paint

below is my code:



my first question is why cant i move the icon after i press the button?
it seems that it has already move to x =100 y =100 before i press
and when i press the button, it didn't work.


I also search some previous topic and find


Yes, generally, in Java, the reference to the screen's Graphics object (called "g" in this case) is not reliable outside of the paint() method.

Standard procedure is to do all of your drawing in the paint() method, or in methods that are called only by paint(). That drawing code should look at the state of your application to know what to draw.

For example, you could have your key press set a boolean variable. Then, when paint() did its thing, it would look at the variable to know whether or not to draw the image.

And you don't normally call paint() directly. As Svend said, you would usually call repaint().

- Jeff



my second question is how and where should i set the variable to control paint in my code
I tried and it just cant pass into paint method.

thank you
12 years ago

I have a problem

What should i do if I like to

1. Press the button

2. The image show at certain location

3. Press the same button

4. The image show again at x = x +50 with the original image remain?

I can not figure it out

what should i do in the



Any hint would be very helpful

please help me on this thank you
12 years ago
Thank you so much praneeth jayarathna

it works

I have new problem

What should i do if I like to

1. Press the same button

2. The image show again at x = x +50 with the original image remain?

I can not figure it out

please help me thanks
12 years ago
Hello everyone,

I have several pictures,
I want to add picture whenever I press the JButton.
Like:

1. (the board is empty)

2.button pressed (show a image)

3.press another button

4. and so on...


Even I press another button the previous images are still remain.
I want to do it on JFrame and on its certain area(I mean there is a certain area only images)
Can anybody give an example or direction?
Thank you
13 years ago
No need to reply, nice persons (no offended , please do not misunderstand)
I have already solved this problem by using thread

Thanks to Steve, who just show an URL and then let me learn and know how thread works.

13 years ago