Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / Java - Creating a border in java

Author
Message
Riz
17
Years of Service
User Offline
Joined: 7th Dec 2008
Location:
Posted: 1st Sep 2009 18:43
Hi guys i was wondering how would i go about creating a border in java? I have images that descend from top to bottom and when they reach the bottom of the screen i want them to stay there and not continue to drop. How exactly would i go about doing that. I know that i need to create a boolean statement that will be checked to see if the condition has been met, but i am unsure of the logic required to do this. I appreciate any help on the matter. Thanks in advance
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Sep 2009 04:12
oh, javascript, not java as that's totally different.

I'm a little fuzzy on what you exactly want. You want an image to just float at the bottom of the screen regardless of where you scroll? Or do you want a simple border added around an image?

[url="http://www.nocleanfeed.com"][/url]
Riz
17
Years of Service
User Offline
Joined: 7th Dec 2008
Location:
Posted: 2nd Sep 2009 06:05
Basically what i want to try and do is have it like a tetris game. Basically in tetris when the blocks come down you rotate them until they reach the bottom of the screen. Once they reach the bottom of the screen they stay there and the next block comes down. What i want to try and do is that. Keep my image at the bottom of the screen while the next image falls down and not have my image go past the boundary line. Hope this makes sense
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 2nd Sep 2009 09:37
Would work as in any programming / scripting language handling logic; pseudocode:


Riz
17
Years of Service
User Offline
Joined: 7th Dec 2008
Location:
Posted: 3rd Sep 2009 00:44
Hey i am still having trouble if you or anyone could possibly take a look at my code and help figure out my problem id really appreciate it:

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Sep 2009 10:38 Edited at: 3rd Sep 2009 10:39
That looks like normal Java to me; not sure if it would run as a JavaScript at all.
Anyway, you only want the y-position in the last outcommented if-clause, as that is the only one that is relevant for determining the height. Also, you would probably want to subtract the rectangle's height from that, so that it stops as soon as it's bottom reaches the border, and not it's top.
Like so:


Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Sep 2009 18:54
He does want Java, not javascript (my mistake). Just his first explanation sounded to me like he wanted JS cause it didn't really make a whole lot of sense.


Ditch the call to paint() in the actionPerformed method, because what you're really calling is TimerAction.paint()

[url="http://www.nocleanfeed.com"][/url]

Login to post a reply

Server time is: 2026-06-10 09:32:26
Your offset time is: 2026-06-10 09:32:26