If the last page was currently showing in the display area, the button would turn red (see Figure 4) instead of green and clicking the button would have no effect.įor a variety of reasons that I won’t bore you with here, I have elected to use the Greenfoot IDE in this lesson. That button has turned green indicating that it is okay to click the button to turn to the next page. In Figure 1, the mouse (which doesn’t show in the screen shot) is touching the button on the right. The buttons on the left and right side of Figure 1 are the kind of buttons that you might see in a child’s educational game that could be used to allow the child to “turn a page” or to progress back and forth through different scenes or worlds. You can run the scenario online at that URL and I encourage you do so while you are reading this lesson. I have published an online version of this scenario named ArrowButton02 at the Greenfoot gallery (see Resources). (Note that the two buttons at the bottom are part of the Greenfoot runtime environment that was used to develop and test these buttons.) In this lesson, I will show you how to create and test a pair of buttons of the kind as shown on the left and right sides Figure 1. But, we’ll do the best we can to cover as many as we can. Obviously, we won’t be able to cover all of these GUI components in this lesson, or even in this series of lessons. The following list identifies some of the custom GUI components that may be needed if your software needs a custom GUI. Sometimes its easy to forget that despite the sophistication of the JavaBeans event model and the components that are included in the Swing API, a GUI is nothing more than a bunch of images rendered on the screen along with the ability to detect various mouse and keyboard operations in and among those images. You will find a consolidated index at General background information I recommend that you also study the other lessons in my extensive collection of online programming tutorials. Source code for the class named ArrowButtonManager02. Source code for the class named ArrowButton02. Responding to a click on the RightArrow button. Display red or green image on the button. The constructor for the RightArrow class. Beginning of the class named ArrowButtonManager02. Beginning of the class named ArrowButton02. The six arrow images used in the scenario Class diagram for scenario named ArrowButton02. I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the figures and listings while you are reading about them. In this lesson, I will introduce you to the methodology for creating your own custom GUI components using Greenfoot by creating a pair of buttons used to turn the pages in a Greenfoot scenario. That is what this tutorial lesson is all about. In those cases, you must get back to basics and either find an API of GUI components appropriate for the purpose, or develop the GUI components yourself. You certainly won’t want it look like a word processing or spreadsheet program. In that case, your will probably want the look and feel of the GUI to be based on the theme of the game. Or, your business may be writing game software for older children and adults. You will probably agree that the standardized Swing GUI components are not particularly appropriate for children in that age range. What if your business is writing educational software for children in the five to ten year age range. For example, what if your clientele has absolutely no appreciation for standardized GUI components and may not even be able to read. However, Swing and AWT components aren’t always appropriate. Most of us have come to appreciate the use of relatively standardized GUI components, often based either on the AWT or on Swing. We may make money when you click on links to our partners. content and product recommendations are editorially independent.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |