MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

Swing

Show Dialog Box in Java swing
Previous Home Next

 

       
In the Swing the Message dialog box is used to display messages to the user. In this section we are using JOptionPane class to display the message Dialog box. Our program display "Click On Me" button on the window and when user clicks on it program 

displays Message box with "OK" button and message "R4RTech Soft Solution". 

 
showMessageDialog(): 
This method is used to display a simple message.
showInputDialog(): 
This method is used to display a prompt for inputting and returns a String value which is entered by user.
showConfirmDialog(): 
This method is used to asks the user for confirmation (Yes/No) by displaying message. 

 

package r4r;
import javax.swing.*;
import java.awt.event.*;

public class showdialogbox {
	JFrame frame;
	  public static void main(String[] args){
		  showdialogbox sdb = new showdialogbox();
	  }

	  public showdialogbox(){
	  frame = new JFrame("Show Message Dialog");
	  JButton button = new JButton("Click on Me");
	  button.addActionListener(new MyAction());
	  frame.add(button);
	  frame.setSize(500, 500);
	  frame.setVisible(true);
	  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	  }

	  public class MyAction implements ActionListener{
	  public void actionPerformed(ActionEvent e){
	  JOptionPane.showMessageDialog(frame,"R4RTech Soft Solution");
	  }
	  }
}

Click on Me

R4RTech Soft Solution
Previous Home Next