Chapter 14. A Very Graphic Story: Getting Gui
Face it, you need to make GUIs. If youâre building applications that other people are going to use, you need a graphical interface. If youâre building programs for yourself, you want a graphical interface. Even if you believe that the rest of your natural life will be spent writing server-side code, where the client user interface is a web page, sooner or later youâll need to write tools, and youâll want a graphical interface. Sure, command-line apps are retro, but not in a good way. Theyâre weak, inflexible, and unfriendly. Weâll spend two chapters working on GUIs and learn key Java language features along the way including Event Handling and Inner Classes and lambdas. In this chapter, weâll put a button on the screen, and make it do something when you click it. Weâll paint on the screen, weâll display a JPEG image, and weâll even do some (crude) animation.
It all starts with a window
Sheâs asked a couple of really good questions. In a few pages weâll address these questions with an extra-special âNo Dumb Questions.â
A JFrame is the object that represents a window on the screen. Itâs where you put all the interface things like buttons, check boxes, text fields, and so on. It can have an honest-to-goodness ...
Get Head First Java, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.