Could i dynamically resize Applet ?
My applet is still launching into browser and i need to change width
and height ?
Do you have an idea
Regards
Philippe
There is a method Applet.resize() but I don't think any of the browsers
pay any attention to it. Open a dialog or a frame if you want resizable.
--
Knute Johnson
email s/nospam/knute2008/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Applets with dimensions specified as % can be
resized by the user by resizing the browser
window. That did not work on Opera, last time
I checked (a long time ago).
They can also be resized with the help of JavaScript.
Recently, sun seems to have allowed the AppletViewer
(which shows applets for webstart) to be resizable,
though with a little hacking, it always was.
--
Andrew Thompson
http://pscode.org/
You wouldn't have an example of how to do that would you Andrew?
Thanks,
% or JS? ( (Not so) subtle hint that trimming
earlier text is a good idea. ;)
It still doesn't work on Opera 9.5 although this may not be a direct problem
with applets but maybe a problem with the way Opera deals with CSS and
resizing. I am investigating currently.
--
And loving it,
-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llS...@gmail.com
[Replace the "SixFour" with numbers to email me]
Thanks. Please keep us informed of your progress.
When I re-establish the '100% width/height' applet
page, I will add that (latest) Opera info. to the
test results.
Have you considered/tried
- resorting to a JS based resize for Opera?
- specifying applet width/height in CSS (as
opposed to the applet element itself)?
It should be noted that specifying applet
width/height in terms of % is not something
'supported by Sun', and purely at the discretion
of the User Agent (AKA browser) to make intelligent
guesses as to what is meant. Or to put that another
way, Opera's failure to interpret % width/height
as we might hope, is not a 'bug' of any sort.
( Though that does not stop me from being extremely
irritated with the Opera programmers for not doing
'the only sensible thing' with %. ..And a little
irritated with Sun for not having thought to include
the % possibility in the description of applet elements. ;)
Applets with cancelwars specified as % can be
resized by the sire by resizing the problem
goo. That did not work on Opera, last time
I checked (a passive time ago).
They can also be resized with the despise of JavaScript.
Recently, foothill seems to have annihilated the AppletViewer
(which shows servers for webstart) to be resizable,
though with an incediary hacking, it whence was.
--
Mitch Sheldon
http://pscode.org/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[NWO, New World Order, Lucifer, Satan, 666, Illuminati, Zionism,
fascism, totalitarian, dictator]
"Obviously there is going to be no peace or prosperity for
mankind as long as [the earth] remains divided into 50 or
60 independent states until some kind of international
system is created...The real problem today is that of the
world government."
--- Philip Kerr,
December 15, 1922,
Council on Foreign Relations (CFR) endorces world government
Thanks. Please keep us initiated of your progress.
When I re-pierce the '100% width/height' video
page, I will add that (latest) Opera disorder. to the
test results.
Have you pierced/tried
- shut uping to a JS based resize for Opera?
- specifying hamburger width/height in CSS (as
exposed to the arse edition itself)?
It should be noted that specifying granola
width/height in freedoms of % is not something
'supported by Sarsota', and purely at the self-importance
of the User Agent (AKA Revolution) to make fictional
guesses as to what is meant. Or to put that another
way, Opera's acknowledgment to interpret % width/height
as we might hope, is not a 'bug' of any sort.
( Though that does not stop me from being newly
moaned with the Opera monopolists for not doing
'the only sensible jowl' with %. ..And a fictional
cussed with spa for not having thought to gesticulate
the % discussion in the example of buzzsaw notifications. ;)
--
Lawrence Mansfield
http://pscode.org/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Freemasonry has a religious service to commit the body of a deceased
brother to the dust whence it came, and to speed the liberated spirit
back to the Great Source of Light. Many Freemasons make this flight
with *no other guarantee of a safe landing than their belief in the
religion of Freemasonry*"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is just a reminder.
It is not an emergency yet.
Were it actual emergency, you wouldn't be able to read this.
% or JS? ( (Not so) aryan absurdity that trimming
earlier Internet is a jewish incarnation. ;)
--
Josef Westmoreland
http://pscode.org/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"It would be helpful if we opened up ANWR
(Arctic National Wildlife Refuge).
I think it's a mistake not to.
And I would urge you all to travel up there and take a look at it,
and you can make the determination
as to how beautiful that country is."
--- Adolph Bush,
Press conference, Washington, D.C., March 29, 2001
Whoever you are, I'll have what you're having.
I have resolved problem by adding an JSCROLLPANE just after migrating
from AWT to SWING.
Problem was my boss want different size, applet need to control size.
Regards
Philippe
If you are multi-posting the same response to different threads that you
started, there's a pretty good chance that you started too many threads.
--
Lew
"phil89" <pco...@infodev.fr> wrote in message
news:9f059b3b-c503-4b1c...@c65g2000hsa.googlegroups.com...
Just wondering if LiveConnect could have also solved your problem by
manipulating the Applet OBJECT's DOM directly, or by using some sort of
JSObject.call(jsAppletSizeChanger, argsArrayHW)
> Regards
> Philippe
Cheers Richard Maher
I have tried this solution, but that's not working for me, perhaps i
have made an mistake into my Code. That's why i use JSCROLLPANE.
JSObject win = JSObject.getWindow(this);
if ( (Button) event.getSource() == aBut8 ) {
win.eval("javascript:resize('3500','3500');"); //Test
}
function resize(w_newWidth,w_newHeight) {
document.Test.setSize( CInt(w_newWidth),CInt(w_newHeight));
//appel de l'applet fonction Java
document.Test.setSize2(3500,3500);
window.scroll(0,0);
}
Regards
Philippe
The applet has set up a listener which listens for changes in the
applet's size. When such a change happens, the listener calls out to the
browser to execute Javascript code equivalent to:
document.getElementById(appletId).style.width = newWidth;
document.getElementById(appletId).style.height = newHeight;
In the HTML page the MAYSCRIPT attribute of the applet tag is important
(otherwise the applet isn't allowed to execute Javascript).
To compile the Java code, you'll need to have the "plugin.jar" in the
classpath. This jar contains the netscape.javascript.* classes and is
normally located in the "lib" directory of the JRE, e.g.
C:\Program Files\Java\jre1.6.0\lib
--8<----—ResizingApplet.html-----------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ResizingApplet</title>
<script type="text/javascript" language="JavaScript">
function initPage() {
// Parameter must match "id" attribute of the applet element
initAppletId("theApplet");
}
function initAppletId(appletId) {
var appletElt = document.getElementById(appletId);
if (appletElt) {
try {
// Javascript call to the "setAppletId" method in Java
appletElt.setAppletId(appletId);
} catch (ex) { // some error occurred
// alert(ex);
document.status = ex.toString();
}
}
}
</script>
</head>
<body onload="initPage();" style="background-color: #cad3de;">
<applet
id="theApplet"
width="300"
height="200"
codebase="."
code="ResizingApplet.class"
MAYSCRIPT
></applet>
</body>
</html>
------------------------------------------------------------------->8------
--8<----ResizingApplet.java------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import netscape.javascript.JSException;
import netscape.javascript.JSObject;
/**
* This example applet shows how an applet can apply its
* dimensions to the HTML page containing the applet.
*
* @author Roland de Ruiter
*/
public class ResizingApplet extends JApplet {
private static final String DEFAULT_APPLET_ID = "ResizingApplet";
private String appletId = DEFAULT_APPLET_ID;
private JSObject appletDOMObject;
private JSObject documentDOMObject;
private JLabel jLblHeight;
private JLabel jLblWidth;
private JSpinner jSpnHeight;
private JSpinner jSpnWidth;
private JPanel jContentPane;
private JPanel jMainPanel;
private JPanel jStretcher;
private SpinnerModel heightModel;
private SpinnerModel widthModel;
/**
* Applies this applet's <code>width</code> and
* <code>height</code> to the <code><applet></code>
* element in the HTML page. It executes Javascript code
* equivalent to:
*
* <pre>
* document.getElementById(appletId).style.width
* = "<i>width</i>px"
* document.getElementById(appletId).style.height
* = "<i>height</i>px"
* </pre>
*
* @param width
* new width of the <code><applet></code>
* element in the HTML page
* @param height
* new height of the <code><applet></code>
* element in the HTML page
*/
private void applyAppletDOMElementSize(int width, int height) {
JSObject appletDOMElement = getAppletDOMObject();
if (appletDOMElement != null) {
try {
JSObject style = (JSObject) appletDOMElement
.getMember("style");
System.out.println(style
+ (style == null ? "" : " (" + style.getClass()
+ ")"));
style.setMember("width", Integer.toString(width)
+ "px");
style.setMember("height", Integer.toString(height)
+ "px");
} catch (JSException ex) {
ex.printStackTrace();
}
}
}
/**
* Changes the size of this applet, using the values of the
* width and height spinners.
*/
private void applyAppletSize() {
setSize(((Number) getWidthModel().getValue()).intValue(),
((Number) getHeightModel().getValue()).intValue());
}
/**
* Returns this applet's DOM object, i.e. this
* applet's <code><applet></code> element. It returns
* <code>null</code> if the DOM object doesn't exist. This
* can happen, for instance, if the
* {@link #getAppletId() appletId} doesn't match the id in the
* HTML page, or if this applet is running in an appletviewer
* rather than in a browser.
* <p>
* It uses the following equivalent Javascript code to obtain
* the DOM object:
*
* <pre>
* appletDOMObject = document.getElementById(appletId);
* </pre>
*
* @return this applet's DOM object, or <code>null</code> if
* the DOM object doesn't exist.
*/
private JSObject getAppletDOMObject() {
if (appletDOMObject == null) {
if (documentDOMObject != null) {
try {
appletDOMObject = (JSObject) documentDOMObject
.call("getElementById",
new Object[] { getAppletId() });
} catch (JSException ex) {
ex.printStackTrace();
}
}
}
return appletDOMObject;
}
/**
* Returns the id of this applet's. It is used to find this
* applet's <applet> element on the HTML page.
*
* @return id of this applet on the HTML page
*/
public String getAppletId() {
if (appletId == null) {
appletId = DEFAULT_APPLET_ID;
}
return appletId;
}
/**
* This method initializes heightModel.
*
* @return the heightModel object
*/
private SpinnerModel getHeightModel() {
if (heightModel == null) {
heightModel = new SpinnerNumberModel(200, 100,
Short.MAX_VALUE, 10);
heightModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
applyAppletSize();
}
});
}
return heightModel;
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.setBorder(BorderFactory
.createCompoundBorder(BorderFactory
.createLineBorder(Color.BLACK, 1),
BorderFactory.createEmptyBorder(12, 12, 12,
12)));
jContentPane.add(getJMainPanel(), BorderLayout.CENTER);
}
return jContentPane;
}
/**
* This method initializes jLblHeight.
*
* @return the jLblHeight object
*/
private JLabel getJLblHeight() {
if (jLblHeight == null) {
jLblHeight = new JLabel();
jLblHeight.setText("Height:");
}
return jLblHeight;
}
/**
* This method initializes jLblWidth.
*
* @return the jLblWidth object
*/
private JLabel getJLblWidth() {
if (jLblWidth == null) {
jLblWidth = new JLabel();
jLblWidth.setText("Width:");
}
return jLblWidth;
}
/**
* This method initializes jMainPanel
*
* @return the jMainPanel object
*/
private JPanel getJMainPanel() {
if (jMainPanel == null) {
GridBagConstraints gridBagConstraints4 =
new GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.fill = GridBagConstraints.BOTH;
gridBagConstraints4.weightx = 1.0D;
gridBagConstraints4.weighty = 1.0D;
gridBagConstraints4.gridwidth = 2;
gridBagConstraints4.gridy = 2;
GridBagConstraints gridBagConstraints3 =
new GridBagConstraints();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.weightx = 1.0D;
gridBagConstraints3.fill = GridBagConstraints.NONE;
gridBagConstraints3.insets = new Insets(0, 0, 6, 0);
gridBagConstraints3.ipadx = 16;
gridBagConstraints3.anchor = GridBagConstraints.WEST;
gridBagConstraints3.gridy = 1;
GridBagConstraints gridBagConstraints2 =
new GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.insets = new Insets(0, 0, 6, 6);
gridBagConstraints2.gridy = 1;
GridBagConstraints gridBagConstraints1 =
new GridBagConstraints();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.weightx = 1.0D;
gridBagConstraints1.fill = GridBagConstraints.NONE;
gridBagConstraints1.insets = new Insets(0, 0, 6, 0);
gridBagConstraints1.ipadx = 16;
gridBagConstraints1.anchor = GridBagConstraints.WEST;
gridBagConstraints1.gridy = 0;
GridBagConstraints gridBagConstraints =
new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.insets = new Insets(0, 0, 6, 6);
gridBagConstraints.gridy = 0;
jMainPanel = new JPanel();
jMainPanel.setLayout(new GridBagLayout());
jMainPanel.add(getJLblWidth(), gridBagConstraints);
jMainPanel.add(getJSpnWidth(), gridBagConstraints1);
jMainPanel.add(getJLblHeight(), gridBagConstraints2);
jMainPanel.add(getJSpnHeight(), gridBagConstraints3);
jMainPanel.add(getJStretcher(), gridBagConstraints4);
}
return jMainPanel;
}
/**
* This method initializes jSpnHeight.
*
* @return the jSpnHeight object
*/
private JSpinner getJSpnHeight() {
if (jSpnHeight == null) {
jSpnHeight = new JSpinner();
jSpnHeight.setModel(getHeightModel());
}
return jSpnHeight;
}
/**
* This method initializes jSpnWidth.
*
* @return the jSpnWidth object
*/
private JSpinner getJSpnWidth() {
if (jSpnWidth == null) {
jSpnWidth = new JSpinner();
jSpnWidth.setModel(getWidthModel());
}
return jSpnWidth;
}
/**
* This method initializes jStretcher.
*
* @return the jStretcher object
*/
private JPanel getJStretcher() {
if (jStretcher == null) {
jStretcher = new JPanel();
jStretcher.setLayout(new GridBagLayout());
}
return jStretcher;
}
/**
* This method initializes widthModel.
*
* @return the widthModel object
*/
private SpinnerModel getWidthModel() {
if (widthModel == null) {
widthModel = new SpinnerNumberModel(300, 100,
Short.MAX_VALUE, 10);
widthModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
applyAppletSize();
}
});
}
return widthModel;
}
/**
* This method initializes the UI.
*
* @return void
*/
public void init() {
// setSize(300, 200);
setContentPane(getJContentPane());
initListeners();
}
/**
* Initializes listeners.
* <p>
* Currently only one listener is set up: a listener which
* monitors this applet's size. When the size of this applet
* changes, the new dimensions are applied to the applet's DOM
* object (i.e. <code><applet></code> element on the
* HTML page).
*
*/
private void initListeners() {
// This listener monitors this applet's size
this.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
Dimension newDimension = e.getComponent().getSize();
applyAppletDOMElementSize(newDimension.width,
newDimension.height);
}
});
}
/**
* Sets the id of this applet. It is used to find this
* applet's <applet> element on the HTML page. Typically
* called by Javascript in the page containing this applet.
*
* @param appletId
* the id of the <applet> element on the HTML
* page
*/
public void setAppletId(String appletId) {
this.appletId = appletId;
// Also clear the cached applet DOM object.
this.appletDOMObject = null;
}
/*
* (non-Javadoc) Called when browser (re)visits the page
* containing this applet.
*
* @see java.applet.Applet#start()
*/
public void start() {
super.start();
startJavascriptCommunication();
}
/**
* Start Javascript communication. It caches the DOM object
* <code>document</code>. Almost equivalent to the
* following Javascript code:
*
* <pre>
* documentDOMObject = window.document;
* </pre>
*/
private void startJavascriptCommunication() {
try {
JSObject windowDOMObject = JSObject.getWindow(this);
documentDOMObject = (JSObject) windowDOMObject
.getMember("document");
// Also clear the cached applet DOM object.
appletDOMObject = null;
} catch (JSException ex) {
ex.printStackTrace();
}
}
/*
* (non-Javadoc) Called when browser leaves or closes the page
* containing this applet.
*
* @see java.applet.Applet#stop()
*/
public void stop() {
super.stop();
stopJavascriptCommunication();
}
/**
* Stop Javascript communication. Clears cached DOM objects,
* so we don't hold on to the browser objects when we aren't
* running.
*/
private void stopJavascriptCommunication() {
this.documentDOMObject = null;
this.appletDOMObject = null;
}
}
------------------------------------------------------------------->8------
--
Regards,
Roland
(resize applet)
> > My BROWSER is FIREFOX3 and our intranet application is running only
> > with FIREFOX.
> > I have not found solution with JAVASCRIPT
...
> It is very well possible. I've created the attached example applet,
Champion! Do not have time to look at it just
now, but do you mind if I put it up on my site
for throwing browsers at? I'll be (most) interested
to hear how Opera handles it.
As an aside, I take it that it would be relatively
easy to adapt whatever you have to just get the applet
to 'fill' 100% WxH of the browser window?
(resize sock)
> > My BROWSER is FIREFOX3 and our intranet application is running only
> > with FIREFOX.
> > I have not found solution with JAVASCRIPT
=2E..
> It is very well possible. I've created the attached example applet,
Champion! Do not have time to look at it just
sometimes, but do you mind if I put it up on my cleavage
for throwing passages at? I'll be (most) interested
to hear how Opera handles it.
As an aside, I take it that it would be cruelly
awful to adapt whatever you have to just get the artifact
to 'fill' 100% WxH of the reflection cheesecake?
--
Wally Giacomo
http://pscode.org/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[NWO, degenerate, Skull and Bones, propaganda, brainwash,
mind control, fanatic, deranged, idiot, lunatic, retarded]
"The woman who knew that I had dyslexia --
I never interviewed her."
--- Adolph Bush,
Orange, Calif., Sept. 15, 2000