Advice needed about JFrame and JDialog (moved from java programming)

My main class in my application is a page where the user can choose to register or login. This class is a JFrame. If the user chooses to register, my register dialog is called up and the parent JFrame passed to the dialog:
private void btnRegister_actionPerformed()
                new Register(this);
          }Same happens for login. If the user chooses to login, my login dialog comes up and my main class JFrame is set as its parent. This is all fine because all the calling up is done in my main class, so i can just use 'this' to pass the JFrame.
Now here is my problem. If the user successfully logs in, they should have access to control some events. Now i am not sure if it will be ok to make this new events class another JFrame, as it is practically the start of a new section in my application.
Thats my first question. My second question is if i do make this events class a JDialog, is it bad coding not to give it a parent frame? Or would this be acceptable? My worries is passing the main class JFrame to a class which is only accessable by going through two other classes.
Cheers for the advice

It's Simple dude,
Advice: Use JIternalFrame, for your purpose.
And if u want to go with JDialog than u can do that in main method. Like when u call JDialog
Register dialog = new Register(this);Check for login in Register class or what ever u want. Create new method like success
private boolean isSuccess() {
return success;
} at Register Class. After Registeration change the variable boolean success value to true or false as per logic
And add
Register dialog = new Register(this);
if(dialog.isSuccess()) {
// Show loginDialg(this) or else
}Regards,

Similar Messages

  • Creating and running JARs from Java programs

    OK, I have been googling and searching, but this is something I cannot work out, so I raelly need some help.
    Basically, I am building a GUI app that would generate, compile and run java programs. And I also want to enable the users to create JARs they can later double-click if they want to run the program.
    I am using Runtime to compile programs and it works just fine. When I click on a button to create a JAR, my application creates one, but when I double-click on it, it can't find main and it exits. Now that is not so much unusual, but I am positive that my manifest file is OK, because when I run the same command from the command line, then I can click on the JAR file to run it.
    So what is the deal here? I mean, why would a JAR file created from the command line run and the one created through a GUI app using the very same command could not find main?
    Any help would be graetly appreciated.

    again, another unanswered question.
    BTW I'l keep bumping these until I get an answer that works. I have been up 3 hours now trying to get this sorted and it's something that netbeans is supposed to do on its own!?!?!?!?!
    Hello, SUN, is there anyone there???
    No, didn't think so.

  • HT4009 I make an In-App purchase and my device fails to complete the purchase. Could you do something about it and prevent it from ever happening again?

    To iTunes Store
    I've being trying to make an In-App purchase and it doesn't work. I get this message that says the pruchase can't be completed. Could you do something about it and prevent it from ever happening again?
    Sincerely
    Cameron

    We are itunes users just like you.
    You should contact itunes support

  • What is the difference between JFrame and JDialog?

    Is there any difference between JFrame and JDialog except that the JDialog can be modal?
    Is there any reason to use JFrame at all if i can achive the exactly the same with a JDialog?

    API wise they are basically the same, but they are usually built on top of different heavyweight components. Some platforms treat frames quite a bit differently than they do dialogs.

  • I need to call a batch file from java and pass arguments to that Batch file

    Hi,
    I need to call a batch file from java and pass arguments to that Batch file.
    For example say: The batch file(test.bat) contains this command: mkdir
    I need to pass the name of the directory to the batch file as an argument from My Java program.
    Runtime.getRuntime().exec("cmd /c start test.bat");
    How to pass argument to the .bat file from Java now ?
    regards,
    Krish
    Edited by: Krish4Java on Oct 17, 2007 2:47 PM

    Hi Turing,
    I am able to pass the argument directly but unable to pass as a String.
    For example:
    Runtime.getRuntime().exec("cmd /c start test.bat sample ");
    When I pass it as a value sample, I am able to receive this value sample in the batch file. Do you know how to pass a String ?
    String s1="sample";
    Runtime.getRuntime().exec("cmd /c start test.bat s1 ");
    s1 gets passed here instead of value sample to the batch file.
    Pls let me know if you have a solution.
    Thanks,
    Krish

  • BASIS Configuration needed to send an external mail from SAP Program

    Can you please help me about the BASIS configuration needed to send an external mail from SAP Program?
    Regards,
    Subhasish

    Hi Subhasish,
    Please go thru the below link.
    Re: SCOT Configuration--for external mail
    Regards,
    Lakshman.

  • Exception when connecting to Reporting and Analysis services from Java API

    Hello,
    I'm trying to connect to Hyperion Reporting and Analysis services from Java API using [Developer's guide|http://www.bidw.in/docs/hs_developer.pdf] .
    I get this error:
    com.sqribe.rm.ReportMartException: com/hyperion/css/CSSException
         at com.sqribe.rm.SessionImpl.convertError(Unknown Source)
         at com.sqribe.rm.AASessionImpl.open(Unknown Source)
         at com.sqribe.rm.AASessionImpl.internalInit(Unknown Source)
         at com.sqribe.rm.AASessionImpl.<init>(Unknown Source)
         at com.sqribe.rm.SessionFactory.getInstance(Unknown Source)
         ...My code:
    String user = "user";
    String pwd = "password";
    String host = "my.hyperion.server";
    int port = 6800;
    try {
         Session theSession = SessionFactory.getInstance(user, pwd, host, port);
         Repository theRepository = theSession.getRepository();
    } catch (UserValidationException e) {
         e.printStackTrace();
    } catch (UnknownReportMartException e) {
         e.printStackTrace();
    } catch (ReportMartException e) {
         e.printStackTrace();
    }I have tried to look at my services running, and it all looks OK. I've checked user/passowrd/port for GSM. What can be wrong?
    I also tried to run samples from \BIPlus\SDK\samples\java, e.g. Login.java:
    #> java Login user password my.hyperion.server 6800with this effect
    com.sqribe.rm.ReportMartException: SystemExceptionError
            at com.sqribe.rm.SessionImpl.convertError(Unknown Source)
            at com.sqribe.rm.AASessionImpl.open(Unknown Source)
            at com.sqribe.rm.AASessionImpl.internalInit(Unknown Source)
            at com.sqribe.rm.AASessionImpl.<init>(Unknown Source)
            at com.sqribe.rm.SessionFactory.getInstance(Unknown Source)
            at Login.<init>(Login.java:36)
            at Login.main(Login.java:69)I'm sure that I'm connecting to the server because when put wrong passowrd or user as input to Login class I get this:
    com.sqribe.rm.ReportMartException: AUTHEN_CSSLoginFailed
            at com.sqribe.rm.SessionImpl.convertError(Unknown Source)
            at com.sqribe.rm.AASessionImpl.open(Unknown Source)
            at com.sqribe.rm.AASessionImpl.internalInit(Unknown Source)
            at com.sqribe.rm.AASessionImpl.<init>(Unknown Source)
            at com.sqribe.rm.SessionFactory.getInstance(Unknown Source)
            at Login.<init>(Login.java:36)
            at Login.main(Login.java:69)so it is there but something is wrong later. Any idea what?
    Please help.
    regards,
    Pawel
    Edited by: Paoro on 2010-09-27 02:02

    HI,
    I am getting the same error while running the Login file, Did any one resolve this issue?
    Please share the solution.
    Thanks.

  • Downloading unix archive file (.Z extension) from java program

    Hi,
    I am trying to download unix archive files with .Z extension from java program. When I use
    BufferedReader zReader = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
    and then read line by line and write it to file, downloaded file can't be decompressed. I tried to open it with winZip which supports .Z files but I get the message : Cannot open file, it does not appear to be a valid archive.
    How can I download file correctly?
    Any help would be appreciated.

    Hi,
    I am trying to download unix archive files with .Z
    extension from java program. When I use
    BufferedReader zReader = new BufferedReader(new
    InputStreamReader(urlConn.getInputStream()));
    and then read line by line and write it to file,How are you writing the file? Since it is binary data you need to be careful about using Reader/Writers, which are meant for character data. Look at using classes from the InputStream/OutputStream hierarchy.
    - N

  • Calling oracle SQL Loader from java program

    Hi,
    I want to insert data into oracle tables from a text files containing fixed length fields. I am using SQLLoader to achieve this. The requirement is to call the SQLLoader within the java program.
    Does anyone know how to call SQL Loader from java program?
    Thanks,
    Varsha

    Simply "exec" the sqlldr program with the parameters you need to pass to it.
    Runtime.exec (........)
    Try to pass all parameters needed including the username and password, and use the option "silent" to avoid output, and the option "log" to have a log file of the modifications that sqlldr has done to the database.

  • SOLVED: How To Use LDAP over SSL (no certs) from java program

    Trying to connect to OID from Java program (using Grocery Store demo as a test). Want to use SSL with no server certificate. OID is configured, and ldapsearch -U 1 works.
    Tried using URL with ldaps, or adding SECURITY_PROTOCOL,"ssl". In both case the error is 'simple bind failed'.
    Samples on OTN say this should be possible, but then only have code for the non-ssl connection.
    Posting from others with this same question don't seem to have been answered.
    Message was edited by:
    user590350
    I have found that using ConnectionUtil.getSSLDirCtx() from Oracle will make a no-authentication SSL connection. An example in the sample code would be useful.

    Even with Java APIs, There is a way to talk through SSL without bothering about certificates. It's just that you will have to write some code and make some changes in settings.
    Read following to get further information on the same.
    http://kiranthakkar.blogspot.com/2007/04/dummny-certificate-authentication.html
    I don't know or I won't comment whether it's the right approach or not but it's definitely a work around.
    Thanking You
    Kiran Thakkar

  • Problem while running dos command from java program

    Dear friends,
    I need to terminate a running jar file from my java program which is running in the windows os.
    For that i have an dos command to find process id of java program and kill by using tskill command.
    Command to find process id is,
    wmic /output:ProcessList.txt process where "name='java.exe'" get commandline,processid
    This command gives the ProcessList.txt file and it contains the processid. I have to read this file to find the processid.
    when i execute this command in dos prompt, it gives the processid in the ProcessList.txt file. But when i execute the same command in java program it keeps running mode only.
    Code to run this command is,
    public class KillProcess {
         public static void main(String args[]) {
              KillProcess kProcess = new KillProcess();
              kProcess.getRunningProcess();
              kProcess = new KillProcess();
              kProcess.readProcessFile();
         public void getRunningProcess() {
              String cmd = "wmic /output:ProcessList.txt process where \"name='java.exe'\" get commandline,processid";
              try {
                   Runtime run = Runtime.getRuntime();
                   Process process = run.exec(cmd);
                   int i = process.waitFor();
                   String s = null;
                   if(i==0) {
                        BufferedReader stdInput = new BufferedReader(new
                               InputStreamReader(process.getInputStream()));
                        while ((s = stdInput.readLine()) != null) {
                         System.out.println("--> "+s);
                   } else {
                        BufferedReader stdError = new BufferedReader(new
                               InputStreamReader(process.getErrorStream()));
                        while ((s = stdError.readLine()) != null) {
                         System.out.println("====> "+ s);
                   System.out.println("Running process End....");
              } catch(Exception e) {
                   e.printStackTrace();
         public String readProcessFile() {
              System.out.println("Read Process File...");
              File file = null;
              FileInputStream fis = null;
              BufferedReader br = null;
              String pixieLoc = "";
              try {
                   file = new File("ProcessList.txt");
                   if (file.exists() && file.length() > 0) {
                        fis = new FileInputStream(file);
                        br = new BufferedReader(new InputStreamReader(fis, "UTF-16"));
                        String line;
                        while((line = br.readLine()) != null)  {
                             System.out.println(line);
                   } else {
                        System.out.println("No such file");
              } catch (Exception e) {
                   e.printStackTrace();
              return pixieLoc;
    }     when i remove the process.waitFor(), then while reading the ProcessList.txt file, it says "No such file".
    if i give process.waitFor(), then it's in running mode and program is not completed.
    Colud anyone please tell me how to handle this situation?
    or Is there anyother way to kill the one running process in windows from java program?
    Thanks in advance,
    Sathish

    Hi masijade,
    The modified code is,
    class StreamGobbler extends Thread
        InputStream is;
        String type;
        StreamGobbler(InputStream is, String type)
            this.is = is;
            this.type = type;
        public void run()
            try
                InputStreamReader isr = new InputStreamReader(is, "UTF-16");
                BufferedReader br = new BufferedReader(isr);
                String line=null;
                while ( (line = br.readLine()) != null)
                    System.out.println(type + ">" + line);
                } catch (IOException ioe)
                    ioe.printStackTrace(); 
    public class GoodWindowsExec
        public static void main(String args[])
            try
                String osName = System.getProperty("os.name" );
                String[] cmd = new String[3];
                 if( osName.equals( "Windows 95" ) )
                    cmd[0] = "command.com" ;
                    cmd[1] = "/C" ;
                    cmd[2] = "wmic process where \"name='java.exe'\" get commandline,processid";
                } else {
                    cmd[0] = "cmd.exe" ;
                    cmd[1] = "/C" ;
                    cmd[2] = "wmic process where \"name='java.exe'\" get commandline,processid";
                Runtime rt = Runtime.getRuntime();
                System.out.println("Execing " + cmd[0] + " " + cmd[1]
                                   + " " + cmd[2]);
                Process proc = rt.exec(cmd);
                System.out.println("Executing.......");
                // any error message?
                StreamGobbler errorGobbler = new
                    StreamGobbler(proc.getErrorStream(), "ERROR");           
                          // any output?
              StreamGobbler outputGobbler = new
                    StreamGobbler(proc.getInputStream(), "OUTPUT");
                          // kick them off
                errorGobbler.start();
                outputGobbler.start();
                // any error???
                int exitVal = proc.waitFor();
                System.out.println("ExitValue: " + exitVal);       
            } catch (Throwable t)
                t.printStackTrace();
    }when i execute the above code, i got output as,
    Execing cmd.exe /C wmic process where "name='java.exe'" get commandline,processid
    and keeps in running mode only.
    If i execute the same command in dos prompt,
    CommandLine
    ProcessId
    java -classpath ./../lib/StartApp.jar;./../lib; com.abc.middle.startapp.StartAPP  2468
    If i modify the command as,
    cmd.exe /C wmic process where "name='java.exe'" get commandline,processid  > 123.txt
    and keeps in running mode only.
    If i open the file when program in running mode, no contents in that file.
    If i terminte the program and if i open the file, then i find the processid in that file.
    Can you help me to solve this issue?

  • Starting weblogic server from java program

    Runtime r=Runtime.getRuntime();
    Process p=r.exec("cmd /c d:/bea/weblogic700/server/bin/setWLSEnv.cmd");
    when ihave given like this it is working.
    now i want to start weblogicserver from jav program
    String s="-Dweblogic.Domain=mydomain weblogic.Server"
    Process p=r.exec("cmd /c d:/bea/weblogic700/server/bin/setWLSEnv.cmd java "+s);
    when i gave like this weblogicserver should start with specified domain
    but no output is comming.please tellme where the problem is

    no - nothing happened. it perform the next java code - and there is nothing else happen on the windows.
    maybe i don't check in the right place for the error you are talking about?
    i also tried i simple cmd file that does nothing - but still nothing...
    for any other file types it works properly.

  • Calling C code (exe ) from Java program

    Hi all,
    kindly help in giving a solution for calling C code (exe ) from Java program, i will be very thank full to u if any body can help in sending a code example
    bye

    You might need to consume the io operations on the Process...
    An excerpt from java.lang.Process:
    All its standard io (i.e. stdin, stdout, stderr) operations will be redirected to the parent process through three streams (Process.getOutputStream(), Process.getInputStream(), Process.getErrorStream()). The parent process uses these streams to feed input to and get output from the subprocess. Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.

  • Setting windows environment variables from Java program

    Is there any way to set environment variables from Java program in Windows? Any help is appreciated.
    Here is my situation:
    I need to decrypt an encrypted Oracle user password in a batch file which will be used while running a sql script with sqlplus. I was planning to have bat file which will call a Java program decrypt the password and set it as an env variable in windows which will be available while calling sqlplus.
    thanks

    Runtime.exec has a lot of overloadings. Two of them
    allows you to specify the environment variables.
    exec
    public Process exec(String[] cmdarray,
    String[] envp,
    File dir)
    throws IOExceptionExecutes the specified command and
    arguments in a separate process with the specified
    environment and working directory.
    cmdarray - array containing the command to call and
    its arguments.
    envp - array of strings, each element of which has
    environment variable settings in format name=value.
    dir - the working directory of the subprocess, or null
    if the subprocess should inherit the working directory
    of the current process.
    I had this sample program:
    public class SetVarExample {
    public static void main (String[] args) throws Exception {
         String[] cmd_env= new String[] {"password="+"ABCD","Path=C:\\Sun\\AppServer\\jdk\\bin"};
         String cmd = "cmd /c SET ";
         Runtime.getRuntime().exec(cmd,cmd_env);
    System.out.println( "Finish ...." );
    I tried it in a command prompt. But looks like when the program exits, it's a whole new process and so it does not retain the env variables set in the java program.
    Any suggestions? Am I doing it worng?
    thanks

  • How to edit the existing data in the XML file from java programming.

    Hi all
    i am able to create XML file with the sample data as below from java programming.
    i need sample code on how to edit the existing data in the XML file?
    for example
    <?xml version="1.0"?>
       <mydata>
               <data1>
                         <key1>467</key1>
                        <name1>Paul</name1>
                        <id1>123</id1>
              </data1>
              <data2>
                         <key2>467</key2>
                        <name2>Paul</name2>
                        <id2>123</id2>
              </data2>
        </mydata>
    i am able to insert the data in the XML.
    now i need sample code on how to modify the data in the above XML file from the java programming for only key2,name2,id2 tags only. the remaining tags data in the XML file i want to keep same data except for key2,name2,id2 which are i want to modify from java code
    Regards
    Sunil
    [points will be always rewardable]

    hi
    u need a parser or validate the xml file for to read the xml file from java coding u need for this
    xml4j.jar u can download this file  from here
    http://www.alphaworks.ibm.com/tech/xml4j
    or we can use the SAX(simple API for XML)
    some sample applications for this
    http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html
    http://www.developertutorials.com/tutorials/java/read-xml-file-in-java-050611/page1.html
    http://www.xml-training-guide.com/e-xml44.html
    let me know u need any other info
    bvr

Maybe you are looking for

  • After effects cs4

    I had this message trying to open Adobe After Effects CS4: Adobe After Effects CS4 is not installed or its insatallation is damaged. Please reinstall or repair. What should i do....

  • Can't replace existing workbook

    We are having an issue moving in a workbook that is already in quality.  I created it then somebody else changed it in Quality and should not have so now I am trying to re-transport it and it fails.  Is it due to the owner now being the other person

  • Auth check

    hi, iam using job_submit FM  to run a job in background. iam also passing the parameter authcknam to the FM which is not equal to sy-uname but the job gets released with my user name (sy-uname). how can i release the job with the user name i want? th

  • SPRO Change

    Hi All, The user's path is : SPRO - IMG - CRM - Transactions - Settings for Opportunities - Define Opportunity group, priority and origin - Define source for opportunities. When she click on the clock right at this stage, she gets the msg " you dont

  • Subscriber's web can't be accessed

    Hi, i've got problem in subscriber web UI. I can't access it. I can access the publisher and all call activity is fine. When i go to the subscriber's url, it appears : HTTP/1.1 500 Server Error Is there any work around for this problem? Thanks