在 Swing 应用程序中运行 SWT 组件 [英] Running SWT components within a Swing App

查看:48
本文介绍了在 Swing 应用程序中运行 SWT 组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人有任何尝试运行在 Swing 组件中托管的复杂 SWT UI 的经验.

I was wondering if anybody had any experience trying to run a complex SWT UI hosted inside a Swing component.

我已经设法进行了一个非常简单的演示,但如果其他人已经尝试并失败/成功做到这一点,那么从他们的经验中学习会很棒.

I've managed to get a very simple demo going but if anyone else has tried and failed / succeeded to do this it'd be great to learn from their experiences.

重申我的应用程序是一个 Swing 应用程序,我希望使用复杂的 SWT UI 组件(拖放、弹出窗口和对话框)——有人管理过这个吗?

So to reiterate my application is a Swing app I wish to make use of a complex SWT UI component (drag and drop, popup windows and dialogs) - anybody managed this?

推荐答案

我使用过 Swing 和 SWT,尽管之前从未在同一个应用程序/项目中使用过.

I've used both Swing and SWT, although never in the same application/project before.

只要您不尝试在同一个窗口中将组件混合在一起,我看不出有任何理由您不能使用特定的小部件集来拥有完全独立的窗口/对话框.然而,试图在单个窗口中混合 SWT 和 Swing 可能永远不会奏效,或者至少会导致很多问题,因为这两个小部件集依赖于完全不同的绘制/布局方式——Swing 的组件都是直接在 Java 中处理的,并且是与底层操作系统完全分离,而 SWT 明确依赖底层操作系统来完成所有(或大部分)GUI 渲染.试图将两者混合可能会导致各种问题.

As long as your not trying to mix components together within the same windows I don't see any reason you can't have completely separate windows/dialogs each using a specific widget set. However, trying to mix SWT and Swing within a single window would likely never work, or at the very least cause lots of problems since both widget sets rely on completely different means of drawing/layout - Swing's components are all handled directly within Java and are completely separated from the underlying OS, while SWT explicitly relies on the underlying OS to do all (or most) of the GUI rendering. Trying to mix the two would likely cause all kinds of problems.

当然,我也会抛出通常的这不是推荐的做法"的回答:除非您在这里有一些非常具体的目标,否则在同一个应用程序中混合不同的小部件集不是一个好主意.Swing 和 SWT 有两种完全不同的哲学和底层架构.事实上,SWT 的诞生源于 IBM/OTI 不喜欢 Swing 所采用的方法,因此选择实现他们自己的小部件.使用这种对比鲜明的 GUI 小部件方法,您最好选择一种并坚持使用,而不是将两者混合在一起.

Of course, I'll throw out the usual "this isn't a recommended practice" response as well: Unless you have some really specific goal in mind here, mixing different widget sets in the same application is not a good idea. Swing and SWT have two completely different philosophies and underlying architectures. In fact SWT was born from the fact that IBM/OTI did not like the approach that was taken with Swing and so chose to implement their own widgets. With such contrasting approaches to GUI widgets, you're better off just choosing one and sticking with it, rather than mingling the two together.

这篇关于在 Swing 应用程序中运行 SWT 组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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