> or how about this one.. how do you make an
> application lose focus... the whole application?
>
> =)
Deepends on what constitutes your application.
You could do it window by window.
Look, for example at JWindow Api where you will find how to create
windows with an owner Window which may or may not help you
> or how about this one... how do you simulate an
> (alt+tab) keyboard press using java?
Try awt.Robot. Don't know it it works, though.
Losing focus itelf won't help, it's gaining focus that makes a Window come to front, not losing focus that makes it go to the background. but you can still try frame.toBack().
> > or how about this one... how do you simulate an
> > (alt+tab) keyboard press using java?
>
> Try awt.Robot. Don't know it it works, though.
>
> Losing focus itelf won't help, it's gaining focus
> that makes a Window come to front, not losing focus
> that makes it go to the background. but you can still
> try frame.toBack().
that's basically my problem. i cannot get the focus of the newly spawned ie window... using frame.toBack will cause the applicaiton to go behind all the windows currently running.... hehehe
Are you doing somewthing after spawning IE? Because this works the way you want:
public class TestSomething {
public static void main(String[] args) {
JFrame f = new JFrame();
JButton b = new JButton("Hit Me");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
try {
Runtime.getRuntime().exec("cmd /c start http://www.google.fr");
} catch (IOException ex) {
ex.printStackTrace();
}
}
});
f.getContentPane().add(b);
f.setVisible(true);
}
}
> Are you doing somewthing after spawning IE? Because
> this works the way you want:
>
> public class TestSomething {
>
>public static void main(String[] args) {
>JFrame f = new JFrame();
>JButton b = new JButton("Hit Me");
>b.addActionListener(new ActionListener() {
> public void actionPerformed(ActionEvent
> actionEvent) {
>
> try {
> Runtime.getRuntime().exec("cmd /c start
> http://www.google.fr");
> } catch (IOException ex) {
>ex.printStackTrace();
>}
> }
>
>});
> f.getContentPane().add(b);
>f.setVisible(true);
>
>
> }
yes some thing very similar
public class Launcher
{
private JFrame frame = null;
private JButton button = null;
public Launcher() throws Exception
{
frame = new JFrame("some title");
frame.setSize(200,200);
frame.setLayout(new FlowLayout());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
button = new JButton("launch here");
robot = new Robot();
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
Runtime.getRuntime().exec("cmd.exe /c start deploy.js google.com");
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
});
frame.getContentPane().add(button);
frame.setVisible(true);
}
public static void main(String args[]) throws Exception
{
new Launcher();
}
}
i'm not realy sure why it wont work.. the ie will spawn behind the application