[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

VB & Java

I want to create a Java Applet. Drop it on a VB form. Compile it and have the applet work. Can this be done? And if so how?
0
MarkW
Asked:
MarkW
  • 2
1 Solution
 
Jason_GCommented:
Hi Mark,
This is about the only thing I could find in MSDN in reference to applets, and it talks about Visual Basic scripting edition.

***************************************************
*Visual Basic, Scripting Edition, and Java Applets*
***************************************************
Visual Basic, Scripting Edition, is yet another implementation of Microsoft Visual Basic;

this version allows developers to write programs—known as scripts—inside an HTML document.

A Visual Basic, Scripting Edition, program can call any public member of a Java applet. For

example, I could create a Java class.

public class Alarm extends Applet
{
    private int m_nVolume;

    public void setVolume(int v)
    {
        m_nVolume = v;
    }
}
I could then include the applet in an HTML document.

<APPLET CODE="Alarm.class" IS=ringer>
Then I could call setVolume from a script.

<SCRIPT language="VBScript">
<!--
Sub setLowVolume
    document.ringer.setVolume 10
End Sub

Sub setHighVolume
    document.ringer.setVolume 100
End Sub
-->
</SCRIPT>
The term document identifies the location of the ringer object, which is part of the web

page. What I’ve done above isn’t COM programming; I’m simply using Visual Basic, Scripting

Edition, to communicate between the web page and the applet. But as you’ll see, this

mechanism is quite useful in connecting Java applets to ActiveX controls.

I hope this helped.

Sincerely,
Jason

Jason Gorman (jason_gorman@scholars.com)
Learning Advisor, scholars.com
Microsoft Authorized Technical Education Center
Novell Authorized Online Training Provider
http://scholars.com

0
 
Answers2000Commented:
You need IE-4 installed on the same PC.

1. Use the Web Browser control (SHDOCVW.DLL), insert this into your form.
2. Make a dummy HTML page which references the applet (just like if you were putting the applet on the web).  Save this as a file.
3. Use the Navigate function in the Web Browser control to bring up the dummy HTML page.  [it can navigate to local files as well as web sites]

Incidentally the dummy HTML file can either be distributed with your app, be on a web site somewhere or you can create a local file using the VB file functions (HTML pages are just ASCII text after all)
0
 
Answers2000Commented:
Actually IE v3 will work too.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now