• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applets opening a browser of a particular size

 
peter cooke
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has to be obvious to people that do alot of AWT.
I have an AWT application that:
1)when a particular event occurs in the applet(such as a button being pressed).
2)the applet must lauch a new browser window to a particular URl and the new window must be of a particular size.

I can open a new window, but I cannot figure out how to control the dimensions of the browser.

import java.applet.Applet;
import java.applet.AppletContext;
import java.net.MalformedURLException;
import java.net.URL;
/*
* Created on Apr 6, 2004
*/
/**
* @author pmcooke
*
*/
public class AwtComponents extends Applet {
private java.awt.Button ivjButton1 = null;
public AwtComponents() {
super();
initialize();
}
/**
* Return the Button1 property value.
* @return java.awt.Button
*/
private java.awt.Button getButton1() {
if (ivjButton1 == null) {
ivjButton1 = new java.awt.Button();
ivjButton1.setName("Button1");
ivjButton1.setLabel("Button");
ivjButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("hello world");
AppletContext appletContext = getAppletContext();
try {
URL url = new URL("http://localhost:9080/foo/bar.html");
appletContext.showDocument(url, "_blank");

}
catch (MalformedURLException e1) {
e1.printStackTrace();
}
}
});
}
return ivjButton1;
}
/**
* Initialize the class.
*/
private void initialize() {
this.setName("Frame1");
this.setLayout(new java.awt.FlowLayout());
this.setBounds(45, 25, 270, 227);
this.add(getButton1(), getButton1().getName());
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic