简体   繁体   English

如何实现支持拖放的用户界面?

[英]How can I implement a user interface that supports drag and drop?

I'm currently developing a Java application that converts information from analogue sensors to MIDI messages (and hopefully OSC in the future), which can then be routed to a music production program (Ableton Live, Pro Tools etc.). 我目前正在开发一个Java应用程序,该程序将信息从模拟传感器转换为MIDI消息(并希望在将来成为OSC),然后可以将其路由到音乐制作程序(Ableton Live,Pro Tools等)。

I'm a bit confused about how to implement the user interface though... An exact example of the kind of interface I would like to create is that of Reaktor (an application which allows you to build your own audio DSP units from small predefined modules). 我对如何实现用户界面感到有些困惑。我想创建的这种界面的一个确切例子是Reaktor(该应用程序允许您从小的预定义模块中构建自己的音频DSP单元。模块)。 Here is a link to a screenshot of the application: 这是应用程序屏幕截图的链接:

http://media.soundonsound.com/sos/jun02/images/reaktor06023.gif http://media.soundonsound.com/sos/jun02/images/reaktor06023.gif

Ideally, I would have onscreen components (shapes, rectangles, lines) representing software objects and how they are connected together. 理想情况下,我将拥有代表软件对象以及它们如何连接在一起的屏幕组件(形状,矩形,线条)。 The idea is that the user can drag and drop "modules" (which actually represent software objects) and wire them together and build a custom system. 这个想法是用户可以拖放“模块”(实际上代表软件对象)并将它们连接在一起并构建一个定制系统。 So for example, to convert a stream of sensor information to MIDI, they would drop a "Sensor Module" on to the screen, and wire the output into a "MIDI Converter Module", then wire the output of that into an "Output Module" or something similar. 因此,例如,要将传感器信息流转换为MIDI,他们会将“传感器模块”放到屏幕上,然后将输出连接到“ MIDI转换器模块”,然后将其输出连接到“输出模块”。 ”或类似的内容。

I probably haven't done a great job of explaining my problem, so please feel free to ask any questions for clarification. 我可能无法很好地解释我的问题,所以请随时提出任何问题进行澄清。

Thanks very much in advance! 首先十分感谢!

Chris 克里斯

It's not a hard thing. 这不是一件难事。 It's even documented in the official Java starter guides by Oracle. 甚至在Oracle的官方Java入门指南中都有记录。

http://docs.oracle.com/javase/tutorial/uiswing/dnd/ http://docs.oracle.com/javase/tutorial/uiswing/dnd/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM