• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

Disable frame

Disable window
i have a jframe , how do i disable that frame when another window comes up.

For example, i click button add, another frame appears.
0
zizi21
Asked:
zizi21
  • 4
  • 3
  • 2
  • +1
1 Solution
 
ksivananthCommented:
>>For example, i click button add, another frame appears.

when you click a button, display a JDialog with modal mode and set the frame as the parent for the dialog.
0
 
sciuriwareCommented:
You can do a:

frame.setVisible(false);

on the first frame, but I doubt if you are planning the application right.
Why should your main frame disappear for another?

;JOOP!
0
 
sciuriwareCommented:
If you mean to say: I want the new window to catch input and events .....

That happens automatically.

;JOOP!
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
ksivananthCommented:
0
 
ksivananthCommented:
>>frame.setVisible(false);

this will make the frame hide not disable! Using dialog, you can achieve that!
0
 
sciuriwareCommented:
It all depends on what the questioner really wanted.

;JOOP!
0
 
ksivananthCommented:
yes, the questionaire asked for disabling the frame in his original question!
0
 
c_maxellCommented:
if by disabling you mean unable to edit or select  the parent frame,
I think you might want to consider using JDialog and setModal(true).
by doing this way, once the JDialog pop up, you won't be able to select the JFrame until you close the JDialog.
Hope it helps.

0
 
zizi21Author Commented:
hi, i am using jframe for another window as well as it queries a lot of info.

when the second window appears.., the parent window becomes non editable.thanks
0
 
zizi21Author Commented:
okay..i changed to jdialog and put this using JDialog and setModal(true).

and i still able to edit parent window :-(
0
 
c_maxellCommented:
main function
JFrame mainFrame = new JFrame();
JTextField tx = new JTextField("Testing")
mainPanel.add(tx);

mainFrame add new JButton (button)
if (button is clicked) go to actionPerformed()

function actionPerformed():
JDialog dialog = new JDialog()
dialog.setModal(true)

JTextField tx2 = new JTextField("Text 2);
dialog.add(tx2);
dialog.setVisible(true);

I believe if you set it up this way, the mainFrame will become inaccessible once the dialog is set visible.
Once the dialog is closed, then your mainFrame will become active again.

Can you try this again? if still not working, why don't you post your code.

Hope it helps
Soli Deo Gloria


 
       
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now