Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using multiple layouts in a frame (Java) I am trying to achieve this: The grid needs to be in GridLayout The menu needs to be

Using multiple layouts in a frame (Java)

I am trying to achieve this:

image text in transcribed

The grid needs to be in "GridLayout"

The menu needs to be in "BorderLayout"

The bottom panel needs to be in "FlowLayout"

The right panel needs to be in "BoxLayout"

This is the code I have:

import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextPane; import javax.swing.border.TitledBorder;

public class BUi {

JFrame frame; JMenuBar menuBar; JMenu boggle; JMenuItem newGame; JMenuItem exit; JPanel gridPanel; JButton[][] gridDice; JPanel boxPanel; JScrollPane scrollText; JTextPane enterText; JLabel displayTime; JButton shakeDice; JPanel wordPanel; JLabel createWord; JButton submitWord; JLabel playerScore;

public void Components(){ frame = new JFrame("Boggle"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); menuBar = new JMenuBar(); boggle = new JMenu("Boggle"); boggle.setMnemonic('B'); newGame = new JMenuItem("New Game"); exit = new JMenuItem("Exit"); boggle.add(newGame); boggle.add(exit); menuBar.add(boggle); wordPanel = new JPanel(); createWord = new JLabel(); submitWord = new JButton("Submit Word"); playerScore = new JLabel(); wordPanel.setBorder(BorderFactory.createTitledBorder("Current Word")); createWord.setBorder(BorderFactory.createTitledBorder("Current Word")); playerScore.setBorder(BorderFactory.createTitledBorder("Score")); wordPanel.setLayout(new FlowLayout()); wordPanel.add(createWord); wordPanel.add(submitWord); wordPanel.add(playerScore); gridPanel = new JPanel(); gridPanel.setLayout(new GridLayout(3,3)); gridPanel.setBorder(BorderFactory.createTitledBorder("Boggle Board")); gridDice = new JButton[3][3]; for(int i=0; i

Boggle Boggle Boggle Board Current Word Current Word Enter Words Found Time Left 3:00 Shake Dice Score Submit Word

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_2

Step: 3

blur-text-image_3

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

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago