-
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 ??
-
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.
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks