John Corkrend

Ranch Hand
+ Follow
since Oct 27, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by John Corkrend

Hi everyone, I am currently writing a paper for school that relates to computer programming and am having trouble finding sources. I'm posting this here as I feel you guys will know how to help, if this needs to be moved then I'm sorry, but I've always gotten good feedback from the people on these forums.

Anyways I need to find sources for my topic, I can do that fine, but the thing is they are not reliable sources so my teacher would not accept them. If any of you could point me in the right direction of where to do my research that would be greatly appreciated.

Some of the topics I need to research are how computers handle code, what affects the processes of a computer, and discussing code in general. For the last one I believe I will talk about compiled vs. interpreted languages.
11 years ago

Rob Camick wrote:You need to use a Timer to update the label at a specified interval. Read the Swing tutorial on How to Use Timers.

In your Start button you would start the Timer and in your Stop button you would stop the Timer and update the label with the final difference. When the Timer fires you update the label with the difference in time.



Well that didn't really answer my question, you just explained how to use a timer, the whole starting and stopping thing, which I already have done. What I need to know is how to show the current time, if you run my application you see that the time shows up at the end. I want you to be able to see it while the time is going up. I believe I have to use a loop for this but am not quite sure on how to do it.
11 years ago
I have built an application that is a simple stopwatch with a start/stop button. All it does is simply gets the time it is when you hit start and the time you hit stop, and find the difference. That works and all but the number of seconds shows up at the end after you hit stop. I want to make it so that when you hit start you see the time going up from 0. I have tried this with a for loop and with a while loop but wasn't quite able to figure it out. I have a variable 'isRunning' that changes from true to false depending on whether the clock is running or not. Here is my code so far.


11 years ago
Well you posted this from a computer so I assume you have one unless it was at a library or something. And if you have a computer you can start programming, even if it's not a very good computer. I do most of my programming on a laptop with dual core processors and 4gb of ram. Most modern computers will be able to handle programming applications such as eclipse. If you don't want to download that you could also use Notepad to start out with, type up some basic programs and run them from command line.

As for not knowing what to merge when you code, simply do what feels right. If you feel a program is better off with 1 class instead of 3 then go for it. But the best and only way to learn programming is to just do it. Get the tools necessary to make programs and start.
11 years ago
I have made the changes and was able to move around the oval, but once I changed the fillOvals method to the one you suggested only one oval showed up and it did not move. Here is the updated code if you want it.

Also if you could explain the whole "int left, int top" stuff in the fillOvals method I would appreciate it as I don't quite understand it.

11 years ago
Ok well that did do the trick, they now show up as two different colors, but it conflicts with a different part of my code. Here is the full program, but the part that doesn't work now is lines 22-45.Without calling the repaint method it doesn't show the movement of the oval. In the console it is still printing that the X/Y value changed but it is not showing it on screen. Would there be a way to have them as two different colors and still allow one of them to move like I have here.
11 years ago
Ok well I made the changes but now both of the images just show up as black. And I forgot to mention that I have code that allows you to move one of the pieces so that they are not one right over the other, but I didn't think that was relevant code to changing the color.
Here is my code with some changes

11 years ago
How would I get it so that these two different images show up as two different colors? I have tried adding .setColor to the paint method, but then it flashed back and forth between the two colors that I wanted. These are my paint and paintComponent methods. But I don't really understand them, what is the difference between the two.

11 years ago
Well my code is in my first post, I didn't feel like reposting that because I only made one change. But I can repost it if someone wants me to.
11 years ago
Please use code tags in the future so that your code is easier to read.








Besides that in your logic you should use .equals instead of ==. But I am not the most experienced so I may be wrong, if someone else on the forum would make sure that is right.
If there are any other errors please ask.
11 years ago
Well now there are on errors, but it still doesn't do what I want. It prints out the number 0 even if I've pushed a few buttons. Also it opens up a new window every time I type in "stats", is there a way to create an instance of the class without opening up a new window from that class every time.
11 years ago
So in my program there are two classes. One that is just a window with a text box, and the other that is a window where the game movement takes place. Now what I really want from this program is for the 'TextInput' class to have the variable 'clickCount'.

I have tried creating an instance of the OvalMovement class, but when I try to access the variable it says this on line 43 "Syntax error, insert "AssignmentOperator Expression" to complete Expression"
I don't know quite what to do here. And also how would I create an instance of a class without it creating the window all over again. For example if I take out line 43 in 'TestInput', the program will run but it will open a new window. I understand that it's just doing what it's told, creating an instance of the class, and that class is the window.






11 years ago

John Corkrend wrote:Ok that fixed it, I see how it created the window when the program started. Now another thing I want to ask is why does it close both windows when I only want to close the text one? Is there a way where I can close one window and still leave the other one open?



Ok I just tried some new things out with text window, and found that if I do instead of it works as I want it to. Leaving one window open while closing the other.
11 years ago
Ok that fixed it, I see how it created the window when the program started. Now another thing I want to ask is why does it close both windows when I only want to close the text one? Is there a way where I can close one window and still leave the other one open?
11 years ago
The first thing I have to ask is does this program have user interaction? Or is everything going to be done in the code and we just see a finished product?
And also how experienced are you in java, do you have a solid understanding of methods, objects, and classes?
But I still don't quite see what you're trying to accomplish here. Maybe someone else can be of more help.
11 years ago