How to dynamically create and destroy jFrames in a Java application?

P

Paulie

Hi all,

I'm trying to write a simple cryptography app in Java.

I have a frame called frCryptApp (essentially the welcome
screen) and what I want to do is to offer the user the
possibility of choosing their encryption method
(Caesar cipher, Vigenere &c.) and then have the programme
bring up another frame configured for the parameters
involved with the given cipher.

I want to do this dynamically, i.e. on choosing say the
Caesar cipher, the app will create a new frame frCaesar
and destroy the frCryptApp frame.

Then on closing down the frCaesar frame, it is
destroyed and a new frCryptApp is created to
offer the user further choices.

I have tried various permutations of this.dispose()
and importing frCryptApp.java (using the import
statement), but I just can't seem to get it. frCryptApp
appears to be out of scope for frCaesar.

Could some kind soul please just show me what to
do in this case - i want the code to work if the user
clicks an Exit button on frCaesar or if they shut the
window using the top right x button or any other
way.

TIA and rgs.


Paul...

p.s. I'm using Oracle JDeveloper 11g on Linux
 
M

markspace

I have tried various permutations of this.dispose()
and importing frCryptApp.java (using the import
statement), but I just can't seem to get it. frCryptApp
appears to be out of scope for frCaesar.


There's no reason for this to happen, it's just regular programming.
You'll need to supply an SSCCE to get some real help.

<http://pscode.org/sscce.html>

Classes imported do need to be on the CLASSPATH. Please make sure they
are. Some info how your IDE or ant script is configured would be
helpful too, if those are apropos to you question. If on the command
line, we'll need to see the relevant directory layouts and command line
arguments.
 
L

Lew

markspace said:
Classes imported do need to be on the CLASSPATH. Please make sure they

"Imported" in the English sense of the word, not necessarily the Java 'import'
directive. A better verb than "imported" would be "used".
are. Some info how your IDE or ant script is configured would be helpful
too, if those are apropos to you question. If on the command line, we'll
need to see the relevant directory layouts and command line arguments.

The point of needing an SSCCE is not diminished by this clarification.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top