• 0

JAVA GUI problem


Question

Hi there,

I've been coding a small Hotel Reservation app in Java-

it's basically a 6 button Main Menu with links to other frames.

I was wondering if anyone could help me find out how to load a frame when a button is clicked i.e. When the Make a Reservation main menu button is clicked, how do I load up the Make a Reservation panel?

I have tried to add an ActionListener to the button which does the showBookingFrame() but it doesn't work

Thanks in Advance

Link to comment
https://www.neowin.net/forum/topic/650049-java-gui-problem/
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Add an actionlistener to the button like this:

btnMakeReservation.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt) {
showBookingFrame();
}
});

And then at the bottom of your class add:

public void showBookingFrame() {
ReservationFrame resFrame = new ReservationFrame();
resFrame.setVisible(true);
}

  • 0

Hey everyone, thanks a lot for the speedy replies.

I think the actionlistener was not being called because the instance was not appearing.

I'm editting the code with what Smethead suggested. Currently here's My Current Coding.

It's all in the init() of the applet therefore I was quite confused on how to make the MakeBooking dialog appear once clicked.

Will update the code and get back ASAP

*Please ignore the comments in the code

  • 0

Woot! Got a frame to open once the button is clicked. Thanks everyone and SmetHead.

Is it advised to do the same for all the other buttons in the main menu?

I'll be creating the layout for the frame now

Just wondering - how do I create a button in the popped up frame to Close said frame?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.