Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Default A QUESTION U CAN ALL ANSWER, EXCEPT ME, (if not, come and sit with me lol)

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Default A QUESTION U CAN ALL ANSWER, EXCEPT ME, (if not, come and sit with me lol)

    We studied basic stupid java, where all you did was draw pictures with "sop" statements, and program, HARDCODED, "Now what if i entered $10 for that item, how much change would i get back"

    waiiiit... "now wat if i went into your code and changed that value"

    lol and alot more junk, but i decided, THANKFULLY, to teach myself on my own.

    Unforunatly, the bad thing about java is so far, as i can see (and this is from a consistent perspective) that theres very little, if not, ZERO ground for beginngers, all the stuff isn't dum'd down for you (take for example when i google questions, they simply refer to a class page on sun's website, but even then, with the crappy examples, i (AND ALOT OF OTHER PPL << just self reassuring message to myself to sustain my pride hehe) cannot understand it.

    Something even worse is, i live in canda, in the sense, we do "turing", more precisely, is viable only in ontario (which is a province in a country called canada) In that language, it dums it down for you alot, and so the commands are easy, but u cant get too far, in terms of building complexity. What this means is that there things i can do on there, but not on here, java.

    Which is why, this is my first time ever asking for help in java, for if i cant solve the problem below, il just resort to building programs upon a dead language, that reigns through the population of approx 10,000.

    First off all i dont understand this swing dum stuff, i tried googling for many days, and all of that other dum stuff, as u may have noticed, its called dum, cause i dont understand it yet, itl become smart stuff, when i do though .

    Either way; starting off from 0.. scratch...ground zero...or just zero... of java... i got this far.. (p.s i dont even know wat a project is, or how to call class's from each other LOL, all i know is wat a class file is)

    i somehow, learned 1 command, and OMG from that one command, i used my brain (left side of it only, the right side (artistic) doesnt mind sleeping)

    that one command, was

    Robot myRobot = new Robot();

    and from there, i learned 3 other sub commands,

    myRobot.mouseMove(x,y);
    myRobot.delay(time);
    myRobot.mousePress(InputEvent.BUTTON1_MASK)
    myRobot.keyPress()

    if u know more than me, then just know im better than u at everything else.. hehe

    either way, i need help

    i wrote several programs with these 3 commands of line, and set up em in methods and etc (i dont know how to return a value from method)... but one program, made me stuck..

    if i can figure it this one problem i have, THEN OMG il learn 4 commands, thats like omg 4^4= 64 possibilities! dudes, i can make so many programs out of that, that does sick things,

    either way before i go and ask, read this, i made several programs, using those 3 lines of commands, that all u have to do is click, and it directs your mouse (MOVES AND TYPES FOR YOU) like a robot! to the designated place, ie you wanna chk ur bank account or face book? itl do it for you. and then i wanted to make another that would take you to your lets stay bank page, BUT THIS IS WAT I HARD TIME ABOUT! AND IL ASK THIS PROBLEM IN ANOTHER POST, but was essentially was supposed to take picture of screen (i googled many times, for many hours, tryin to find a viable solution for this) and then from there, it interprets the image u just saved, and goes and does logic by analyzing pixel by pixel, and in a simple page, without u havin to go access your bank page, it puts it u p for you, like in a small click of hitting the .exe file, it tells you....
    either "OMG YOU OWE MORE MONEY AS YOUR BALANCE IS NOW:: X AT THIS TIME Y" and etc lol

    but I like i said in bracket above, this is for another thread, as i feel already POWERFUL with 3 commands i know, so its okay atm. ACtually i feel powerful only because i hope someone will help me increase the number to 4!!

    Either way my present problem is very simple, very difficult for me, (tried googling SO MANY TIMES, GOOGLE FEELS SERVER DRAG FROM MY ABUSE)

    ;; kk serious now;;;

    i wrote up a simple program, (IF U KNOW WHERE TO APPLY IT, YOU WILL FEEL POWERFUL LIKE ME, ELSE :rockon: )

    it goes like this, i hard coded mouse coordinates, meaning i hard coded values for where the mouse should move to, and it clicks on those coordinates;

    seems simple;

    this is wat i want,

    i want the program to run like this; this is the 4th command im asking for;

    when the USER (right) CLICKS ANYWHERE! it saves that mouse coordinate, or its x, y values.

    if that was easy for you, then write me up a program thats in a loop, that prints out the mouse coordinates, because to find specific coordinates of mouse, i hav to guess and check lol;

    it should go like this;

    start with endless loop;
    for (int x= 1000; x>0; x--) {

    (your command on how u retrieve mouse coordinates here)

    System.out.println("X value is " + X + "Y value is " + Y);

    }
    this holds 2nd priority, what holds first priority is the person who can teach me 1 more command line, that will put me up to 4, on how to save mouse coordinates when they click.

    ive gotten very far in java, and i like it because it requires logic, but it makes me very upset, when i have syntax issues, il nEVER EVER EVER EVER EVER EVER EVER EVER EVER EVER ask, or be man enough to ask, if the issue is a logic one only, because then i shouldnt be programming java in the first place duhhhh....
    i rmember when i was writing my 3k line code, i was alone, lonely, with my logic, teacher wouldnt help me, and so, only excuse i can use for help is when its a syntax issue, lik its not my fault i dont kno my abc's! DUH!

    either way thanks...

    ps that 3k line code program, omg if u saw it, it would of amazed you!!!!!!!!!!!!!!!!!


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Default A QUESTION U CAN ALL ANSWER, EXCEPT ME, (if not, come and sit with me lol

    Ok, so that was alot and it was difficult to read because of spelling and stuff. So, what I got out of that was that you need some help learning how to do some things in Java.

    One of those things seemed to be how to get the Coordinates of a Right Mouse Click. Correct?

    If so, I'll step you through it.

    The first step to getting the mouse click is creating a Mouse Listener. In Java, Listeners are used as the main method to communicate with user interactions. All Buttons, all Keystrokes, and all Mouse Clicks need Listeners. So, we want to create our own MouseListener. To do this, we need to use the MouseListener Interface.

    In the MouseListener Interface (on the link provided), we have 5 methods. mouseClicked(MouseEvent e) is used when the mouse is clicked. mouseEntered(MouseEvent e) is used when the mouse enters a component. mouseExited(MouseEvent e) is used when it exits a component. mousePressed(MouseEvent e) is used when the mouse button is press. mouseReleased(MouseEvent e) is used when the mouse button is released. Very self-explanatory.

    So, for our MouseListener we will want to use the mouseClicked(MouseEvent e) method, and that seems to be it. For this method, it will take in a MouseEvent. The MouseEvent will tell us alot of things, but we really just want to know what Mouse Button was pressed. So we use SwingUtilities.isRightMouseButton(MouseEvent anEvent) to find out if it is a Right Mouse Button click.

    So, we have now lined out what we need to do. Now, we have to do it. It is my preference to create a new class to do this, but you can do it however way you would like.

    To create a new MouseListener class, we say this:
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    import javax.swing.SwingUtilities;
    public class MouseEventDemo implements MouseListener 
    {
        public void mousePressed(MouseEvent e) 
        {
            if(SwingUtilities.isRightMouseButton(e))
            {
                System.out.println("Mouse Right Button Clicked");
                System.out.println("X Coord= "+e.getX()+" Y Coord= "+e.getY());
             }
        }
     
        public void mouseReleased(MouseEvent e) 
        {
        }
     
        public void mouseEntered(MouseEvent e) 
        {
        }
     
        public void mouseExited(MouseEvent e) 
        {
        }
     
        public void mouseClicked(MouseEvent e) 
        {
        }
    }

    This will print out Mouse Right Button Clicked and the Coordinates of the click every time the right button is clicked. BUT, we still have to attach it to something for it to work. So we just attach it to our Frame and we should be good.

    Add this code to your main. It will create a 500x500 frame and attach the MouseListener to it. Now whenever you Right-Click in that frame, it should print out.
    MouseListener listener = new MouseEventDemo();
    JFrame frame = new JFrame("Frame");
    frame.setSize(500,500);
    frame.addMouseListener(listener);
    frame.setVisible(true);


    I got all of this information from a few simple Google Searches. The code hasnt been compiled, but I assume it will work.
    Last edited by aussiemcgr; July 26th, 2010 at 02:14 PM.

  3. #3
    Member
    Join Date
    Jun 2010
    Posts
    48
    Thanks
    12
    Thanked 2 Times in 2 Posts

    Default Re: Default A QUESTION U CAN ALL ANSWER, EXCEPT ME, (if not, come and sit with me lol

    Actually if you are doing that on learning purpose, I'd say forget it and go learn java from the get-go.

    (One good way I can suggest you is go to youtube, type "thenewboston java" and click the first video. There is like 86 video chain. If you do it, you will thank me.)

  4. #4
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default Re: Default A QUESTION U CAN ALL ANSWER, EXCEPT ME, (if not, come and sit with me lol

    "...first off all i dont understand this swing dum stuff..."

    How ironic.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Default A QUESTION U CAN ALL ANSWER, EXCEPT ME, (if not, come and sit with me lol


  6. #6
    Member
    Join Date
    Feb 2010
    Posts
    81
    Thanks
    18
    Thanked 1 Time in 1 Post

    Default Re: Default A QUESTION U CAN ALL ANSWER, EXCEPT ME, (if not, come and sit with me lol

    Not sure if you still want this but I got bored and decided to make one for you

    import java.awt.MouseInfo;
    public class MouseLocation2 {
    	public static void main(String args[]){
    		try{
    			while(true)
    			{
    				Thread.sleep(100);
    				int MouseXValue = MouseInfo.getPointerInfo().getLocation().x;
    				int MouseYValue = MouseInfo.getPointerInfo().getLocation().y;
    				System.out.println("("+MouseXValue+", "+MouseYValue+")");
    			}
    		}catch(Exception e){};
    	}
    }

    It'll print out the coordinates every 100 milliseconds.

Similar Threads

  1. [SOLVED] Problem with a tutorial program(Adding the answer of two squared numbers together)
    By Melawe in forum What's Wrong With My Code?
    Replies: 20
    Last Post: April 7th, 2010, 09:03 AM
  2. Arrays.equals not returning correct answer.
    By Anyone in forum Collections and Generics
    Replies: 2
    Last Post: February 11th, 2010, 10:12 AM
  3. get proxy settings from the default system browser
    By reguapo in forum Java Networking
    Replies: 0
    Last Post: January 15th, 2010, 08:43 AM
  4. Default Access (package access) confusion
    By gauravrajbehl in forum Java Theory & Questions
    Replies: 1
    Last Post: November 18th, 2009, 04:11 AM