JFrame question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: JFrame question

  1. #1
    buggy Guest

    JFrame question


    if i have 2 JFrame in 2 different class, for example A and B....
    B frame will be show by clicking a button on A Frame.
    my problem is i want to set the A frame not clickable while B frame was visible
    .. how to do that ??

  2. #2
    Kyle Guest

    Re: JFrame question


    "buggy" <bbgirl@sinagirl.com> wrote:
    >
    >if i have 2 JFrame in 2 different class, for example A and B....
    >B frame will be show by clicking a button on A Frame.
    >my problem is i want to set the A frame not clickable while B frame was

    visible
    >.. how to do that ??

    why not use JDialog for B? Set modal true so A will not be brought up by
    clicking it until you close B.

  3. #3
    Rajesh Guest

    Re: JFrame question

    Dear buggy,
    Here is the code that you are searching for.
    Test these 2 files. and let me know the result.
    Thank you very much.
    Cheers.

    =============================================
    import java.awt.*;
    import java.awt.event.*;

    public class MainFrame extends Frame implements ActionListener
    {
    Button disp;
    static ChildWindow childWindow = null;

    MainFrame()
    {
    setLayout(new FlowLayout());

    disp = new Button("Display");
    add(disp);
    disp.addActionListener(this);

    setVisible(true);
    setSize(300,300);
    show();
    }
    public void actionPerformed(ActionEvent ae)
    {
    if(ae.getSource() == disp)
    {
    if (childWindow == null)
    {
    System.out.println("Window is Opening ");
    childWindow = new ChildWindow();
    }
    else
    {
    System.out.println("Window already Opened ");
    }
    }
    }
    public static void main(String args[])
    {
    new MainFrame();
    }
    }
    =============================================
    import java.awt.*;
    import java.awt.event.*;

    public class ChildWindow extends Frame implements ActionListener
    {

    Button exit;

    ChildWindow()
    {
    setLayout(new FlowLayout());

    exit = new Button("Display Child");
    add(exit);
    exit.addActionListener(this);

    setVisible(true);
    setSize(300,300);
    show();
    }

    public void actionPerformed(ActionEvent ae)
    {
    if(ae.getSource() == exit)
    {
    MainFrame.childWindow = null;
    dispose();
    }
    }
    }
    =============================================


    "buggy" <bbgirl@sinagirl.com> wrote in message
    news:3bfa7cd1$1@147.208.176.211...
    >
    > if i have 2 JFrame in 2 different class, for example A and B....
    > B frame will be show by clicking a button on A Frame.
    > my problem is i want to set the A frame not clickable while B frame was

    visible
    > . how to do that ??




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center