Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java GUI swing and awt package game_project; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.TextArea; import javax.swing.JButton; import javax.swing.JFrame; import

In Java GUI swing and awt

package game_project; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.TextArea; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; public class Game_Project { JFrame window; Container con; JPanel titleNamePanel, startButtonPanel, mainTextPanel, buttonPanel, btPanel; JLabel titleNameLabel; Font titleFont = new Font("Times New Roman", Font.PLAIN, 50); Font normalFont = new Font("Times New Roman", Font.PLAIN, 30); JButton startButton, button1, button2, button3, button4, button5, bt1, bt2; JTextArea mainTextArea; TitleScreenHandler tsHandler = new TitleScreenHandler(); TitleScreenHandler1 tsHandler1 = new TitleScreenHandler1(); TitleScreenHandler2 tsHandler2 = new TitleScreenHandler2(); TitleScreenHandler3 tsHandler3 = new TitleScreenHandler3(); public static void main(String[] args) { new Game_Project(); } public Game_Project(){ window = new JFrame(); window.setSize(800, 600); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().setBackground(Color.black); window.setLayout(null); window.setVisible(true); con = window.getContentPane(); titleNamePanel = new JPanel(); titleNamePanel.setBounds(100, 100, 600, 150); titleNamePanel.setBackground(Color.black); titleNameLabel = new JLabel("STRATEGIC PLAN GAME"); titleNameLabel.setForeground(Color.white); titleNameLabel.setFont(titleFont); startButtonPanel = new JPanel(); startButtonPanel.setBounds(300, 400, 200, 100); startButtonPanel.setBackground(Color.black); startButton = new JButton("START"); startButton.setBackground(Color.black); startButton.setForeground(Color.white); startButton.setFont(normalFont); startButton.addActionListener(tsHandler); titleNamePanel.add(titleNameLabel); startButtonPanel.add(startButton); con.add(titleNamePanel); con.add(startButtonPanel); } public void CreateGameSreen(){ titleNamePanel.setVisible(false); startButtonPanel.setVisible(false); buttonPanel = new JPanel(); buttonPanel.setBackground(Color.black); buttonPanel.setBounds(20, 50, 924, 70); con.add(buttonPanel); button1 = new JButton("Vision & Mission"); button1.setBackground(Color.black); button1.setForeground(Color.white); button1.setFont(normalFont); buttonPanel.add(button1); button2 = new JButton("Values"); button2.setBackground(Color.black); button2.setForeground(Color.white); button2.setFont(normalFont); buttonPanel.add(button2); button3 = new JButton("Priorities"); button3.setBackground(Color.black); button3.setForeground(Color.white); button3.setFont(normalFont); buttonPanel.add(button3); button4 = new JButton("Competitive Advantage"); button4.setBackground(Color.black); button4.setForeground(Color.white); button4.setFont(normalFont); buttonPanel.add(button4); button5 = new JButton("Goal"); button5.setBackground(Color.black); button5.setForeground(Color.white); button5.setFont(normalFont); buttonPanel.add(button5); button1.addActionListener(tsHandler1); } public class TitleScreenHandler implements ActionListener { public void actionPerformed(ActionEvent event){ CreateGameSreen(); } } public void Vision_Mission(){ buttonPanel.setVisible(false); btPanel = new JPanel(); btPanel.setBackground(Color.black); btPanel.setBounds(20, 50, 924, 70); con.add(btPanel); bt1 = new JButton("Vision"); bt1.setBackground(Color.black); bt1.setForeground(Color.white); bt1.setFont(normalFont); bt1.addActionListener(tsHandler3); btPanel.add(bt1); bt2 = new JButton("Mission"); bt2.setBackground(Color.black); bt2.setForeground(Color.white); bt2.setFont(normalFont); bt2.addActionListener(tsHandler2); btPanel.add(bt2); }

public class TitleScreenHandler1 implements ActionListener{ public void actionPerformed(ActionEvent event){ Vision_Mission(); } } public void Mission(){ btPanel.setVisible(false); mainTextPanel = new JPanel(); mainTextPanel.setBounds(100, 100, 600, 250); mainTextPanel.setBackground(Color.black); con.add(mainTextPanel); mainTextArea = new JTextArea("An engaged and responsive university, meeting the needs of stakeholders " + "through excellent education, applied research, innovation and service."); mainTextArea.setBounds(100, 100, 600, 250); mainTextArea.setBackground(Color.black); mainTextArea.setForeground(Color.white); mainTextArea.setFont(normalFont); mainTextArea.setLineWrap(true); mainTextPanel.add(mainTextArea); } public class TitleScreenHandler2 implements ActionListener{ public void actionPerformed(ActionEvent event){ Mission(); } } public void Vision(){ btPanel.setVisible(false); mainTextPanel = new JPanel(); mainTextPanel.setBounds(100, 100, 600, 250); mainTextPanel.setBackground(Color.black); con.add(mainTextPanel); mainTextArea = new JTextArea("A premier technological university known for knowledge " + "creation, innovation and entrepreneurship."); mainTextArea.setBounds(100, 100, 600, 250); mainTextArea.setBackground(Color.black); mainTextArea.setForeground(Color.white); mainTextArea.setFont(normalFont); mainTextArea.setLineWrap(true); mainTextPanel.add(mainTextArea); } public class TitleScreenHandler3 implements ActionListener{ public void actionPerformed(ActionEvent event){ Vision(); } } } Question:

1. Is the code above please may you put a ScrollBar or ScrollPane so that if I put many things I would scroll down and may you put also the back button in every page so that I can go back in a previous page?

note: when you are running the code maximize the window that will appear.

in java GUI swing and awt

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions