Java GUI 中的问题 [英] Problem in Java GUI

查看:33
本文介绍了Java GUI 中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读我的问题之前,先看看这个GUI图.

Before reading about my problem, first look at this GUI Diagram.

顶部有三个栏,如下所示:

There are three bars at the top as follows:

  • 有按钮图片视图"、文本视图"等
  • 第二个按钮是流程"、组织"等
  • 第三个按钮应用到进程"等

然后是两个信息栏.

然后是一个显示图表的画布窗口.​​

After that a canvas window displaying the diagram.

现在,我想要一个与此类似的 GUI,具有以下功能(相对于上图):

Now, I want a GUI similar to this with the following features (relative to the above diagram):

  • 起初,只出现第一个栏,在它下方出现一个没有图表的白色空白画布,遍布整个 GUI.

  • At first, only first bar appears and below it a white blank canvas having no diagram appears spreading all over the GUI.

当用户点击图片视图"按钮时,第二个栏出现在第一个栏的下方,然后是相同的画布,没有图表在剩余空间上蔓延

When the user clicks on the "pictorial view" button the second bar appears below the first bar and after that the same canvas without diagram spreading over the remaining space

当用户点击第二个栏上的应用程序"按钮时,第三个栏出现在第二个栏的下方,之后相同的空白画布散布在 GUI 中的剩余空间.

When the user clicks on the "application" button on the second bar, the third bar appears below the second bar, and after that the same empty canvas spreading over the remaing space in the GUI.

我曾尝试通过首先拥有一个带有 BorderLayout 的主面板"来实现它.之后如下图所示:

I had tried to implement it by first having a "main panel" with BorderLayout. After that as showing in the following figure:

mainPanel(Border Layout)
|
|--topPanel (at NORTH of the mainPanel's Border Layout)
|
|
|--centerPanel (at CENTER of the mainPanel's Border Layout)

topPanel - 包含所有栏(当用户单击按钮时应动态添加栏)

topPanel - to contain all the bars (bars should be added dynamically when a user clicks on a button)

centerPanel - 包含画布并在 topPanel 中添加新条时自动调整其大小

centerPanel - to contain the canvas and adjust its size automatically when new bars are added in the topPanel

推荐答案

我会为应用程序使用 BorderLayout,工具栏位于偏北的窗格中.

I would use a BorderLayout for the app, with the toolbars in a northerly pane.

那个北窗格我会给出一个垂直的 BoxLayout 并将 3 个工具栏放入 3 个连续的框中.那应该注意几何形状.

That north pane I'd give a vertical BoxLayout and put the 3 toolbars into 3 successive boxes. That should take care of the geometry.

我不确定使工具栏不可见是否会导致它不占用空间,但这是最简单的.或者,您可以从北窗格动态add()/remove() 工具栏.

I'm not sure if making a toolbar invisible will cause it not to occupy space, but that would be the simplest. Alternatively, you could dynamically add()/remove() toolbars from the north pane.

这篇关于Java GUI 中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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