How dialog boxes can be created in java by using JDialog class? Explain with java code.

 Creating Dialog Boxes with JDialog

With JOptionPane class, it is easy to create dialog boxes, but to create custom dialog boxes we need to use JDialog class as below. JDialog class is foundation for all dialog boxes customized in swing class. We can create dialog boxes by using any one of following constructor defined in JDialog

JDialog()

JDialog(parent_frame)

JDialog(parent_frame, modal)

JDialog(parent_frame, title)

JDialog(parent_frame, title, modal)

Example

import javax.swing.*;

import java.awt.*;

import java.awt.event.*; 

class DialogDemo extends JFrame

JLabel 1; 

JTextField f;

Dialog d; 

DialogDemo()

{

setSize (400, 300);

setDefaultLookAndFeelDecorated (true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setVisible(true);

setTitle ("Paraent Frame");

1-new JLabel("Email");

fanew JTextField(15);

d=new JDialog(this,"Dialog Example", true);

d.setLayout (new FlowLayout (FlowLayout. CENTER, 20,20)); d.setSize(300,200);

d.setLocation (50,50);

d.setModal (true);

d.add(1);

d.add(f);

d.setVisible (true);

}

public static void main (String args[])

{

DialogDemo frame=new DialogDemo();

}


Comments

Popular posts from this blog

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?

Explain Parallel Efficiency of MapReduce.

Short Note on Security Architecture of E-governance