Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All to be done in Java Swing. The goal of this project is to create a simple GUI program. The Gui Interface needs to contain

All to be done in Java Swing. The goal of this project is to create a simple GUI program. The Gui Interface needs to contain 1 JLabel, and 4 Jbuttons The gui components need to be contained within a JFrame. Additionally a Jpanel should be used to hel control the layout of the buttons. Use a GridLayout for the layout manager. The buttons should be in a 2x2 grid, with the JLabel above it above it. Dont worry about the functionality of the buttons, its the establishing the positions of the components that is giving me the trouble. Here is the code I have so far.

I've excluded some of the fluff that I have in the actual file such as the button click windows and what not. All I need is the keys to be in a grid layout of | FLabel | |Uppercase Button| |Lowercase Button| |NewPhrase Button| | Reset Button |

import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.Insets; import java.awt.Label; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel;

/* HEADER********************************************************** * AUTHOR: * CONTACT: * FILE NAME: Mainframe.java * FILE DEPENDENCIES: Driver.java * FILE DESCRIPTION: window's properties * HEADER END****************************************************** */

//make the horizontal and vertical gaps 15 & 15 //System.out.println( changeCase.toUpperCase( ) ); //System.out.println( changeCase.toUpperCase( ) );

public class MainFrame extends JFrame {

JLabel stringHolder; JButton btnUpper; JButton btnLower; JButton btnNewPhrase; JButton btnReset; EchoUpperCaseClass btnEchoU; EchoLowerCaseClass btnEchoL; EchoGoToDefaultClass btnEchoD; JPanel lblHolder; JPanel btnHolder; public MainFrame(){ btnHolder = new JPanel(); lblHolder = new JPanel(); stringHolder = new JLabel("Hello World", JLabel.CENTER); btnUpper = new JButton("Uppercase"); btnEchoU = new EchoUpperCaseClass(); btnLower = new JButton("Lowercase"); btnEchoL = new EchoLowerCaseClass(); btnNewPhrase = new JButton("New Phrase"); btnReset = new JButton("Reset"); btnEchoD = new EchoGoToDefaultClass(); // adds panels to the window this.add(btnHolder); // this.add(lblHolder); // button instances & window echos btnHolder.add(stringHolder); btnHolder.add(btnUpper); btnUpper.addActionListener(btnEchoU); btnUpper.setPreferredSize(new Dimension(40,40));

btnHolder.add(btnLower); btnLower.addActionListener(btnEchoL); btnLower.setPreferredSize(new Dimension(40,40)); btnHolder.add(btnNewPhrase); btnNewPhrase.setPreferredSize(new Dimension(40,40)); btnHolder.add(btnReset); btnReset.addActionListener(btnEchoD); btnReset.setPreferredSize(new Dimension(40,40));

// window properties setTitle("Hello World"); setSize(1200,1200); setLayout(new GridLayout(2,2)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } }

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

Answered: 1 week ago

Answered: 1 week ago