How to set up a simple gui based on jframe

Assignment Help JAVA Programming
Reference no: EM131945898

Computer Science Assignment: Java Programming

Program: First GUI

Throughout the semester, we have been working on command line applications. While the command line can be a powerful form of interacting with the computer, most modern applications have a graphical user interface, or GUI. This program will give you some initial experience making GUI applications with Swing.

Things you will learn

• How to set up a simple GUI based on JFrame
• Setting up listeners and responding to events
• Drawing simple shapes and images
• Dealing with mouse and mouse motion events

Directions

1. Write a GUI application in Java using Swing that has a three buttons and a drawing area. The buttons should be at the top of the window. The buttons should be labeled as "swap", "center", and your name.

2. Give the window an initial size of 800 x 600 pixels, and put your name in the menu bar.

3. The drawing area should cover the remainder of the window.

4. When it starts, the program should show an oval with your name in the center of it (that is not an image of an oval). Also, it should show an image of your choice read in from a file somewhere on the screen. The background of the drawing area should be a non-white color.

5. Pressing the "center" should cause both the the oval to move to the center of the window.

6. You must also be able to click and drag the oval with your name or the image around the screen independently with the mouse.

7. When you click the "swap" button, the oval and image should swap positions on the screen.

8. When the user presses the button with your name on it, the program should do something else not described in the assignment that is unique to your program, such as change the color of all the things you draw, switch the oval to be outlines instead of filled, or something like that.

9. As always, make sure the proper block comment is at the top of your main file with your name.

10. Once your program is working, pass it off directly to the instructor or TA. Also, turn in your code to D2L.

Suggestions

• Get the skeleton of your GUI working first. First get the buttons drawing properly, then go on to listen to and respond to events.

• Initially, hook up the event listeners so that they print something to the console when a button is pressed. That way you can know that your code is getting events.

• Make a subclass of JPanel called "DrawPanel" or something like that to draw the objects. Override the "paintComponent" method of this class. This class needs boolean variables to decide whether to draw the rectangle, oval, your name, and the special. It may also need other variables to indicate colors, positions of things, etc.

• You can measure a string using the FontMetrics class. This measures how much space (in pixels) the string will take when drawn. You would use this information to determine where to place the text and backing rectangle.

Reference no: EM131945898

Questions Cloud

Determining the technically for diaisomers : For Norbornene there are technically for diaisomers so why are only two (endo & eco-norborneol) the only ones considered?
What is the ph of the water solution : If 0.001 M of CO2 is introduced into a closed container which is full of pure water and has no headspace for air, what is the pH of the water solution
Is the no price change scenario a good choice and when : Scalper Inc. is trying to determine whether to give a $15 rebate, to cut the price to $8, or to have no price change on a software networking product.
Create a change request log that contains information : The project is moving along quite well, staying on schedule and within the budget. However, a severe storm is expected to go through your area.
How to set up a simple gui based on jframe : How to set up a simple GUI based on JFrame. Setting up listeners and responding to events. Drawing simple shapes and images.
How should project iterations be structured to ensure rapid : How should project iterations be structured to ensure rapid progress to completion, high quality, and efficient use of medical practitioner time?
Will a finished skateboard arrive at the destination : Is there a way that overall throughput can be increased by relocating emplyees to different stations inteh factory numbers vertically.
What is the total value of the firm if taxes ignore : BL Plastics is an all equity firm that has 27,000 shares of stock outstanding. The company has divided to borrow $46, 080 to buy out the shares of a deceased.
What value of k minimizes training set error for data set : What value of k minimizes the training set error for this data set? What is the resulting training error? Explain. Why might too small values of k also be bad?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd