Computer Science Canada Title Bar + Threads + embeding fonts, any ideas? |
Author: | aussilia [ Fri Sep 22, 2006 10:33 pm ] |
Post subject: | Title Bar + Threads + embeding fonts, any ideas? |
Hello, this is my first time posting on the java side of compsci! (I have migrated from Turing) After about 3 weeks and tons of hours learning Java, I have hit three main points that I am unable to understand/implement. The program I am writing is a copy of the matrix screen-saver (letters fall from top of screen) application. I have made an entire .java file that has double-buffer, and the code to make one line of varying length and characters fall from the top of the screen. problems: 1. Is there any way to make the title bar with the little cup go away (to get the full screen effect) either in the code or in making it into a .jar file? 2. I can make one line appear, but I need ~ 70 at the same time! Will the double buffers interfere with each other? I also plan to use the mouse (click on a character to freeze the entire screen); can I implement it in a "main thread" sort of thing? Or should I make another class and implement the first one?? Threads and making objects are very confusing for me so far ![]() ![]() 3. I have Arial Unicode MS on my computer, and I use this in my program to generate the Japanese and other characters needed, but other computers don't have it. Instead of asking others to download the font (which is pretty hard to find because it is Microsoft proprietary) is their a way to "bundle" the font with my program? Any help in any of these areas would be very very very appreciated. Sorry if the questions seem naive but other help I found wasn't much help in the area of applications. Thanks allot!!! |
Author: | [Gandalf] [ Sat Sep 23, 2006 2:57 pm ] |
Post subject: | |
1. You'll want to use a JWindow instead of using JFrame. 2. No idea what you're trying to say here, sorry. ![]() 3. Most likely. Just include the .ttf file with your program. Can't help you with any specific problems you might have, since I've never done it myself. |
Author: | aussilia [ Sat Sep 23, 2006 6:55 pm ] |
Post subject: | |
1. Thanks, exactly what i was looking for! ![]() 2. sorry if i was being unclear, but i think i have accidentaly found my own answer, explanation to come soon ![]() 3. What do you mean by "include"? in the compilation? in the java program itself?? ![]() i searched for include but none of the things mentioned had much to do with what i am trying to do. Has anyone ever done anything along these lines? Thanks so much to Gandalf for the help! |
Author: | [Gandalf] [ Sat Sep 23, 2006 8:25 pm ] |
Post subject: | |
No problem. ![]() What I meant by include was simply have the .ttf file in the same folder as the .java/.class file. There is a chance that you will then simply be able to use it like any other font already on that computer, or you might have to do something more like installing it to C:/Windows/Fonts for Windows. |
Author: | Aziz [ Mon Sep 25, 2006 3:29 pm ] |
Post subject: | |
Wow, 3 weeks, either you're skipping ahead and doing too advanced stuff, or you've REALLY put a lot of effort into this. I'm going to go ahead and assume the ladder, and point you to the Full-Screen Exclusive API of Java, check out the Java Tutorial for it: http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html |
Author: | aussilia [ Tue Oct 03, 2006 12:09 pm ] |
Post subject: | |
So the final problem i have left is integration. I have code that lets me generate a line of characters and make them fall down the screen. The only problem is that i need about 60 of these lines to make the matrix effect. What i have been trying to do is to make one class that just generates a line, the call it from another class that makes the backbuffer adn screen. Am i on the right track? What i am basicaly looking for is something like the turing fork statment. (you can make a for loop and use the fork statment as many times as you want). Is this way that I described the best way? *pseudo code* letters class make a line of random characters ex: fadsfafafe add to the y value of the position of the line of characters (they fall down) screen class make the backbuffer and screen call letters 60 times [/b] |
Author: | Aziz [ Tue Oct 03, 2006 10:43 pm ] | ||||||||
Post subject: | |||||||||
Turing's fork is (supposed to be) the threads of other languages. Except, thread's work. In java, this is the class Thread. Check out the API and the Java Tutorials on it. Quickie about threads. The constructor: [syntax="java"]public Thread(Runnable r)[syntax] Any object can be Runnable. So, say you make a Timer class, and implement the interface 'Runnable'. Runnable requires the 'run()' method. So you have a class:
But I don't think threads are you're problem here. You need say, 10 lines of text (for example). Use an array:
Then set all the elements of lines to an empty string ("") (via a for loop). Make a while loop:
I think that's pretty much all you'll need.... |
Author: | aussilia [ Fri Oct 06, 2006 4:10 pm ] |
Post subject: | |
The trick is that i want all 60 of my lines to fall at the same time, i dont think your second sugestion code does that, but the first might! Thanks! |
Author: | HellblazerX [ Fri Oct 06, 2006 6:51 pm ] |
Post subject: | |
No, I don't think you understood what Aziz was trying to tell you. You should not be using threads for something this simple. Threads are designed for programs that have components that need to run separate of each other. Yours does not, or doesn't need to anyways. Even if you did implement threads in your program, your 60 lines of letters still won't be falling down at the same time, they'll only seem like it, because of the speed at which the computer processes at. Aziz's second method works just fine, if not better than the method involving threads. |
Author: | aussilia [ Fri Oct 20, 2006 11:18 pm ] | ||
Post subject: | |||
I have finally finished stage one of my project (personal). This will let you all know what i was talking about during this entire time. A big kudos to Aziz for seeing my madness and pointing me in the right way. (I have come far along since my last post, threads do seem like a stupid idea) More improvments coming soon! (If you see boxes instead of characters, you need to have Arial Unicode MS installed)
|
Author: | Aziz [ Sun Oct 22, 2006 11:04 pm ] |
Post subject: | |
Whoa, triple post ![]() |