|
-
Jun 18th, 2002, 05:04 AM
#1
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.
-
Jun 18th, 2002, 10:10 AM
#2
Dazed Member
You can use setLocation(x,y) or setLocation(Point p)
-
Jun 18th, 2002, 11:53 PM
#3
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.
-
Jun 19th, 2002, 12:46 AM
#4
Dazed Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|