- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create Message Pop-Ups with Java?
To create Message Pop-ups, use the following JOptionPane −
JOptionPane.showMessageDialog
We are displaying a tree inside the message pop-ups. The following is an example to create Message Pop-Ups with Java −
Example
package my; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo { public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Demo"); DefaultMutableTreeNode node = new DefaultMutableTreeNode("Project"); DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("App"); DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Website"); DefaultMutableTreeNode node3 = new DefaultMutableTreeNode("WebApp"); node.add(node1); node.add(node2); node.add(node3); DefaultMutableTreeNode one = new DefaultMutableTreeNode("Learning website"); DefaultMutableTreeNode two = new DefaultMutableTreeNode("Business website"); DefaultMutableTreeNode three = new DefaultMutableTreeNode("News publishing website"); DefaultMutableTreeNode four = new DefaultMutableTreeNode("Android app"); DefaultMutableTreeNode five = new DefaultMutableTreeNode("iOS app"); DefaultMutableTreeNode six = new DefaultMutableTreeNode("Editor WebApp"); node1.add(one); node1.add(two); node1.add(three); node2.add(four); node2.add(five); node3.add(six); JTree tree = new JTree(node); frame.add(tree); tree.setVisibleRowCount(8); JOptionPane.showMessageDialog(null, new JScrollPane(tree)); } }
Output
- Related Articles
- How to create input Pop-Ups (Dialog) and get input from user in Java?
- How to Block Pop-Ups on Google Chrome?
- How to create a chat message with CSS?
- How to create a message box with Tkinter?
- How to Remove YOUR COMPUTER HAS BEEN BLOCKED Fake Microsoft Warning Pop Ups?
- Is it possible to handle Windows based pop-ups in Selenium?
- How to format message with integer fillers in Java
- Create Toast Message in Java Swing\n
- Create an alert message box with Bootstrap
- How to create a Tkinter error message box?
- Format a message with date in Java
- How to Do Sit-ups?
- How to send a cross-document message with HTML?
- How to print custom message instead of ErrorStackTrace in java?
- How can I create a simple message box in Tkinter?

Advertisements