Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is setBounds and how do I use it?

Tags:

java

setbounds

I cannot find anything on setBounds, what it is for, or what its function actually is. Could someone clear me up on this? Thanks so much!

like image 777
JeremyF Avatar asked Oct 16 '13 22:10

JeremyF


People also ask

How do you use setBounds?

The setBounds() method needs four arguments. The first two arguments are x and y coordinates of the top-left corner of the component, the third argument is the width of the component and the fourth argument is the height of the component.

What is the correct syntax of setBounds () method in Java Swing?

setBounds() method needs four arguments. The first two arguments are the x and y coordinates of the upper left corner of the component, the third argument is the width of the component, and the fourth argument is the height of the component.

How does Java's BorderLayout work?

A border layout lays out a container, arranging and resizing its components to fit in five regions: north, south, east, west, and center. Each region may contain no more than one component, and is identified by a corresponding constant: NORTH , SOUTH , EAST , WEST , and CENTER .

What is the use of setVisible in Java?

The setVisible(true) method makes the frame appear on the screen. If you forget to do this, the frame object will exist as an object in memory, but no picture will appear on the screen.


1 Answers

You can use setBounds(x, y, width, height) to specify the position and size of a GUI component if you set the layout to null. Then (x, y) is the coordinate of the upper-left corner of that component.

like image 73
tianz Avatar answered Sep 24 '22 01:09

tianz