From 6b7f7eee1104301da5bf92b063daa2f314e2c7e0 Mon Sep 17 00:00:00 2001 From: Asaad Dadoush Date: Wed, 9 Dec 2020 01:26:32 +0300 Subject: [PATCH] Add Action for ViewRoutes --- src/EventControll.java | 47 ++++++++++++++++++++++++++++++++++++++++++ src/MakkahCity.java | 8 +++++-- 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/EventControll.java diff --git a/src/EventControll.java b/src/EventControll.java new file mode 100644 index 0000000..01e773f --- /dev/null +++ b/src/EventControll.java @@ -0,0 +1,47 @@ +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import java.awt.BorderLayout; +import javax.swing.JPanel; +import java.awt.Font; + +public class EventControll { + + private JFrame frame; + private JLabel lblNewLabel; + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + EventControll window = new EventControll(); + window.frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + public EventControll() { + initialize(); + } + + private void initialize() { + frame = new JFrame(); + frame.setBounds(100, 100, 450, 300); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JPanel panel = new JPanel(); + frame.getContentPane().add(panel, BorderLayout.CENTER); + + lblNewLabel = new JLabel(); + lblNewLabel.setFont(new Font("Rockwell", Font.PLAIN, 16)); + panel.add(lblNewLabel); + frame.setVisible(true); + } + + public void setData(Object A) { + lblNewLabel.setText(A.toString()); + } +} diff --git a/src/MakkahCity.java b/src/MakkahCity.java index 7c82dfd..ed59290 100644 --- a/src/MakkahCity.java +++ b/src/MakkahCity.java @@ -147,6 +147,10 @@ public class MakkahCity { btnViewRoutes.setFont(new Font("Rockwell", Font.PLAIN, 16)); btnViewRoutes.setBackground(new Color(9,9,9)); btnViewRoutes.setForeground(Color.white); + btnViewRoutes.addActionListener(e -> { + EventControll t = new EventControll(); + t.setData(stdRoutes[0]); + }); JButton btnViewBuses = new JButton("View Buses"); btnViewBuses.setBounds(1384, 75, 184, 29); @@ -1046,5 +1050,5 @@ public class MakkahCity { } } lblDate.setText(currenttimeManager.getCurrentTime().toString()); -} -} \ No newline at end of file + } + } \ No newline at end of file