Develop SWT applications

zhaozj2021-02-16  89

It turns out that the client program for Java is a graphical interface, just knows the principle of simple Java graphic programming. Recently, it is indeed very different from other development methods under WINDOW. I have not used AWT, nor I used Swing, I saw this on the Internet, it can't. I use SWT directly, anyway, can cross the platform.

Composite Refresh

It seems simple, but after composite.Open (), dynamically created a few Control, running is not displayed, but the original Control can be dispose (). Pick up, I don't want to do it. Remember when testing SCJP , AWT or SWING needs to call redraw () reinstall the canvas, call it, or not, the resources of dynamically create controls are not found, think SWT does not support dynamic creation, just want ~! @ # $% ^ & * ) _ . Lookout in the desperation, Layoutexample in it, actually achieved dynamic creation button, this is not what is going to study, see CreateTailxxx, see CreateTailxxx, there is no special place, go out and look forward, use Composite .keout (TRUE) method. Looking back, it is it.

Looking back, the designer does not want us to see the control one by one, so that such a method is designed to let the control screen.

2. Control parent components

When the Window program dynamically creates a control, you can specify the parent control to null, and then call the Add method of the parent component. SWT does not seem to support, if the composite of the control is NULL, will throw an exception. Must be specified A parent container. It seems regardless of the 3 * 7 = 21, the shell is used as its Parent, then calls Composite.SetParent () to change its Parent, think about it, no. If you use the setParent method to change, its shell's Control list also retains this control. Copy, and there is always a clean feeling of clean when Dispose ().

It turns out a good frame because you must give up the Parent Composite.

转载请注明原文地址:https://www.9cbs.com/read-12828.html

New Post(0)