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();
}
}
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();
}
}
}
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.
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