From the course: Learn Java with Swing
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Frames and panels - Java Tutorial
From the course: Learn Java with Swing
Frames and panels
- [Instructor] Frames and panels. Since we're working with Swing, it's important to understand in a little bit more detail, how frames and panels work together. After a frame is instantiated, we can add one or more panels. When you create a frame or when you instantiate a frame, it has two primary constructors, an empty constructor, and a constructor that accepts a string for the title of the frame. Now if you create an empty constructor you can always add the title using the set title command. Once we instantiate a frame object, we can add a panel that will contain all of our graphical components. Panels have a default flow layout, so components are added from left to right, and then they wrap to the next line when they run out of room. It's important to understand too, that we can add one or more panels to one frame. One of the properties that should always be set when using a frame is the property for what should happen when the user clicks the Close icon in the window. The default…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.