这是本设计的一个更好的顶层容器中,用的JFrame Jpanels,或JDesktop中与JInternalFrames [英] Which is a better top level container for this design, JFrame with Jpanels, or JDesktop with JInternalFrames

查看:155
本文介绍了这是本设计的一个更好的顶层容器中,用的JFrame Jpanels,或JDesktop中与JInternalFrames的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与Swing和AWT初学者,我希望建立使用NetBeans的GUI。我的GUI需要三个方面,我目前想的是在JFrame JPanels。我需要一个绘图面板将侦听鼠标输入和借鉴的Java2D形状。绘图面板将被锚定到左上方。另外两个领域是一个属性滚动面板,和一个控制器滚动窗格。控制器面板将决定哪些绘制的元素将通过按钮来显示,并滚动属性面板将显示有关该被点击绘图窗格(端点,颜色等)任何形状物体的细节。

I'm a beginner with Swing and AWT, I'm looking to build a GUI using Netbeans. My GUI requires three areas, that I'm currently thinking of as JPanels on a JFrame. I require a "Drawing" panel that will listen for mouse input and draw Java2D shapes. The drawing panel will be anchored to the top left. The other two areas are a "Properties" scroll pane, and a "Controller" scroll pane. The controller pane will determine which drawn elements will be displayed via buttons, and the properties scroll pane will show details about any shape object that is clicked in the drawing pane (endpoints, color, etc..).

一个典型的用例的绘图区域是这样的,在绘图区域的第一次点击将是一个形状的第一套坐标,即:一条线。点击被捕获为Point2D对象。第二次点击将是第二Point2D对象,而生产线将在两者之间建立。控制器区域将有按钮的圆线Elipse,等等。根据点击它的控制器按钮,只有该类型的形状将在绘图区域绘制。控制器和属性滚动窗格不会移动,它们将被锁定,可调整大小以分别的底部和GUI的右侧。

A typical use case for the drawing area is such that the first click in the drawing area will be the first set of co-ordinates for a shape, IE: a line. That click will be captured as a point2d object. The second click will be the second point2D object, and a line will be built between the two. The controller area will have buttons like "Circle" "Line" "Elipse", etc. Depending on which controller button is clicked, only shapes of that type will be drawn in the drawing area. The controller and properties scroll panes will not be moveable, they will be locked and resizable to the bottom and right sides of the GUI, respectively.

作为一个初学者,我与使用最好的元件挣扎。我一直在阅读了关于JDesktop中和的JInternalFrame,但似乎我并不真正需要的一切。三JPanels一个简单的JFrame应该足够了吧?更具体地讲,我想我需要一个顶级的JFrame,有一个JPanel的绘图框架和两个JScrollPanels。我需要在绘图窗格中一个鼠标监听器来捕捉每次点击的坐标,和听众在控制面板各按钮。我可以把鼠标监听上一个JPanel,并绘制Java2D的形状,或者我需要在JPanel内部的不同(更好?)容器做我的画?

As a beginner, I'm struggling with the best components to use. I've been reading up on JDesktop and JInternalFrame, but it seems like I don't really need all that. A simple JFrame with three JPanels should suffice, right? More specifically, I think I need a top level JFrame, with a JPanel for the drawing frame and two JScrollPanels. I'll need a mouse listener on the drawing pane to capture the co-ordinates of each click, and listeners for each button in the control pane. Can I put a mouse listener on a JPanel, and draw Java2D shapes to it, or will I need a different (better?) container inside the JPanel to do my drawing?

推荐答案

GraphPanel 可能会给你一些想法构建这样的应用程序。

GraphPanel may give you some ideas for constructing such an application.

GraphPanel截图

这篇关于这是本设计的一个更好的顶层容器中,用的JFrame Jpanels,或JDesktop中与JInternalFrames的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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