This example has four JLabels in it and a FlowLayout Manager is taking care of laying out these labels. Each label uses a unique border to draw around it. Since JLabel is a component, one can apply the same technique for other components as well. For example, a JTextField can use same technique to draw the border. Now, we can have a look at the Bevel Raised border in the picture above and the JLabel looks like a button, right? But it is not. We also set a Font for all the JLabels in this example.
In the this example, we can see how a JFrame Window looks. The three buttons in the top right clearly show how it was drawn using line and rectangles using in-built graphics API. The window displays the title in the frame. And in the Gray area, three JLabels are sitting. That is all and nothing special here.
In this example, we create AWT Frame which shows personal data. Here, fields Name and Age collect user input from the Frame itself. Address multi-line text field is read-only and ellipsis button next to it will launch a dialog to gather user input. The frame wants to display the address in a precise format and hence it invokes the dialog. Once the dialog is displayed as modal, the code execution in the Frame window is blocked. This means, the user can not interact with any of the UI components in the Frame Window before closing the dialog. In the dialog, the user can fill the details required for the address field and click OK. Or they can also click Cancel and that is not a usual workflow. the address information from the dialog and displays that in address multi-line field. Note, the frame gets the address in a formatted way from the dialog. Since, address field is disabled, the user can not edit its content manually. They can feed the address only via the dialog and there by the frame gets the formatted address.
Here, we have a PopupMenu with 4 MenuItems and one separator. We can also notice that the Menu is not attached to a Menubar, and it is displayed in the AWT Frame Window. In this example, we will display the Menu when you right click the mouse inside the AWT Frame.
A Menu contained by one more menu is what called Sub-Menu. Here in this short example, we will create sub-menus.