JLabel Border and Font Example

JLabel Border and Font

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.

About the AWT Dialog Example

Java AWT Dialog Example

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.