Question: Here is my code down below and what i need is the picture package concerticket; import javax.swing. * ; import java.awt. * ; import java.text.SimpleDateFormat;

Here is my code down below and what i need is the picture
package concerticket;
import javax.swing.*;
import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class TicketSystem {
public static void main(String[] args){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
JFrame frame = new JFrame("Welcome to Ashley Theater");
frame.setSize(800,600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Header label
JLabel headerLabel = new JLabel("Kormassa Theater");
headerLabel.setFont(new Font("Arial", Font.BOLD, 20)); // Set font size and style
headerLabel.setHorizontalAlignment(SwingConstants.CENTER); // Center align the text
// Add a JLabel with an ImageIcon to display the image
ImageIcon imageIcon = new ImageIcon("theater.jpg");
JLabel imageLabel = new JLabel(imageIcon);
JButton createAccountButton = new JButton("Create Account");
JButton loginButton = new JButton("Login");
JButton cancelButton = new JButton("Cancel");
createAccountButton.addActionListener(e ->{
CreateAccountWindow createAccountWindow = new CreateAccountWindow();
createAccountWindow.setVisible(true);
});
loginButton.addActionListener(e ->{
LoginWindow loginWindow = new LoginWindow();
loginWindow.addLoginListener(new LoginListener(){
@Override
public void onLogin(String username){
loginWindow.dispose(); // Close the login window
MainInterface mainInterface = new MainInterface(username);
mainInterface.setVisible(true); // Show the main interface window
}
});
loginWindow.setVisible(true);
});
cancelButton.addActionListener(e ->{
System.exit(0);
});
// Panel for the buttons at the bottom
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
buttonPanel.add(createAccountButton);
buttonPanel.add(loginButton);
buttonPanel.add(cancelButton);
// Add the headerLabel, imageLabel, and buttonPanel to the frame
frame.setLayout(new BorderLayout());
frame.add(headerLabel, BorderLayout.NORTH);
frame.add(imageLabel, BorderLayout.CENTER);
frame.add(buttonPanel, BorderLayout.SOUTH);
frame.setVisible(true);
}
});
}
static class MainInterface extends JFrame {
public MainInterface(String username){
setTitle("Welcome,"+ username +"!");
setSize(800,600);
setLocationRelativeTo(null); // Center the window on the screen
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel welcomeLabel = new JLabel("Welcome,"+ username +"!");
welcomeLabel.setFont(new Font("Arial", Font.BOLD, 20)); // Set font size and style
welcomeLabel.setHorizontalAlignment(SwingConstants.CENTER); // Center align the text
JButton logoutButton = new JButton("Logout");
logoutButton.addActionListener(e ->{
dispose();
LoginWindow loginWindow = new LoginWindow();
loginWindow.setVisible(true);
});
JPanel panel = new JPanel(new BorderLayout());
panel.add(welcomeLabel, BorderLayout.NORTH);
panel.add(logoutButton, BorderLayout.SOUTH);
getContentPane().add(panel);
// Display theater sections and allow selection
displayTheaterSections();
}
private void displayTheaterSections(){
List sections = new ArrayList>();
sections.add(new TheaterSection("Stage Side", 60.00,80.00,150));
sections.add(new TheaterSection("Main Floor", 40.00,60.00,280));
sections.add(new TheaterSection("Balcony",20.00,30.00,250));
JPanel mainPanel = new JPanel(new BorderLayout());
// Create a panel for the image
ImageIcon theaterSectionImage = new ImageIcon("theater_section.png");
JLabel imageLabel = new JLabel(theaterSectionImage);
JPanel imagePanel = new JPanel();
imagePanel.add(imageLabel);
// Create a panel for the options
JPanel optionsPanel = new JPanel(new GridLayout(0,1));
Here is my code down below and what i need is the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!