Previously we discussed some basic intuition of Java graphical user interface, or GUI. In this article we will talk about some general idea of GUI Layout. By default, a JFrame has five regions we can add widgets or custom graphics. We are allowed to add only one thing to each region on the frame. But that one thing might be a panel that can hold three other things, including a panel that also can hold other two things .. an so on. Let see HOW?
GUI Layout | Content Pane Layout
Previously we also have talked about the simple way of adding widgets, such as button, checkbox, textarea, etc on JFrame’s content pane.
But that is In-fact, not the right way of adding thing on the frame. Rather, we should take two arguments in add method, that takes a region (i. e. – center, east, north, etc) and the widget to add to that region. Figure below, we have illustrated the default JFrame’s content pane layout:
So, we can add things (such as buttons) on that layout in following manner:
This is usually the mandatory way to add things to JFrame’s default content pane. But when we don’t specify the region the widget will automatically land on the default center region of the content pane.
//This is just an introduction of JFrame’s content pane layout, or java gui Layout. Next we will talk about how to add different widgets to content pane-layout’s different regions. We will also discuss about how to register Listeners to different buttons on GUI Layout to handle different events that occur with user interaction. see here>>