problem with background image and buttons

Hi all,

i'm currently trying to design an interface for an hotel management system. The problem that i am getting is that i cant display my background picture and put four buttons on it.... I have succeeded only in displaying my background picture and having only a button displayed at the "south" border of the applet.

Can anyone help me out in solving this problem please?

Here is my code:

public static void main(String[]args)

{

JFrame frame=new JFrame("Super Hotels");

Container contentPane=frame.getContentPane();

Icon icon=new ImageIcon ("laplaya.jpg","Super Hotels");

JLabel lab=new JLabel(icon);

JScrollPane pane=new JScrollPane(lab);

contentPane.add(pane);

JButton b1=new JButton("Hotel Management");

b1.setToolTipText("Click here for Hotel Management!");

frame.setSize(550,400);

frame.show();

}

[908 byte] By [mparfait_2007a] at [2007-11-26 22:51:08]
# 1
i forgot a line after the b1.settooltiptextcontentPane.add(b1.BorderLayout.SOUTH);
mparfait_2007a at 2007-7-10 12:12:56 > top of Java-index,Desktop,Core GUI APIs...
# 2

how do you want your buttons aligned?

If its what I am guessing your want, try:

JPanel southPanel = new JPanel(new FlowLayout());

southPanel.add(button1);

southPanel.add(button2);

southPanel.add(button3);

southPanel.add(button4);

contentPane.add(southPanel,BorderLayout.SOUTH);

Nethera at 2007-7-10 12:12:56 > top of Java-index,Desktop,Core GUI APIs...
# 3
yeps but cant they be aligned on the background picture?
mparfait_2007a at 2007-7-10 12:12:56 > top of Java-index,Desktop,Core GUI APIs...
# 4
o, are you trying to say that the southPanel blocks out the picture?if so, southPanel.setOpaque(false);
Nethera at 2007-7-10 12:12:56 > top of Java-index,Desktop,Core GUI APIs...
# 5
ok thanks dude, i'll try it out and let you knowthanks a lot;-)
mparfait_2007a at 2007-7-10 12:12:56 > top of Java-index,Desktop,Core GUI APIs...
# 6
works real fine thanks a lot
mparfait_2007a at 2007-7-10 12:12:56 > top of Java-index,Desktop,Core GUI APIs...
# 7
glad I could help
Nethera at 2007-7-10 12:12:56 > top of Java-index,Desktop,Core GUI APIs...
# 8

can i ask another question pls...

i'm getting stuck with the buttons linked with my other forms...can anyone help?

I mean when i click on the button it should open the other form...e.g:specified in another class..

The main interface was created in "primary.class" file and i created the second form in "room.class"

mparfait_2007a at 2007-7-10 12:12:56 > top of Java-index,Desktop,Core GUI APIs...
# 9
http://java.sun.com/docs/books/tutorial/uiswing/events/actionlistener.htmlpublic void actionPerformed(ActionEvent e){room.openDialog();}
Nethera at 2007-7-10 12:12:56 > top of Java-index,Desktop,Core GUI APIs...
# 10
thanks Nether:-)you're a crackhave a good week dude
mparfait_2007a at 2007-7-10 12:12:56 > top of Java-index,Desktop,Core GUI APIs...