简体   繁体   English

需要Java swing帮助

[英]Java swing help needed

I need to build a GUI in java with the following format: 我需要在java中使用以下格式构建GUI:

Without providing any large blocks of code I want to know how to get started. 没有提供任何大块代码我想知道如何开始。 After reading countless info on swing I am utterly confused. 在阅读了无数关于秋千的信息后,我完全感到困惑。 I'm wondering if I would need multiple Jpanels / frames or a gridlayout or flowlayout. 我想知道我是否需要多个Jpanels / frames或gridlayout或flowlayout。 Also a very general idea of how to get started on the GUI would help. 关于如何开始使用GUI的一般概念也会有所帮助。 I know what components I need (list, label etc..) and have example code to help. 我知道我需要什么组件(列表,标签等..)并有示例代码来帮助。 The data I will load myself. 我将加载自己的数据。

I'm assuming I will need a separate class for each component and maybe only one for labels to make it easier to debug. 我假设每个组件都需要一个单独的类,可能只有一个用于标签,以便于调试。

You will need to mix containers and layouts, knowing what properties different layouts have, and different parts of those layouts, and the different options of the layouts will help a lot in knowing how to nest components together to get what you want. 您将需要混合容器和布局,了解不同布局具有哪些属性,以及这些布局的不同部分以及布局的不同选项将有助于了解如何将组件嵌套在一起以获得所需内容。

Without providing code that shows this, I would do the following container/layout nesting: 如果没有提供显示此代码的代码,我将执行以下容器/布局嵌套:

The root panel could have a BorderLayout, with two JPanels on the east and west sides of it. 根面板可以有一个BorderLayout,在它的东侧和西侧有两个JPanel。

West most JPanel could have a BorderLayout, with the JList being in the center so it expands and takes up as much room as possible, and the 4 labels and 4 text fields could be in another panel which has a GridLayout of 4 rows by 2 columns. West最JPanel可以有一个BorderLayout,JList位于中心,因此它会扩展并占用尽可能多的空间,4个标签和4个文本字段可能位于另一个面板中,其中GridLayout为4行乘2列。

The far east JPanel could have a BorderLayout as well, with a JPanel in the north that has a GridLayout of 3 rows by 1 column, where each of those rows has another panel of a FlowLayout. 远东JPanel也可以有一个BorderLayout,北边的JPanel有一个3行乘1列的GridLayout,其中每一行都有另一个FlowLayout面板。 The text area or whatever it is could be in a JPanel in the center position, and you could place the bottom text field and label in a JPanel with a FlowLayout in the south position of the far east JPanel. 文本区域或其他任何内容可以位于中心位置的JPanel中,您可以将底部文本字段和标签放在JPanel中,并在远东JPanel的南侧位置使用FlowLayout。

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

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