Thursday, October 04, 2007

java可视化编程

试用了eclipse和net beans,发现好的程序(和sun自己的程序)都是用netbeans写的。而且eclipse的环境很难配置(一不小心就搞错版本号),最严重的问题是布局管理器不听话,组件不能自由移动位置,JPanle更是几乎无法调整,一挪搞不好还挪到窗口以外不知哪方天地了。


看csdn某兄弟揭老底:IBM 它的产品命名为 eclipse(日食) 是十分阴险的,它是想要把 sun(太阳) 遮住呀

NetBeans GUI开发介绍
(自动管理layout)
In Java applications, the components that comprise a GUI (Graphical User Interfaces) are stored in containers called forms. The Java language provides a set of user interface components from which GUI forms can be built.

GUI forms are indicated by form nodes ( ) in the Projects, Files

the IDE displays it in a Editor tab with toggle buttons allowing you to switch between Source and Design views

layout managers enable you to control the way in which visual components are arranged in GUI forms by determining the size and position of components within containers. This is accomplished by implementing the LayoutManager interface.
By default, new forms created with the GUI Builder use a FreeDesign paradigm which enables you to lay out your form using visual guidelines that automatically suggest optimal alignment and spacing of components. As you work, the GUI Builder translates your design decisions into a functional UI without requiring you to specify a layout manager. Because FreeDesign employs a dynamic layout model, whenever you resize the form or switch locales the GUI adjusts to accommodate your changes without changing the relationships between components.
In order for the interfaces you create with the GUI Builder to work outside of the IDE, the Swing Layout Extensions library must be on the classpath at runtime. To simplify the process of deploying of your GUI applications, the IDE automatically copies the JAR (and any other JAR files on the project's classpath) to the dist/lib folder when you build the project. The IDE also adds the JAR to the Class-Path element in the application JAR file's manifest.mf

When you create a new container, it is created using the default layout manager for that container type. Most containers use BorderLayout by default, however some containers have their own special layouts that cannot be changed. If necessary, you can change the layout of most containers using the Palette window, GUI Builder, or Inspector window

Eclipse:

Jframe (总框架),jFrame.setContentPane(getJContentPane());
jFrame.setJMenuBar(getJJMenuBar());
下面是jpanel类实现的jcontentpane对象(还可用Layout添加多个字pane/desktoppane

jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getItIsABean(), BorderLayout.NORTH);
jContentPane.add(getJDesktopPane(), BorderLayout.WEST);

可以附加 aboutDialog = new JDialog(getJFrame(), true)(新对话框)并setContentPane(getAboutContentPane());

刚发现netbeans和eclipse都有用左边的小加号隐藏代码的能力,真不知道他是凭什么来判断一段代码需要隐藏,甚至netbeans自动隐藏它认为是generated code的部分!

对于熟手可能是个好的功能,但是很容易误导生手!我就找了半天一堆import,不知道到底是有还是没有,因为被eclipse隐藏了。

0 Comments:

Post a Comment

<< Home