Java代写 | Model-View-Controller in Java | CS代写 | Java GUI窗体程序

Java代写/Java窗体程序/Java GUI/Java Graphics/Java MVC/Java Layout Managers

本次的assignment要求使用Java GUI编写一个画图程序

Assignment 2: Model-View-Controller in Java

Due Wed, June 20 at 5:00 PM
Starter code and instructions are here (a2starter.html).
A demo of the reference implementation is available online (


In this assignment you’ll demonstrate your understanding of MVC by implementing a sketching program that lets users draw on the screen using a mouse. Your drawing application will support standard drawing features (e.g. stroke width, multiple colors, window resizing) as
detailed below. Additionally, your users can use a scrubber to scroll back or forward through the steps used to create a drawing.

Learning Goals

  • MVC
  • Widget Library
  • Layout Managers
  • 2D Graphics

This is a rough mockup that illustrates the features that you will implement, and the layout that you must use.


Your doodle program will have the following attributes:

  1. It will include a menu bar with a file menu. Within file, you will have options to save and load doodles, to create a new doodle, and to exit the program. Be sure to prompt the user to save before overwriting any changes they’ve made when creating a new doodle, loading a doodle or exiting the program.
  2. It will have a palette on the left hand side supporting, at a minimum, color selection and stroke thickness/width (you should display the colors and lines graphically, not as text!). You should support at least 6 colors in this color palette. The last button in the color palette should invoke a JColorChooser to select a custom color. You should also have some way to indicate which colour is currently selected (whether from the color chooser, or the color palette e.g. a panel showing the current color). When you choose a color, that color will be used for any new strokes that you make. Past stroke colors should not be altered and should always be rendered appropriately (i.e. color is part of your model).
    Similarly for width.
  3. The main area of the screen is a canvas that supports drawing by using mouse strokes(i.e. drawing one or more lines using the mouse). Mouse down begins a stroke, mouse dragged defines the body of a stroke, and mouse up defines the end of a stroke, using the appropriate color and line width (see above). On mouse up, the playbar (timeline) ticks must be updated such that there is a tick that correponds to the *end* of each stroke.
  4. At the bottom of the screen, there will be playback controls (JButtons with icons) and a playback bar (JSlider). Initially, there are no ticks on the bar. Each time a stroke is completed a tick is added to the bar.
  5. File saving and loading must be supported using a JFileChooser. You can save in either text or binary formats (you can just serialize an object, for example). Your JFileChooser should filter out just your supported data files (i.e. you should save using a file extension, and filter to show just those files).
  6. In drawing, if you scrub back, some of your later strokes will vanish on the display. At this point, if you begin drawing, the non-displayed strokes should be removed from your model and new strokes that you create will be appended to the visible strokes on the display. If you begin drawing partway through a previous stroke, that stroke will truncated to just include points up to the new point where you start drawing (and the scrubber will update based on your new line length). This is a simple form of undo/redo, as in on undo, if you start acting, future events (post-undo point) are deleted from the application model.
  7. Finally, we expect a dynamic layout. The canvas should be fully accessible regardless of the size of the window, by resizing itself to fit the available space. The color chooser and stroke chooser need to expand and contract based upon available space; how the layout changes is a visual design decision left to you. At the bottom of the screen, playback buttons must be positioned approximately as indicated, and the slider should expand and contract appropriately to fill available remaining space. You may set a “reasonable” minimum size (e.g. 400 X 300, 200 X 150, etc.). There should be no limit to the maximum size.


1.0. Initial release.
1.1. Specified number of colors in the color palette.
1.2. Added requirement to show currently selected color.
1.3. Removed the suggestion that ticks had to be evenly spaced.


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:dmxyzl003 工作时间:全年无休-早上8点到凌晨3点