how to show message box in java
  • can anyone tell me what is code for display message box in java i am using netbeans.
  • 1 Comment sorted by
  • Vote Up0Vote Down ithackerithacker
    117.50 Karma Accepted Answer
    Hi try this code here is one button on form when button click's so message box will appear.

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

    public class JavaApplication1{
    JFrame frame;
    public static void main(String[] args){
    JavaApplication1 db = new JavaApplication1();

    public JavaApplication1()
    frame = new JFrame("Form1");
    JButton button = new JButton("Click here for message box");
    button.addActionListener(new Button_Click());
    frame.setSize(300, 300);

    public class Button_Click implements ActionListener
    public void actionPerformed(ActionEvent e)
    JOptionPane.showMessageDialog(frame,"Hi, Type your message here");

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook


Popular Posts of the Week

    Optimum Creative