This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Take a look at Java documentation forFontclass Here is the sample code.
2. How do you create a countdown timer ?
Well, there are several ways to do it. The simplest one I found is to create a seperate thread which will keep checking for the input every second and will take action if no input was supplied in specified time. [ November 04, 2005: Message edited by: Deep Narsay ]
1. In what way do you (Koert Kopbeen) mean to change the font? The class only works if you are using Swing or something similar. If you're talking in an output file or a system out, there is no such way. Alternatively, if it is HTML, you just insert HTML codes.
2. You don't need to create a second thread if you don't mind the application pausing while waiting for input (so if you want to do other things while waiting 10 seconds, you need a second thread, but it doesn't sound like you do). In this case you can just call Thread.sleep() every second (or half second if you'd prefer) for 10 seconds and check keyboard input each iteration.
3. Deep Narsay, how is that 3 answers? >< [ November 04, 2005: Message edited by: Scott Selikoff ]
Originally posted by Scott Selikoff: 3. Deep Narsay, how is that 3 answers? ><
[ November 04, 2005: Message edited by: Scott Selikoff ]
Koert said "I have three questions"
I replied "I have three answers"
Now, as soon as he asks third question, I will shoot the answer.
Joined: Oct 30, 2005
Ja sorry I made a mistake - just two questions.
I am referring to normal Strings in Java. I have seen that it is possible to change the font (I use Ready to Program - the normal font of the code is Courier New: I believe that is the regular font across platforms) in Buttons etc, but I want a certain part of the String to stand out. How do I do that - let's say change a part of the program to Times New Roman or something.
The timer: is there not maybe a method in Java to do it? I would like to display the counted time in the program. How do I do that?
OK, so maybe I do have a third question. Again about Strings: how do I make a certain part of text flicker?
And a fourth one: Whenever I use PrintWriter of the java.io class, it erases the contents of the .txt file completely. No matter what I type in there, it erases it. Any ideas? Anyone had this same problem?
PS: Mag dinge vir julle net goedgaan - anders as met myself wannneer dit kom by Rekenaarstudie HG!