如何在Java组件中嵌入Windows程序 [英] How to embed a windows program inside java component

查看:62
本文介绍了如何在Java组件中嵌入Windows程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上做了一些运气不好的研究,而且似乎看不到类似的问题.

I have done a little research online with no luck, and I cant seem to see a question on SO similar to this.

我想知道是否可以将Windows程序放入jFrame或jWindow中.我想到的一个特定示例是,如果要创建一个jFrame,是否可以生成一个Windows程序以打开(即cmd.exe)并将该窗口嵌入到我的jFrame中某个位置.希望下面的图片描绘了Im想要达到的目标.

I wanted to know if its possible to place a windows program to fit inside a jFrame or jWindow. The particular example I had in mind was if I were to create a jFrame, can I spawn a windows program to open (i.e. cmd.exe) and embed that window within my jFrame somewhere. Hopefully the following image depicts what Im trying to acheive.

推荐答案

在此站点上已经有人问过这个问题,而且据我所知,答案总是一样的:虽然是的,从理论上讲是可行的,这非常难以实现,尤其是因为Java Swing使用的轻量级组件不是由OS创建的,而是由Swing本身创建的.如果您使用的语言可以使您与操作系统紧密结合,例如C#(如果使用Windows或Windows的C/C ++以及大多数其他功能),那会更好.

This has been asked before several times on this site, and always, as far as I can recall the answer is the same: while yes this is theoretically feasible, it is extraordinarily difficult to implement, especially since Java Swing uses light weight components that are not created by the OS, but created by the Swing itself. You would be better off using a language that allows you to get tighter with the operating system such as C# if Windows or C/C++ with Windows and most everything else.

所以我的最终答案是:对于Java Swing GUI来说,这是不切实际的.

So my final answer: this is not practical with Java Swing GUI's.

修改
请注意,如果您要做的只是从命令行流式传输输出,可以通过将其显示在JTextField或JEditPane或JTextPane中来完成.为此,无需在GUI中嵌入OS窗口.

Edit
Note that if all you want to do is to stream output from the command line, this can be done by displaying it in a JTextField or JEditPane or JTextPane. There is no need to embed an OS window into the GUI for this.

这篇关于如何在Java组件中嵌入Windows程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆