Welcome to Code Central, your go-to resource for all things networking and coding! Whether you're a beginner looking to learn the basics or an expert seeking advanced techniques, this blog provides insightful articles, tutorials, and tips to help you navigate the world of technology. Stay updated on the latest trends in networking, coding practices, and industry best practices to elevate your skills and keep ahead of the curve.
In the previous chapter
we discussed about the user defined dialog box theoretically. And in this
chapter we are going to create the user defined dialog box.
The steps for creating
a user defined dialog box are;
a) JDialog class is used.
b) Two constructor are
there, they are: JDialog(JFrame parent, Boolean isModal) and JDialog(JFrame
parent, String title, Boolean isModal). You can use any one of them to create
user defined dialog box.
Note:
First constructor has two parameters and the value should be passed in the
constructor. The first parameter should be passed with parent frame and second
parameter should be passed with Boolean value that is either true or false.
As we know that Dialog
box is like a frame but it cannot execute independently. So we take help from
the parent frame. Creating a user defined dialog box is same like creating the
frame. Example;
l=new JLabel("This is a user defined
dialog box");
// add label to
the dialog
d.add(l);
d.setVisible(true);
}
}
Note: Green Color words in the above program is comments. Output:
The output you see I same because both program
source code is same only I have changed the constructor of the dialog box and
value of isModal, this is why I have used the video to show the difference.
Post a Comment
0 Comments