0

Hello wonderful people!

I've relatively new to this java and I'm practicing by creating an online booking system with multiple JFrames (I've heard this could be an issue).

In short, I want to retrieve the value of this jComboBox and display it in a text area on a separate frame. The problem is: How do I undergo this?

private void filmSelecterActionPerformed(java.awt.event.ActionEvent evt) {                                             
if (filmSelecter.getSelectedIndex() == 0)
continueButton.setEnabled(false);
 else {
continueButton.setEnabled(true);
}

Second JFrame

private void jQty2ActionPerformed(java.awt.event.ActionEvent evt) {                                      

}                                     

private void reviewButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             

    // -------Review Order Button----
    double Qty1 = Double.parseDouble(jQty1.getText());
    double Qty2 = Double.parseDouble(jQty2.getText());
    double Qty3 = Double.parseDouble(jQty3.getText());
    double Qty4 = Double.parseDouble(jQty4.getText());

    double total, subTotal, ticket1, ticket2, ticket3, ticket4;

    String adultPrice = String.format("%.2f", adultprice);
    subTotal1.setText(adultPrice);

    String studentPrice = String.format("%.2f", studentprice);
    subTotal2.setText(studentPrice);

    String childPrice = String.format("%.2f", childprice);
    subTotal3.setText(childPrice);

    String seniorPrice = String.format("%.2f", seniorprice);
    subTotal4.setText(seniorPrice);

    ticket1 = Qty1 * adultprice;
    ticket2 = Qty2 * studentprice;
    ticket3 = Qty3 * childprice;
    ticket4 = Qty4 * seniorprice;

    //subTotal
    String sub1 = String.format("£%.2f", ticket1);
    subTotal1.setText(sub1);

    String sub2 = String.format("£%.2f", ticket2);
    subTotal2.setText(sub2);

    String sub3 = String.format("£%.2f", ticket3);
    subTotal3.setText(sub3);

    String sub4 = String.format("£%.2f", ticket4);
    subTotal4.setText(sub4);

    subTotal = ticket1 + ticket2 + ticket3 + ticket4;

    // Total ticket price
    String subTotalAll = String.format("£%.2f", subTotal);
    jTotalPrice.setText(subTotalAll);

    // Receipt
    String Title = "\tGreenwich Peninsula Cinema\n\n\n";
    String Movie = "Movie Name: " + "\n";
    //String MovieDay = "Movie Day" + filmSelecter.getSelectedItem() + "\n";
    String MovieTime = "Movie Time: \n";
    String Barrier = "=========================================" + "\n";
    String Adult = "Adult:" + subTotal1.getText() + "\nNumber of Tickets: " + Qty1 + "\n";
    String Student = "Student:" + subTotal2.getText() + "\nNumber of Tickets: " + Qty2 + "\n";
    String Child = "Child:" + subTotal3.getText() + "\nNumber of Tickets: " + Qty3 + "\n";
    String Senior = "Senior:" + subTotal4.getText() + "\nNumber of Tickets: " + Qty4 + "\n";
    String Thanks = "\n\n\tEnjoy the film!";
    String ShowReceipt = Barrier + Title + Movie + /*MovieDay +*/ MovieTime + Barrier + Adult + Student + Child + Senior + Thanks + "\n" + Barrier;

    filmReceipt.append(ShowReceipt);
}                                                             

I hope this helps in anyway.

iHugTreez
  • 7
  • 1
  • 1
    Yes, do read: [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/questions/9554636). As for how to pass information from one object to another, which is really all you're trying to do, create public methods that one object can call to either pull information from another object, or that one object can use to push information into the other object. Swing GUI's are no different from non-GUI classes in this regard. – Hovercraft Full Of Eels Nov 27 '16 at 17:46
  • Thanks for replying! Is there anyway you can show how to do this? I'm extremely sorry if I'm being a pest. – iHugTreez Nov 27 '16 at 17:55
  • Welcome to stackoverflow. This isn't a code writing site. We can help you with a specific problem. You need to make an attempt on your own and ask for help with an error or an incorrect output. – curt Nov 27 '16 at 18:26
  • Ah, apologies curt. Honest mistake on my end, once more I'm extremely grateful Hovercraft Full Of Eels. – iHugTreez Nov 27 '16 at 18:44

0 Answers0