关于Java中的bulding GUI和小部件 [英] Regarding bulding gui and widgets in java

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

问题描述

我是Java的完全入门者.尽管我已经学习了很多有关语言的文献(相当好),但这是我的第一个实际项目.

I am a complete beginner in java. Although i have studied a lot of literature on the language (well sort of), this is my first real project.

我基本上打算制作一个简单的Clock小部件,后来计划制作Gui.直到现在,我还是学会了挥杆.但是后来我在这个网站上发现Swing有点过时了 (ref: Java GUI框架.选择吗?Swing,SWT,AWT,SwingX,JGoodies,JavaFX,Apache Pivot?).

I was basically planning to make a simple clock widget and later plan to build Gui s. Until now, i had learnt in swing. But then i found on this site that Swing is kinda outdated ( ref : Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot?).

我需要的是Java中的一些好的库来帮助我完成此过程(时钟小部件以及随后更复杂的gui).因此,我想到了从jgoodies(免费的)中获取库.

What i needed was some good libraries in java to assist me in this process ( the clock widget and subsequently more complex gui). So i thought of getting libraries from jgoodies, the free ones.

现在我完全困惑并困惑于该做什么,什么都不了解.当然,我不需要设计模式等方面的书籍.只需Java参考和有关gui的一些教程,即可使用Java和jgoodies入门.而且我在任何地方都找不到它们. 所以请指出正确的方向.

And now i am utterly confused and messed up on what to do and dont understand anything. And of course i dont need books in design patterns etc etc. Just java references and some tutorials on gui using java and jgoodies to get me started. And i cant find them anywhere. So please point me in right direction.

阅读背景(Head First Java,Java的完整引用和数据结构以及算法)

Reading background (Head First java, java the complete ref and data structures and algo)

(建议其他人参加,如果不够的话)

(Suggest others if not sufficient)

推荐答案

我需要的是Java中的一些好的库来帮助我完成此过程(时钟小部件以及随后更复杂的gui).因此,我想到了从jgoodies(免费的)中获取库.

What i needed was some good libraries in java to assist me in this process ( the clock widget and subsequently more complex gui). So i thought of getting libraries from jgoodies, the free ones.

可能您不需要的库数量比您想象的要多.从第一原理学到东西,您会学得更好.

Probably you don't need libraries as much as you think you do. Learn stuff from first principles and you will learn it better.

所有主要的Java GUI框架都已经相当高级并且可以使用.刚开始时,我认为您应该跳过第三方库,并了解基础JRE和您选择的框架所提供的内容.仅使用基本框架,Java语言和JRE,还有足够的知识要学习.如果您尝试过早添加其他框架,最终将导致超负荷,混乱且生产率低下.另外,对库的日益增加的抽象化可能使您无法充分了解一些重要的基本原理.

All the major Java GUI frameworks are quite high level and functional already. When you are first starting out, I think you should skip 3rd party libraries and see how far you get with what is provided in the base JRE and the framework of your choice. There is more than enough to learn with just the basic frameworks, the java language and the JRE. If you try to add in other frameworks too early, you will end up overloaded, confused and less productive. Plus the increased abstraction of the libraries may prevent you from learning some of the important underlying principles well enough.

一旦您在构建事物上有了更多的经验,那么您将对框架中哪些地方适合您的应用程序有一个更好的了解,您可以在那时添加第三方库.

Once you get a bit more experience in building things, then you will have a much better idea where the gaps in the frameworks are for your application and you can add in 3rd party libraries at that time.

计划制作一个简单的时钟小部件

planning to make a simple clock widget

如果遇到问题,这里是 JavaFX 时钟的代码:

If you get stuck, here is code for a JavaFX clock: How to draw a clock with JavaFX 2? or a similar implementation in Swing.

请注意,创建时钟与创建使用预定义控件库的基于表单的传统GUI有很大不同-但是任何主要的Java GUI框架都可以处理这两项任务.

Note that creating a clock is quite a bit different than creating a traditional form based GUI that makes use of a library of predefined controls - but any of the major Java GUI frameworks can handle both tasks.

不要花时间做第一个GUI编程任务,做些简单的事情.然后尝试创建一个时钟.

Don't make a clock your first GUI programming task, do something easier. Then try to create a clock later.

使用摆幅进行精确布局确实是一项艰巨的任务

using swing for precise layout is really a difficult job

有用于Swing和其他框架的交互式图形布局管理器(例如,出色的

There are interactive graphical layout managers for Swing and other frameworks (e.g. the excellent SceneBuilder for JavaFX) which make this easier.

但是,当初次使用时,可能值得手动编写代码,而不是让工具为您管理布局(例如,在学习JavaFX时,仅坚持使用Java API,并且在完全适应之前不要使用FXML) Java API).您将以这种方式更好地了解布局管理和其他内容的来龙去脉.当然,您会犯一些错误,并且会有一些挫败感,但是随着时间的推移,事情会变得更加清晰和持久.而且您最终可能会决定还是喜欢手动编码而不是使用图形工具.

However, when first starting, it's probably worth hand coding stuff rather than letting a tool manage the layout for you (for example when learning JavaFX, stick with just the Java API and don't use FXML until you are completely comfortable with the Java API). You will learn the ins and outs of layout management and other things better that way. Sure you will make some mistakes and there will be a bit of frustration, but things will become clear in time with some persistence. And you may eventually end up deciding that you prefer hand-coding rather than using a graphical tool anyway.

棘手的部分通常是创建质量高,可动态调整大小的GUI,这些GUI在不同的分辨率和窗口大小下看起来都很好-无论使用哪种GUI工具包,对于初学者来说通常都是棘手的.

The tricky part is usually creating quality, dynamically resizable GUIs that look good at different resolutions and window sizes - and that is generally tricky for beginners no matter what GUI toolkit is used.

JavaFX中的布局管理器与Swing中的基本布局管理器非常相似-因此在布局方面,两个框架之间几乎没有区别.

The layout managers in JavaFX are very similar to the basic layout managers in Swing - so layout-wise there is little difference between the two frameworks.

与Swing的直接模式绘制相比,JavaFX中的保留模式Scene Graph可能更容易使用,但是我想这与布局没有太大关系.

The retained mode Scene Graph in JavaFX may be a bit easier to work with than the direct mode painting of Swing, but I guess that is not quite layout related.

用于JavaFX的自省工具(例如 ScenicView )可简化运行时的调试布局.将诸如ScenicView之类的东西想像为类似于 HTML的Firebug (例如,您必不可少的布局调试助手).

Introspection tools, such as ScenicView for JavaFX, ease debugging layouts at runtime. Think of things like ScenicView as something similar to Firebug for HTML (e.g. your essential layout debugging companion).

现在我完全困惑并且搞不清楚该做什么,什么都不懂.

And now i am utterly confused and messed up on what to do and dont understand anything.

您了解的程度超出了您的想象,或者您所了解的不足以询问这个问题.

You understand more than you think you do or you wouldn't have known enough to ask this question.

您应该做的(IMO)就是选择一个Java GUI框架(任何框架-它们都是可以通过的),选择一个体面的启动任务(看起来似乎很简单的事情-甚至比时钟还简单)并开始编码.使一切与任务相关;具有明确最终目标的非常小的任务.编写大量的代码,并始终返回并修改您的代码,然后输出该代码以使其尽可能达到最佳效果-不要满足于足够的要求.

What you should do (IMO) is just pick a Java GUI framework (any framework - they are all passable), pick a decent starting task (something that seems mind-numbingly simple - even simpler than a clock) and start coding. Make everything task related; very small tasks with clear end-goals. Write a decent amount of code and always go back and revise your code and it's output to try to make it the very best it can be - don't settle for good enough.

尝试绘制彩虹和笑脸-当您将其编码并在屏幕上看到时,您会感觉很好:-)

Try painting rainbows and happy faces - when you code that up and see it on the screen, you will feel good about yourself :-)

如果您需要Java语言复习,请遵循Oracle >学习Java语言教程.那是我多年前学习Java的方式.多年来一直对其进行维护,因此它仍然是一种巨大的资源,并且在今天仍然有用.

If you need a refresher on the Java language, follow the Oracle Learning the Java Language trail. That trail is the way I learnt Java many years ago. It has been maintained over the years so that it is still a great resource and useful today.

如果选择Swing,请遵循MadProgrammer的开始链接.

If you choose Swing, follow the starting links from MadProgrammer.

如果选择JavaFX,请遵循 JavaFX教程

If you choose JavaFX, follow the JavaFX tutorials and the Ensemble sample app but be aware that some of the JavaFX tutorials are targeted to more experienced programmers.

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

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