• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to free/release/dispose a Form

 
Miguel Enriquez
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all i have this code:

RegistraFolios dg = new RegistraFolios();
dg.dispose();
dg.setUndecorated(true);
dg.setLocationRelativeTo(null);
dg.setVisible(true);
JOptionPane.showInputDialog(dg);

in last line i show the form in modal mode.

how to free? i try this:

private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}

but not work.


Thanks
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a "Form" -it's not a term that has a standard meaning in Java-, and what would it mean to "free" it? Also, it would help to know what kind of class "RegistraFolios" and "this" are.
 
Miguel Enriquez
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thing that I want to do is to create a modal window from a JForm(Swing), in order to make the code to stop when the window is executing, and continue when you close the form. I read that I can do it calling the JForm like a parameter of a JOptionPane, but now I don't know how to close it, because even dispose or close work. The new window keeps displaying.

RegistraFolios is the main window, and the This from the second code is the procedure from the Ok button of the second Jform, the one that I trying to make work like a modal one.

Note: I call it modal, but truly I don't know how you call it on Java, the modal term was used in Object Pascal.

Thanks in advantage.
 
Campbell Ritchie
Marshal
Posts: 52516
118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A dialogue window from JOPtionPane is usually modal. I do not know whether that means the same as in Pascal. Have a look at the Java Tutorials. Your dialogue appears, you do something with it and then close it. Because it is modal, you have to click the close button on the dialogue.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a JForm? It's not a JRE class, and a quick search comes up with no likely hits.
 
Miguel Enriquez
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what I want to do, make a Jform appear like a Jdialog using JOptionPane, and the code that I show you can do it, but at the moment when I need to close it, I don't know how to do it, any ideas? What can I use on a button to do it?
Jform is a component of Java Swing i use Netbeans.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miguel Enriquez wrote:Jform is a component of Java Swing

It is not: http://docs.oracle.com/javase/8/docs/api/. Is it maybe a NetBeans extension?
 
Miguel Enriquez
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, the correct name of the component is JFrame Form, and in http://docs.oracle.com/javase/8/docs/api/ it appears like JFrame. I pass it like a parameter in a JInputPane, but now I can't close it when I finish using it. Using dispose or close doesn't work.

Thanks.
 
Campbell Ritchie
Marshal
Posts: 52516
118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frames are top‑level containers. They are not intended to be passed as arguments to methods of other Swing components. They are there simply to hold the entire display together.
 
Paul Clapham
Sheriff
Posts: 21863
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miguel Enriquez wrote:The thing that I want to do is to create a modal window from a JForm(Swing), in order to make the code to stop when the window is executing, and continue when you close the form. I read that I can do it calling the JForm like a parameter of a JOptionPane, but now I don't know how to close it, because even dispose or close work.


No, don't try to use a JFrame to write a modal dialog. I don't know what you read or where you read it, but for a modal dialog you use a JDialog. And for more information than that, then jdialog tutorial is your search for a tutorial. Choose the Oracle tutorial from that list.
 
Miguel Enriquez
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!