Results 1 to 10 of 10

Thread: java message box

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432

    java message box

    is thier a messagebox in java like in vb ????? if so how do i use it ?

  2. #2
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196
    There is a message box method in Java, however it is only available when using Swing (I think).

    Swing allows you to use graphical components in Java classes. If you want to know more about this goto:

    http://java.sun.com/docs/books/tutorial/uiswing/

    It's a Swing tutorial. However, if you are just doing it for debugging etc. I suggest ignoring it as it can be very slow. Also, it's rather a lot of possibly unnecessary hassle.

    Hope it helps

    HD

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432
    no its for user errors and for valadation

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432
    ok cool thanks for the tutorial but dose it have a name so can search for it ?

  5. #5
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196
    Sorry I forgot to say what the thing's called

    You can use the JOptionPane class (I think) and the method showMessageDialog(...). Have a look here:

    http://java.sun.com/docs/books/tutor...ts/dialog.html

    That should do it!

    HD

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432
    COOOOOOl Thanks

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432
    can someone give me a working example ??("JBuilder")

  8. #8
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196
    Can't be sure if this will work - don't have chance to try it (supposed to be working )


    /* All imports here - java.swing.* and the like
    *
    ..
    */

    JFrame frame = new JFrame("My Window");
    JOptionPane.showMessageDialog(frame, "This is my window");



    http://java.sun.com/docs/books/tutor...ialogDemo.java

    is an example of using frames and dialogs with Swing.

    I've not done much so I haven't got any examples.

    HD

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432
    ya i tryed to run that example but it wouldnt compile had errors

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    USA
    Posts
    432
    Ok i got it to work now thanks :-)

    Code:
    import javax.swing.JApplet;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    public class Dialog extends JApplet 
    {
        JFrame frame = new JFrame("My Window");
        public Dialog()
        {
            JOptionPane.showMessageDialog(frame, "This is my window");
        }
        
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width