Results 1 to 4 of 4

Thread: Layout Problem.....

  1. #1
    vastest
    Guest

    Layout Problem.....

    How can I position Panels at specified locations in a frame. I know about BorderLayout, this layout is not suitable for my needs. I want to be able to, if possible, position panels at specified X Y coordinates.

  2. #2

  3. #3
    vastest
    Guest

    Post only 4 java master

    thanks....for reply
    but I have already used that method and required objective is completed.

    I'm again in trouble.
    problem is I'm added a panel in applet and panel is moving in all direction on mouse move.
    I'm added mouselistener in applet and check as:
    code: in init() method of JApplet.

    JPanel mp=new JPanel();
    getContentPane().setLayout(null);
    getContentPane().add(mp);
    mp.setLocation(-100000,-100000);
    mp.setSize(50000000,50000000);

    addMouseMotionListener(new MouseMotionAdapter(){
    public void mouseMoved(MouseEvent me){
    if(me.getX()>1000){

    mp.setLocation(mp.getX()-200,mp.getY());
    mp.setSize(mp.getWidth()+200,mp.getHeight());
    }

    else if(me.getX()<100){
    mp.setLocation(mp.getX()+200,mp.getY());
    mp.setSize(mp.getWidth()-200,mp.getHeight());

    }
    else if(me.getY()<100){
    //if(mp.getY()<vs.getY()){

    mp.setLocation(mp.getX(),mp.getY()+200);
    mp.setSize(mp.getWidth(),mp.getHeight()-200);
    //}
    }
    else if(me.getY()>650){

    mp.setLocation(mp.getX(),mp.getY()-200);
    mp.setSize(mp.getWidth(),mp.getHeight()+200);
    }

    }
    }
    );

    but I want add mouselistener in panel.
    [mp.addMouseMotionListener();]

    problem is I can't define if condition as above.

    please help me....

    again thanks for study my problem.

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    So you are basicaly having trouble nesting your if's? As it stands now it looks like you have a mouse listener for your applet not the panel.

Posting Permissions

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



Click Here to Expand Forum to Full Width