Search This Blog

Showing posts with label how to display. Show all posts
Showing posts with label how to display. Show all posts

What Does Modal and Modeless (Non Modal) Mean in Java

In java, the dialogue boxes in JOptionPane class are very popular. Now when we use dialogue boxes, whether it is message dialogue box, input dialogue or any other,  we may sometimes need to make the parent container (often JFrame or JWindow) not focusable. In another words, we may have to prevent a (parent) component taking input from the user while one of its member component is active. (You may have noticed that when error message boxes are displayed, you cannot click its parent window on many software until you dismiss it by clicking 'OK' or 'close'). Such a property of a member or child component, is called modality. In java, you can use JDialog with or without modality. A JDialog can be either modal or modeless.
A Modal dialog box is a dialog box that blocks input to some other top-level windows in the application. The modal dialog box captures the window focus until it is closed, usually in response to a button press.
A Modeless dialog box is a dialog box that does not block input to any other top level window while it is shown.
See following java code example:

How to Display Multiple Lines in JLabel

multiple lines of text i JLabel, Java source code. Java code to display multiple lines in JLabel. HTML formatting in JLabel Java.
HTML formatted multiline JLabel
Jlabel is actually intended to show single line of text. But you may sometimes ask how to make JLabel to display multiline text. It is possible for JLabel to show multiple lines of text. JLabel in Java can show HTML formatted text. This ability of JLabel can be used to extend longer text onto next line. The following lines of code is an answer for the questions like 'is there a multi-line JLabel' or 'how to display multiple lines using JLabel. Simply, look at the sample code:
JLabel lbl_Multiline=new JLabel();
lbl_Multiline.setText("<html>This is my long text to display with JLabel....</html>");