Bobby Marvikuan

Ranch Hand
+ Follow
since Mar 14, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
12
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bobby Marvikuan

Michael Dunn wrote:make a class (a very little class) - just a
frame and panel (for your drawing code).

make sure it demonstrates the same problem
then post that code.


Lol dunno this is what I get after decreasing
10 years ago
Hi
I have a class(very big) which draws an image using paintComponent method but when I am resizing the image disappears. Can anyone suggest me a way to prevent this? I cannot use method drawImage because it is looping through and draws each time a new square to make a crossword. So, if I would use it will draw each time a new Image is there a way to do that or no???
10 years ago

Maneesh Godbole wrote:Check out https://coderanch.com/how-to/java/BackgroundImageOnJPanel
You can use the same approach to have your custom painting instead of the image


OK thanks I see the point but if I want to add on my square smth. like JLabel will I able to do that if I am using this method with an image?
10 years ago
Hi there!
Can anyone help me to understand why my code does not working please it should draw a rectangle in the JFrame but ... it does not and I am stupid because I don't see why. so here is the code.


10 years ago

Tim Moores wrote:

Firstly,the first line of an output of the program below is The main thread dies here. Why it starting from there


Newly created threads #1 and #2 both sleep at the beginning, so it's natural to run the non-sleeping main thread. But even without that it's up to the JVM to schedule threads. You shouldn't expect thread X to start being executed before thread Y just because it was created earlier; it may work out that way (and probably will), but not necessarily so. You could insert print statements at the beginning of the run method to see when each thread starts to execute.

Second question, there are while(true) loop so, it should never end unless the exception is thrown but the program does not throws an exception. So, why it starts then executing this:new Thread (new SleepyThread(5, "1 ")).start();


I don't understand this question; can you rephrase it? What did you observe happening, and what were you expecting instead?

and the last question why it is doing more 2 thread than first is it because of the program says to or ... smth else?


Is it? It's pretty evenly distributed on my machine. Of course, thread #2 waits for a shorter time than thread #1 at startup, which explains the consecutive 2s at the beginning.


Thank you so much!
and second question was

while(true){
try { Thread.sleep(500);; } catch (InterruptedException e){System.out.print("I was interrapted"); }
System.out.print(msg+" ");
}


this loop should be endless isn't it? because true is not becoming false and there is no return statement in there??
10 years ago
Hello can anyone help me to understand multithreading I am not getting the point. Firstly,the first line of an output of the program below is The main thread dies here. Why it starting from there. Second question, there are while(true) loop so, it should never end unless the exception is thrown but the program does not throws an exception. So, why it starts then executing this:new Thread (new SleepyThread(5, "1 ")).start(); and the last question why it is doing more 2 thread than first is it because of the program says to or ... smth else? Thanks in advance!
10 years ago

Bobby Marvikuan wrote:Hello can anyone help with this code why the answer here is 17 but according to my logic it should be 8:( I am not getting that


Oh, I got that I was really stupid!
10 years ago
Hello can anyone help with this code why the answer here is 17 but according to my logic it should be 8:( I am not getting that
10 years ago
Hello. I am interested how to do this thing:
for e.g., I want to draw a square when the mouse stopped Dragging but is not released yet? I tried mouse pressed but it calls it only at the beginning. So, I have no idea, any help?
Cheers in advance!
10 years ago

Darryl Burke wrote:Why do you start the Timer inside a while(...) loop?


It is stupid I know but I have read in the API that it stops before starting doing smth. So, I thought this is what I need because it will stop every time the I "increase my zoom" but it does not change anything if I put it outside:(
10 years ago

Darryl Burke wrote:From your question, I'm assuming that you already know how to zoom, just not how to animate it. Use a javax.swing.Timer and change the zoom level over a period of time, calling repaint() each time.


here is my code first one does not run at all and the second one increase but very quickly(

10 years ago

Darryl Burke wrote:From your question, I'm assuming that you already know how to zoom, just not how to animate it. Use a javax.swing.Timer and change the zoom level over a period of time, calling repaint() each time.


Thanks for answering So, I should change zoom level inside the action performed method inside of action Listener of the timer or no? and a question what should I put inside that method if the answer is no. Cause I tried to play around with it and it did not do what I wanted it to(
10 years ago
Hello everybody. Does anybody have any ideas how to make animated zoom. What I mean by this is how to make zooming slowly showing how it is zooming not at once. Any ideas? Thanks.(:
10 years ago
Hello. Can you help me with my method... I have a panel that draws some image and I need to add there something like a zoombox which appears when the user drags the mouse when I am creating my box my original image disappears. I understand why but I don't see a way to save both image and box. May be you can help=/ Cheers in advance!
10 years ago