0

Hello, i'm using a Jpanel, I am using an image as background . On top of that i want to put buttons on it. The problem is I cannot repostion the buttons? can anyone help me here!!??

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by zyaday
0

Hello, i'm using a Jpanel, I am using an image as background . On top of that i want to put buttons on it. The problem is I cannot repostion the buttons? can anyone help me here!!??

There's no reason to be shy. Post your code so we can help you out.

0

hi Zyaday,
using setBounds() method
first set the layout of panel as none.
syntax:

button_name.setBounds(int x,int y,int width,int height);

example:

JB_ClickMe.setBounds(20,25,150,20);
1

hi Zyaday,
using setBounds() method
first set the layout of panel as none.
syntax:

button_name.setBounds(int x,int y,int width,int height);

example:

JB_ClickMe.setBounds(20,25,150,20);

You could resort to absolute positioning, but in the event that the Panel is resized you may want to use a layout.

I'd suggest looking up the following in google--

Java class LayoutManager

--LayoutManager is really an interface, not a class... but nonetheless it will show you the multiple types of Layout Classes that implement the interface and will help you determine how you want your buttons to look on your Panel.

Votes + Comments
Good help done :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.