English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

4 answers

An example of direct embedding of .NET contols into a Java GUI - in addition you should download a complete project to get real understanding http://www.codeproject.com/script/profile/logon.asp?ct=http%3A%2F%2Fwww%2Ecodeproject%2Ecom%2Fdotnet%2FJavaDOTNETIntegrate%2Easp&mode=1

The class MainFrame creates a SWING Frame Window with the FrameWindow object, which is used as a container for the .NET UserControl object and JButton which closes the application. To activate OOJNI in Java, the application loads the module OOJNIDOTNET.DLL first, then the other JNI modules can be loaded (.NET module CSharpInJava.DLL).

Collapse

import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JFrame;


public class MainFrame extends JFrame {
static{
System.loadLibrary("oojnidotnet");
System.loadLibrary("CSharpInJava");
}

FrameWindow canvas;
JButton okButton;
public MainFrame() {
super("qwerty");
initialize();
}
public void initialize(){
okButton = new JButton();
okButton.setText("Close");
getContentPane().setLayout(new BorderLayout());
getContentPane().add(canvas =
new FrameWindow(), BorderLayout.CENTER);
getContentPane().add(okButton, BorderLayout.SOUTH);
canvas.setBackground(Color.blue);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
System.exit(0);
}
});
okButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
System.exit(0);
}
});
pack();
setSize(200, 200);
}
public static void main(String args[]) {
new MainFrame().setVisible(true);
}
}

2007-03-17 23:52:16 · answer #1 · answered by smacksgalore 2 · 0 0

I think java virtual machine is another platform like dotnet framework. so its may not possible to integrate java objects into dotnet framework unless u go some root level coding. (like taking special care of the java object or creating that object from scratch using c++ or something like that.

2007-03-17 23:07:55 · answer #2 · answered by outlaw 2 · 0 2

no you can not- but why do you need it?

2007-03-17 23:41:38 · answer #3 · answered by Anonymous · 0 0

i dont think u can do this

2007-03-17 23:03:58 · answer #4 · answered by abd 5 · 0 1

fedest.com, questions and answers