Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

JLink Dialog Box Opening Behind ProE?

fiebigc

New member
Here is another wonderful idiosyncrasy that is causing me trouble. I have a synchronous JLink application that creates a menu and button on start up. The button will open a Dialog box that displays all of the models that are currently in the session.

The maddening thing about this is the first time I try to open the dialog box it opens behind ProE. If I want to see the box I have to shrink the ProE window ahead of time so that I can click on it when it pops up. This only occurs the first time I open the dialog box. Afterwards the dialog will open on top of the ProE window. Any suggestions?

Code:
import com.ptc.cipjava.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcGlobal.*;
import com.ptc.pfc.pfcCommand.*;

public class proeSyncJDialog
{
 public static Session curSession;
 private static UICommand cmd;
 
 public static void start() throws jxthrowable
 {
 curSession = pfcGlobal.GetProESession();        //Get Current Session Info

 curSession.UIAddMenu("NeatoMenu", "Help", "proetext.txt", null);     //Adds Neato! Menu Button
 
 cmd = curSession.UICreateCommand("List Models In Session", new proeSyncJDialogListener(curSession));    //Creates Command to Open Web Page in Internal Browser
 
 curSession.UIAddButton(cmd, "NeatoMenu", null, "SubMenuName1", "HelpMessage1", "proetext.txt");  //Creats Sub Menu Button to Open Web Page
   
 }
 
 public static void stop()           //Stop Method Required by J-Link
 {   
 } 
}

Code:
import com.ptc.cipjava.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcCommand.*;
import com.ptc.pfc.pfcModel.*;


import javax.swing.*;

public class proeSyncJDialogListener extends DefaultUICommandActionListener
{
 Session curSession;
 
 public proeSyncJDialogListener (Session session)
 {
 this.curSession = session;
 }
 
 public void OnCommand() throws jxthrowable
 { 
 Models modelsInSession = curSession.ListModels ();       //Retrieves all models in session
 
 String nameOfModels = "";         //Initialize String
 
 if(modelsInSession.getarraysize() == 0)
  nameOfModels = "No Models Present";
 else
 {  
  nameOfModels = modelsInSession.get(0).GetFullName();
  
  if(modelsInSession.getarraysize() > 1)
  for(int i=1; i<modelsInSession.getarraysize(); i++)
  {
   nameOfModels = nameOfModels + "\n" + modelsInSession.get(i).GetFullName();
  }
 }
 
 JOptionPane.showMessageDialog(new JFrame(), nameOfModels, "Models in Session", JOptionPane.INFORMATION_MESSAGE);
}
 
}

WF 3.0
XP Pro


Edited by: fiebigc
 
Turns out this is a quirk in JLink. It's mentioned in the "JLink User's Guide -> Sample Applications -> Testing the JLink Synchronous Installation" under the image of the dialog box. The solution they propose is to hit Alt-Tab to switch to the dialog.

I consider this very unacceptable. I want to write an app that will be deployed to many users in my company and having to teach each one to hit Alt-Tab the first time will only cause confusion.

Does anyone have any work arounds? The only one I could think of is to have the Java app perfom the Alt-Tab keystroke the first time the app opens, but this could prove to be problematic. Thanks.
 
This is a java issue, if you compile your app using java 1.5 + you can use
setAlwaysOnTop

e.g.
JDialog.setAlwaysOnTop(true);

you will also need to change the config.pro option jlink_java_command to use the 1.5 jre

e.g.

jlink_java_command C:\Program Files\Java\jre1.5.0_11\bin\java.exe
 
What I have done, is iconify the dialog and then maximize it. This brings it back to the front of the display.
 

Sponsor

Back
Top