How can we use JOptionPane class in creating different types of dialog boxed explain with suitable syntax.

 Using JOptionPane

Using JOption Pane, you can quickly create and customize several different kinds of dialogs. JOption Pane provides support for laying out standard dialogs, providing icons, specifying the dialog title and text, and customizing the button text. A Dialog can be model When a modal Dialog is visible, it blocks user input to all other windows in the programGUI with Swing.

JOptionPane creates /Dialogs that are modal. To create a non-modal Dialog, you must use the /Dialog class directly. JOptionPane's icon support lets you easily specify which icon the dialog displays. We can use a custom icon, no icon at all, or any one of four standard JOptionPane icons (question, information, warning, and error). 

By using the JOption Pane class we can create different types of dialog boxes a below:

Confirm Dialog: we can create confirm dialog box by calling JOptionPanes show ConfirmDialog( method. These dialog boxes ask a confirmation question and receive yes/no/cancel response. This method can be used with the following signature JOption Pane.showConfirm Dialog(parent_frame, msg, title, msg_options)

Message options can be any one of the following: DEFAULT OPTION, YES_NO_OPTION, YES_NO_CANCEL OPTION, OK CANCEL OPTION.

Example:

JOption Pane.showMessageDialog(frame, "DoYou Want to Exit?", "Alert",)

Do JOptionPane.YES_NO_CANCEL_OPTION)

Output looks like below:



Message Dialog: we can create a message dialog box by calling JOptionPanes show MessageDialog() method. These dialog boxes tell the user about something that has happened. This method can be used with the following signature

JOption Pane.showMessageDialog(par_frame, msg, title, msg_types, icon)

The message type can be any one of following: INFORMATION MESSAGE, ERROR_MESSAGE, WARNING MESSAGE, QUESTION_MESSAGE, PLAIN_MESSAGE

Example:

JOptionPane.showMessageDialog (frame, "Supplyall required values", "Not Empty", JOptionPane.INFORMATION MESSAGE)



Input Dialog: we can create an input dialog box by calling the JOptionPanes showInput Dialo method. These dialog boxes prompt users for some input.. This method can be used with the following signature

JOption Pane.showInput Dialog(parent_frame, msg, title)

Example:

String num;

num JOptionPane.showMessageDialog (frame,"Enter any Number", "Input")

Output looks like below:



Option Dialog: we can create option dialog box by calling JOptionPanes showOption Dialog() method. This dialog supports the unification of the above three dialog boxes allows us to create a configurable dialog box. This method can be used wi the following signature

JOption Pane.show Option Dialog(parent_frame, msg, title, option_type, msg_ty icon, options, default_option)

Example
Object options[]=["Yes Please", "No way!!");
JOption Pane.showOptionDialog(this, "Do you like green eggs", "Silly Question". JOptionPane.YES_NO_OPTION, JOption Pane.PLAIN MESSAGE, null, options,options[0]);


Comments

Popular posts from this blog

Explain Parallel Efficiency of MapReduce.

Suppose that a data warehouse consists of the four dimensions; date, spectator, location, and game, and the two measures, count and charge, where charge is the fee that a spectator pays when watching a game on a given date. Spectators may be students, adults, or seniors, with each category having its own charge rate. a) Draw a star schema diagram for the data b) Starting with the base cuboid [date; spectator; location; game], what specific OLAP operations should perform in order to list the total charge paid by student spectators at GM Place in 2004?

Suppose that a data warehouse for Big-University consists of the following four dimensions: student, course, semester, and instructor, and two measures count and avg_grade. When at the lowest conceptual level (e.g., for a given student, course, semester, and instructor combination), the avg_grade measure stores the actual course grade of the student. At higher conceptual levels, avg_grade stores the average grade for the given combination. a) Draw a snowflake schema diagram for the data warehouse. b) Starting with the base cuboid [student, course, semester, instructor], what specific OLAP operations (e.g., roll-up from semester to year) should one perform in order to list the average grade of CS courses for each BigUniversity student. c) If each dimension has five levels (including all), such as “student < major < status < university < all”, how many cuboids will this cube contain (including the base and apex cuboids)?