Java swing GUI设计 [英] Java swing GUI design

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

问题描述

hi
我需要为我的java应用程序设计一个前端。前端看起来有点像这样:

在Panel 1中:

hi I Need to design a front end for my java application. The front end looks somewhat like this:
In Panel 1:

Text
Text.....................................................Text
TextArea1...................Button1......................TextArea1
TextArea1...................Button2......................TextArea1
TextArea1...................Button3......................TextArea1







Text....TextBox1
Text....TextBox2............................Button1
Text....TextBox3............................Copyright Text





我能够把盒子弄好,但正确安排它们会给我带来很多麻烦。

如果可能的话请帮助我。

我对后端没问题,但没有摇摆的想法。

我得到的图形用户界面都是热门话题使用Jpanel。

指定格式的安排是必要且有约束力的。



删除了SHOUTING,添加了代码块 - OriginalGriff [/ edit]



I ahve been able to get the boxes alright but arranging them properly is giving me lots of troubles.
If Possible please help me.
I am okay with backend but have no Idea of Swings.
The GUI i am getting is all hotch potch using Jpanel.
Arrangement in the designated format is necessary and binding.

[edit]SHOUTING removed, Code block added - OriginalGriff[/edit]

推荐答案

布局管理器的可视指南 [ ^ ] @ Java教程



请注意,您可以组合布局。每个区域(可能是JPanel)可以拥有它自己的布局:



面板1:Borderlayout

- 北:GridbagLayout allText

- West:Textarea1

- 东:Textarea1(应该是Textarea2)

- 中心:Gridlayout或带按钮的BoxLayout



面板2:指定列宽的Gridlayout





一些额外的建议:

- 逐步构建布局。如果您已经在GUI后面有一些代码,请使用playground项目。

- 在创建布局时使用背景颜色。否则你不会看到面板的大小。

- 并非所有面板都必须在一个单独的类中。特别是静态内容为自己的固定类而尖叫。
A Visual Guide to Layout Managers[^]@ the Java Tutorials

Please be aware that you can combine the layouts. Each Area (probably JPanel) can have it''s own layout:

Panel 1: Borderlayout
- North: GridbagLayout all "Text"
- West: "Textarea1"
- East: "Textarea1" (should probably be "Textarea2")
- center: Gridlayout or BoxLayout with Buttons

Panel 2: Gridlayout with specified column width


Some additional advice:
- build the layout step by step. use a "playground" project if you already have some code behind the GUI.
- Use background colors while creating the layout. You won''t see the size of the panels otherwise.
- Not all Panels have to be in a single class. Especially static content is screaming for an own, fixed class.


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

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