473,562 Members | 2,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Button location randomization

6 New Member
Hello I am new to java and doing simple programs such as information input forms, and i was wondering what the code would be to setLocation a button to move randomly through out the form.
Jan 29 '08 #1
14 7917
r035198x
13,262 MVP
Hello I am new to java and doing simple programs such as information input forms, and i was wondering what the code would be to setLocation a button to move randomly through out the form.
You'll need to be more specific. e.g by "form" do you mean JFrame, JPanel or an HTML form?
Jan 29 '08 #2
helpme09
6 New Member
welll i am working in Jbuilder currently, and i am trying to set this up under the mouseEntered
Jan 29 '08 #3
BigDaddyLH
1,216 Recognized Expert Top Contributor
Why do you want a button to move randomly? If you are new to Java, I'd recommend staying away from GUI programs until you get some programming chops.
Jan 29 '08 #4
helpme09
6 New Member
i am currently a student in a JAVA programming class, i don't have a particular reason for wanting a button to move randomly across my program other than to be of an annoyance, is it possible to set up the code for the button to move randomly under the mouseEntered code?
Jan 30 '08 #5
r035198x
13,262 MVP
i am currently a student in a JAVA programming class, i don't have a particular reason for wanting a button to move randomly across my program other than to be of an annoyance, is it possible to set up the code for the button to move randomly under the mouseEntered code?
I'm not sure what you mean by the "under the mouseEntered code" part but you can move buttons around a bit depending on where the button is. A more helpful exercise is to draw a button(or image) on a Canvas and do some animation to move it around randomly.
Jan 30 '08 #6
helpme09
6 New Member
this is the code i was talking about

public void mouseEntered(Mo useEvent e)

is there any code that can go in this area that when the mouse enters the area of a button that the button moves to a random location.
Jan 30 '08 #7
BigDaddyLH
1,216 Recognized Expert Top Contributor
this is the code i was talking about

public void mouseEntered(Mo useEvent e)

is there any code that can go in this area that when the mouse enters the area of a button that the button moves to a random location.
What part is the problem? The random element or the moving?
Jan 30 '08 #8
helpme09
6 New Member
the random element, i don't know how to set up the random element, can you tell me how?
Jan 30 '08 #9
r035198x
13,262 MVP
the random element, i don't know how to set up the random element, can you tell me how?
Have a read at the java.util.Rando m class.
Jan 30 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
7544
by: Skip Hollowell | last post by:
I am working on a menu bar for a site, and am using buttons in the bar (because the customer wants to use accessKeys for each selection, apparently it is too much work to click on them with a mouse, but I digress) It seems that the longer the text is in a button, the more padding there is around that text in the button, thus making the...
11
1421
by: terti | last post by:
Hi there, newbie here. appologies if this is OT. (DOM based) I have a button defined in the html as follows: <input name="btnPay" value="Continue with payment" onclick="document.location='LoadPayment.asp?TPID=23448&RGID=7'" type="button"><br>
4
2596
by: Arif Çimen | last post by:
Hi to everybody, I have chnged a button text in design mode. But After compiling and executing the program the text of the button do not change to new value. Any Ideas? Thaks for helps.
18
2937
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead. If you do have any ideas I would really like to hear them. Thanks Colin - 0 - 0 - 0 - I want a glorified popup/context menu on a button that...
5
5412
by: Wonder | last post by:
How can I create or use the msgobx to show a message without a default button. The user has explicity to click on the button, so the msgbox closes it. Thanks,
1
1850
by: JHawk24821 | last post by:
I am building a simple card matching game where the user picks two buttons on a form out of a group of buttons in an attempt to find a match. I have already taken care of the randomization needed to make each game different, but I can't figure out how to check to see if the cards match. Pseudocode:when any one of a group of buttons is...
2
933
by: RobAMacAF | last post by:
I am making it that when they click the form it adds a button. Sometimes however if they click to close to another button then it makes them overlap. Is there any easy way to tell if the buttons over lap or not? I was thinking of making a function that will run and return true or false if they overlap or not. The buttons are all Size 30,30. My...
0
1010
KalariaNitya
by: KalariaNitya | last post by:
Hello All, in windows application(vb.net) i have one button control i want to relocate that button on Second button's click event. means old location is:184, 111 i want new location :59, 375 but when i set on second button
1
2883
by: =?Utf-8?B?UmljaA==?= | last post by:
I placed a button on a form menustrip for the purpose of causing the horizontal scrollbar of my form to appear so that I can access controls outside of the form's current view (the controls are further to the right of the form than the form's default width - which may take up the entire screen for some users). The form contains panels which...
0
7658
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7940
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6228
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5479
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5198
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3609
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1192
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.