Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can i give a postion to a JLabel

Status
Not open for further replies.

Efa

Programmer
Jul 9, 2001
18
0
0
AU
Just wondering about jLabels & ScrollPanes.

Is it possible to give a position to a label. I have a few labels i want to postion. They just appear in my applet one after another. I want to put them on a new line. Is this possible?

I also have a scrollPane in my applet. Can i give it a certain position and a certain size?

If possible i want to do this without using the graphics paint() method.

Cheers,

Efa
 
not sure if you can an absolute position (e.g. using X and Y coordinates) without using a Graphics object.

You can try experimenting with a GridBagLayout layoutmanager which allows you to break the screen into rows and columns and then you can position your individual components by passing it the component and GridBagConstraints - these use X and Y coordinates relating to the rows and columns you have just specified when creating the manager, it is not a pixel by pixel screen coordinate.
 
It is possible, use null layout. You can do this:-

public void init()
{
setLayout(null);
...
Label lbl = new Label("Hello");
lbl.setBounds(new Rectangle(a,b,c,d));

add(lbl,null);
}

a - X position
b - Y position
c - length
d - width

You can use this for your JScrollPane too.

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top