Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2011
    Location
    Belgium
    Posts
    25
    Rep Power
    0

    Default positioning on java applet

    Hey i was just wandering about this,

    if you want to position an element on a java applet with the paint class you have to give some x and y coördinates with the figure you won't to draw for example a rectangle but this also applies for a button.

    I know you can use certain lay-outs and I don't want to use .swing or a user interface.
    I want to make them myself. (the hard way)

    My question is very simple, In this case I have to guess where my x and y coordinates on the applet are.

    for example 0,0 is the top left corner but isn't there a tool or a grid that show me the exact position of all these coordinates, because that would be very handy for drawing figures. If it doesn't exist andu have to guess, practice by examples can somebody tell me why?

    Thank you very much!

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,267
    Rep Power
    25

    Default Re: positioning on java applet

    Is this just an academic question or do you a problem you are trying to solve?
    If its a coding problem, post your code and your questions.

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: positioning on java applet

    Quote Originally Posted by The original stinger View Post
    I know you can use certain lay-outs and I don't want to use .swing or a user interface.
    I want to make them myself. (the hard way)
    Why in Gosling's name are you trying to avoid using layouts? That's not the way to go.

    Quote Originally Posted by The original stinger View Post
    My question is very simple, In this case I have to guess where my x and y coordinates on the applet are.

    for example 0,0 is the top left corner but isn't there a tool or a grid that show me the exact position of all these coordinates, because that would be very handy for drawing figures. If it doesn't exist andu have to guess, practice by examples can somebody tell me why?
    Think about this- those coordinates are pixels. So if you had a grid that showed you the exact position of each pixel, you'd actually just have a big black rectangle. Note that this wouldn't be hard to code by yourself, but you'd have to come up with a reasonable grid resolution (10 pixels? 25?). Or you could use a MouseListener to find useful coordinates. But avoiding layouts is a classic novice mistake. Don't do it. Use a layout.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Join Date
    Dec 2011
    Location
    Belgium
    Posts
    25
    Rep Power
    0

    Default Re: positioning on java applet

    Quote Originally Posted by Norm View Post
    Is this just an academic question or do you a problem you are trying to solve?
    If its a coding problem, post your code and your questions.
    It's just an academic question. I know layouts like border layout and gridbaglayout exist and I do use them. But when you make websites you have te possiblety to use some firefox addons like a ruler that shows the exact pixels, I was wondering if you can do the same in Java with some tool to get the x and y coordinates that are part of your applet. Because now i have to guess my coordinates and i ddon't like that guessing part.

    (applet created in netbeans and not running in a webbrowser as an example)

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,267
    Rep Power
    25

    Default Re: positioning on java applet

    What GUI builder are you using? I'd think it would have the mouse's x,y display.

  6. #6
    Join Date
    Dec 2011
    Location
    Belgium
    Posts
    25
    Rep Power
    0

    Default Re: positioning on java applet

    Applet in java netbeans without gui help. just a panel or lay-out to draw in... (we must work like that)

  7. #7
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: positioning on java applet

    Quote Originally Posted by The original stinger View Post
    Applet in java netbeans without gui help. just a panel or lay-out to draw in... (we must work like that)
    Did you read my reply? If you want a grid, it's trivial to draw a grid. Or you can just use a MouseListener. Things like this are probably so trivial that it's easier to just write it than it is to look for a program that does it for you.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: positioning on java applet

    If you're looking to report the mouse position, use a MouseMotionListener#mouseMoved and obtain the coordinates form the MouseEvent.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,267
    Rep Power
    25

    Default Re: positioning on java applet

    I think the OP is looking for how to use his IDE.

Similar Threads

  1. A componenet positioning problem
    By apprerntice in forum AWT / Swing
    Replies: 10
    Last Post: 07-22-2011, 07:53 PM
  2. Positioning items with GridBagConstraints
    By jchinson in forum AWT / Swing
    Replies: 4
    Last Post: 07-04-2011, 11:17 PM
  3. Vertical box and positioning
    By aborgeld in forum New To Java
    Replies: 9
    Last Post: 04-01-2011, 07:33 PM
  4. Positioning using setBounds
    By thayalan in forum AWT / Swing
    Replies: 4
    Last Post: 04-28-2009, 01:59 AM
  5. panel positioning
    By shwein in forum New To Java
    Replies: 4
    Last Post: 09-09-2008, 05:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •