Results 1 to 3 of 3

Thread: show modal frame

  1. #1

    Thread Starter
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552

    Resolved show modal frame

    dunno if my subject meets my need. hehe. how do i do a frame that is modal. sample of this is an about frame. something like a .showdialog() in c#. thank you in advance.
    Last edited by Dilenger4; Oct 7th, 2004 at 05:10 PM.

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    You normally hook a JDialog to a JFrame using JDialog's(Frame parent, String title, boolean modal) constructor. For complex dialogs there are static methods in the JOptionPane class that can be invoked. You most likley want to use showMessageDialog(Component parent component, Object message, String title, int messagetype, Icon icon) or one of it's variants.

  3. #3

    Thread Starter
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    thank you i'll try that one.

    edit: got this jdialog thing and it's ok now. thank you.
    Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class cAbout extends JDialog{
       public cAbout(JFrame f){
          super(f,"cAbout",true);
          initializeComponent();
       }
       void initializeComponent(){
          setSize(466,348);
    
          Dimension s=Toolkit.getDefaultToolkit().getScreenSize();
          setLocation(s.width/2-getSize().width/2,
             s.height/2-getSize().height/2);
          setVisible(true);
       }
    }
    Last edited by brown monkey; Aug 30th, 2004 at 01:55 AM.

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