Untitled
unknown
java
2 years ago
1.5 kB
8
Indexable
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyCafe extends JFrame {
private JTextArea orderListTextArea; // Displays the list of orders
private JTextField totalTextField; // Displays the total price
private JTextField payTextField; // User inputs the payment amount
private JTextField balanceTextField; // Displays the balance after payment
private JButton printReceiptButton; // Button to print the receipt
private JButton newOrderButton; // Button to start a new order
private double totalPrice = 0.0; // Holds the total price of the current order
public MyCafe() {
// Initialize the UI components
initializeUI();
// Setup the event listeners for buttons and text fields
setupListeners();
}
private void initializeUI() {
// Set the main frame properties
setTitle("MyCafe Ordering System");
setSize(700, 350);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
// Create and configure the UI components
orderListTextArea = createTextArea();
totalTextField = createTextField(false);
payTextField = createTextField(true);
balanceTextField = createTextField(false);
printReceiptButton = createButton("Print Receipt", false);
newOrderButton = createButton("New Order", true);Editor is loading...
Leave a Comment