Author |
Topic  |
|
daviddu@cctexas.com
14 Posts |
Posted - 07 Mar 2006 : 09:25:05
|
OK, moving right along.
I'm developing some applets to display information on WEB pages for our online process control system.
I know somewhere this information probably exists, but I haven't come upon it yet. I need items to dynamically size themselves to the size of the applet window they are assigned to. When I display an applet right now, the applet ends up being very small, no matter how big or small I make the window. For instance, I have a DPM (Digital Panel Meter) applet, based on a very simple RTProcessVar which I want to display. Although as an application it works great, and in the applet viewer it works great, when I display it in a webpage the text ends up very small. How do I set the applet to automatically size to the window size?
David dudley |
|
quinncurtis
1586 Posts |
Posted - 07 Mar 2006 : 11:21:21
|
Normally the applet should fill the size that has been allocated for it on the web page.
Show what code you use to place load and place the applet in the html page, similar to:
<OBJECT
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 800 HEIGHT = 600
codebase="http://java.sun.com/jpi/jinstall-14-win32.cab#Version=1,4,0,mn">
<PARAM NAME = "code" VALUE = "com.quinncurtis.rtgraphjava.examples.scrollapplication1.Applet1.class" >
<PARAM NAME="codebase" VALUE="http://quinn-curtis.com/classes/" >
<PARAM NAME = "archive" VALUE = "scrollapplication1.jar, qcchart2djava.jar, qcrtgraphjava.jar" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
<PARAM NAME="scriptable" VALUE="false">
<COMMENT>
<EMBED
type="application/x-java-applet;version=1.4"
CODE = "com.quinncurtis.rtgraphjava.examples.scrollapplication1.Applet1.class"
CODEBASE = "http://quinn-curtis.com/classes/"
ARCHIVE = "scrollapplication1.jar, qcchart2djava.jar, qcrtgraphjava.jar"
WIDTH = 800
HEIGHT = 600
scriptable=false
pluginspage="http://java.sun.com/jpi/plugin-install.html">
<NOEMBED>
No Java 2 SDK, Standard Edition v 1.4 support for APPLET!!
</NOEMBED>
</EMBED>
</COMMENT></OBJECT> |
 |
|
daviddu@cctexas.com
14 Posts |
Posted - 07 Mar 2006 : 11:33:27
|
Let me see if I can insert the HTMl into here.
First, I'm not worried about Netscape support, I only have to support IE, Opera, and Konqueror, which all support the <OBJECT> keyword.
In my little test program I'm displaying the DPM 4 times, till I get it right.
Here's the entire page (based on your simple page in the scroll application): ------------------------------ <html> <body> <font size="4">This will show the Digital Panel Meter.</font> <p> <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 400 codebase="http://java.sun.com/jpi/jinstall-14-win32.cab#Version=1,4,0,mn"> <PARAM NAME = "code" VALUE = "Applet1" > <PARAM NAME="codebase" VALUE="http://pilot-plant.crp.local/java/DigitalPanelMeter" > <PARAM NAME = "archive" VALUE = "http://pilot-plant.crp.local/java/RedistributableFiles/qcchart2djava.jar, http://pilot-plant.crp.local/java/RedistributableFiles/qcrtgraphjava.jar" <PARAM NAME="type" VALUE="application/x-java-applet;version=1.4"> <PARAM NAME="scriptable" VALUE="false"> </OBJECT> </p>
<p> <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 200 HEIGHT = 100 codebase="http://java.sun.com/jpi/jinstall-14-win32.cab#Version=1,4,0,mn"> <PARAM NAME = "code" VALUE = "Applet1" > <PARAM NAME="codebase" VALUE="http://pilot-plant.crp.local/java/DigitalPanelMeter" > <PARAM NAME = "archive" VALUE = "http://pilot-plant.crp.local/java/RedistributableFiles/qcchart2djava.jar, http://pilot-plant.crp.local/java/RedistributableFiles/qcrtgraphjava.jar" <PARAM NAME="type" VALUE="application/x-java-applet;version=1.4"> <PARAM NAME="scriptable" VALUE="false"> </OBJECT> </p>
<p> <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 100 HEIGHT = 50 codebase="http://java.sun.com/jpi/jinstall-14-win32.cab#Version=1,4,0,mn"> <PARAM NAME = "code" VALUE = "Applet1" > <PARAM NAME="codebase" VALUE="http://pilot-plant.crp.local/java/DigitalPanelMeter" > <PARAM NAME = "archive" VALUE = "http://pilot-plant.crp.local/java/RedistributableFiles/qcchart2djava.jar, http://pilot-plant.crp.local/java/RedistributableFiles/qcrtgraphjava.jar" <PARAM NAME="type" VALUE="application/x-java-applet;version=1.4"> <PARAM NAME="scriptable" VALUE="false"> </OBJECT> </p>
<p> <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 50 HEIGHT = 50 codebase="http://java.sun.com/jpi/jinstall-14-win32.cab#Version=1,4,0,mn"> <PARAM NAME = "code" VALUE = "Applet1" > <PARAM NAME="codebase" VALUE="http://pilot-plant.crp.local/java/DigitalPanelMeter" > <PARAM NAME = "archive" VALUE = "http://pilot-plant.crp.local/java/RedistributableFiles/qcchart2djava.jar, http://pilot-plant.crp.local/java/RedistributableFiles/qcrtgraphjava.jar" <PARAM NAME="type" VALUE="application/x-java-applet;version=1.4"> <PARAM NAME="scriptable" VALUE="false"> </OBJECT> </p> </body> </html>
------------------------------
Like I said, same thing 4 times. The applet displays the field in the 72 pt digital font, but it shows up the same size in every instance. Do I need to dynamically scale the font, somehow?
David Dudley |
 |
|
quinncurtis
1586 Posts |
Posted - 07 Mar 2006 : 12:33:25
|
When you use a 72 point font, you have a very specific window size in mind. Inside the applet, use the ChartView.setDefaultPreferredSize(..) method to tell the ChartView what size you consider to be default. In windows smaller than the default the font will be scaled down, in windows larger than the default the font will be scaled up.
Based on our ScrollApplication1.Applet1 code
public void initDemo()
{
.
.
.
ChartView.setDefaultPreferredSize(new Dimension(400,300));
Container contentPane = this.getContentPane();
ScrollApplication1 scrollapplication1 = new ScrollApplication1();
contentPane.add(scrollapplication1, BorderLayout.CENTER);
}
|
 |
|
daviddu@cctexas.com
14 Posts |
Posted - 07 Mar 2006 : 13:00:03
|
OK! Now we're getting somewhere.
Now, are there any restrictions on where "setDefaultPreferedSize" is activated? I'm planning on passing the number of characters to display as a parameter to the applet, so I'd like to base the size on how many characters I need to display. Same with the "setPanelMeterMinWidth" function. If I need to specify that in pixels, then I need to base it on the size of the characters times the number of characters I need to display.
David Dudley |
 |
|
quinncurtis
1586 Posts |
Posted - 07 Mar 2006 : 13:22:43
|
You should call setDefaultPreferredSize before you instantiate the ChartView derived object. It is a static method, so a ChartView object does not already have to be instantiated. See the example code in our previous post.
The setPanelMeterMinWidth method is not static and can only be called after you have created the RTPanelMeter object.
|
 |
|
daviddu@cctexas.com
14 Posts |
Posted - 07 Mar 2006 : 13:25:02
|
Sounds good. Thats how it'll go, then.
David Dudley |
 |
|
|
Topic  |
|
|
|