The program do not open on top

HelloFrom my java program i'm calling another java program, but unfortunatly that second program, opens behind the main window of my program for the first time.closing that second application then calling it again opens it normally on top. any ideas
[278 byte] By [tleis] at [2007-9-30 16:24:16]
# 1
when your second program starts and up, make sure you call .toFront(); on your frame so it will come infront of your first app. If it doesn't work, write back and we'll think of something else. Good luck on yourprogram!
afarmand at 2007-7-6 0:06:51 > top of Java-index,Administration Tools,Sun Connection...
# 2
You are helping me too much, i don't know how to thank you afarmandi'm calling the second program using the code that you told me about:Runtime.getRuntime.exec("run.bat");where i should use the .inFront(); code?
tleis at 2007-7-6 0:06:51 > top of Java-index,Administration Tools,Sun Connection...
# 3

It's OK since I'm actively doing forum work now. I guess the best place to call .toFront() is the last place.

For example, import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

public class Demo extends Frame{

MenuBar menubar;

Menu menu1;

Menu subMenu;

MenuItem menuItem;

MenuItem subMenuItem;

Button button;

public Demo(){

setLayout(null);

menubar = new MenuBar();

setMenuBar(menubar);

menu1 = new Menu("Menu");

menubar.add(menu1);

menuItem = new MenuItem("Menu Item");

menu1.add(menuItem);

subMenu = new Menu("Sub Menu");

menu1.add(subMenu);

subMenuItem = new MenuItem("Exit");

subMenuItem.addActionListener(

new ActionListener(){

public void actionPerformed(ActionEvent e){

System.exit(0);

}

}

);

subMenu.add(subMenuItem);

button = new Button("button");

button.setSize(100, 25);

button.setLocation(4, 4);

add(button);

setSize(400, 300);

setVisible(true);

toFront();

}

public static void main(String[] args){

new Demo();

}

}

afarmand at 2007-7-6 0:06:51 > top of Java-index,Administration Tools,Sun Connection...
# 4

hi again,

my problem is that i'm calling a TWAIN application using GetTwain.java

I tried to include toFront(); in several locations but unfortunatly it didn't work.

GetTwain.java

:

import java.awt.Image;

import com.asprise.util.jtwain.Source;

import com.asprise.util.jtwain.SourceManager;

public class GetTwain extends JTwainCode{

public GetTwain() {

try {

Source source = SourceManager.instance().getDefaultSource();

if(source == null) {

error("There is no (default) source on the system!");

return;

}

source.open();

Image image = source.acquireImage();

new ImageDisplayer("GetTwain", image);

source.close();

}catch(Exception e) {

exception(e);

}finally{

SourceManager.closeSourceManager();

}

}

}

tleis at 2007-7-6 0:06:51 > top of Java-index,Administration Tools,Sun Connection...
# 5

that's some strange behaviour. So you're saying when you start your second app from your first app for the

first time, it shows up behind but when you start your second app again (from your first app), it shows up

in front? Here's another thing: why don't you get your first app to call .toBack(); after you've opened your

second app. That might help.

afarmand at 2007-7-6 0:06:51 > top of Java-index,Administration Tools,Sun Connection...
# 6
Calling toBack(); worked fine, but i'm facing another problem, calling that 2nd application, sends the first application to behind all the open windows. Isn't there another solution?
tleis at 2007-7-6 0:06:51 > top of Java-index,Administration Tools,Sun Connection...
# 7

I Found it :

when i call the second application, i send the first app to back, then call it to front after finishing from the 2nd app. the software will wait until i close the 2nd app. to call the 1st app to Front.

[code]:

button1.addActionListener(

new ActionListener() {

public void actionPerformed( ActionEvent event )

{

toBack();

new GetTwain();

toFront();

}

}

}

Thank you very much afermand

tleis at 2007-7-6 0:06:51 > top of Java-index,Administration Tools,Sun Connection...