IntelliJ Community . IntelliJUIDesignerGuide

 
IntelliJUIDesignerGuide 

HOME INDEX SEARCH CHANGES GO  

IntelliJ UIDesigner Guide



Roadmap

  • Done Working with layout
  • Done Align components
  • Partial Fill and size for components
  • Done Binding components
  • Done Localizing form
  • Done Preview form
  • Done Using of components in standard palette
  • Done Using of expected components in standard palette
  • Done Adding custom components

Working with layout

Lay Out Horizontally

You can create a JPanel which automatically lays out your components horizontally.

  • Place some components which you want to lay out horizontally on the UIDesigner area. You must align components approximately horizontally. New Window
  • Select the components. New Window
  • Press the "Lay Out Horizontally" button. New Window

Lay Out Vertically

You can create a JPanel which automatically lays out your components vertically.

  • Place some components which you want to lay out vertically on the UIDesigner area. You must align components approximately vertically. New Window
  • Select the components. New Window
  • Press the "Lay Out Vertically" button. New Window

Lay Out In a Grid

You can create a JPanel which automatically lays out your components in a grid.

  • Place some components which you want to lay out in a grid on the UIDesigner area. You must align components approximately in a grid. New Window
  • Select the components. New Window
  • Press the "Lay Out In a Grid" button. New Window

Break Layout

You can break (destroy) a JPanel with a certain layout. This operation is different from simply deleting the panel, because the child components are not deleted while breaking the layout. Only the JPanel will be removed from the UI form. Here we get an example with "Lay Out In a Grid" explanation and try to break the layouted panel.

  • Select layouted JPanel. New Window
  • Press the "Break Layout" button. New Window

Align Components

To align component you must, to have layouted parent JPanel for this component. For aligning components will use properties "anchor", "rowSpan", "columnSpan" and "margin".

Property anchor

This property set align of component and can be:

  • Center New Window
  • West New Window
  • East New Window
  • North New Window
  • South New Window
  • North-West New Window
  • North-East New Window
  • South-West New Window
  • South-East New Window

Property rowSpan

This property set number of rows (for layout with row number > 1) to component will overlap the layout.

Property columnSpan

This property set number of columns (for layout with column number > 1) to component will overlap the layout.

Property margin

This property set offset in pixels from cell border of parent layout cell. It's a complex property and it consists of nested properties:

  • top, The offset from top border of parent
  • left, The offset from left border of parent
  • bottom, The offset from bottom border of parent
  • right, The offset from right border of parent

Fill and size for components

The size tunning of components can be performed by properties "hSizePolicy", "vSizePolicy", "fill", "minimumSize", "preferredSize", "maximumSize".

Filling components

A component can "Grow" relative to the parent's component layout cell size. It can fill the entire area of a layout cell, or grow only vertically or horizontally. The property "fill" controls the filling of components. Property "fill" may have follow values:

  • None, component get the preferred size and default placement New Window
  • Horizontal New Window
  • Vertical New Window
  • Both New Window

Size polices

Exclamation This information is not clearly right and needed to be approved by JetBrains.

The properties "hSizePolicy" and "vSizePolicy" is complex properties consists of boolean subproperties:

  • canShrink
  • canGrow
  • wantGrow

Setting this properties have impact to resize while calling method pack or resizing frame.

The properties "minimumSize", "preferredSize" and "maximumSize" is minimum, default or maximum sizes of component. The size of component can be changed while method pack is called or frame is resized.

Binding components

For binding components to your class fields, you must first bind form to your class, containing fields to bind. And follow, you must bind all required components to your fields in class.

To bind a class to form you must type full class name into "binding" property of "Form" or choose class from list of classes by button. To bind field you must type field name to "binding" property of component. If you type field, that currently is not in class, then UIDesigner will get you intension bulb to create fields automaticaly.

Exclamation You can not bind this to component. It is a restriction of UIDesigner now.

Preview form

You can preview designed form by pressing on "Preview" button in UIDesigner toolbar (New Window).

Localizing form

The text, you typed in forms need to be localized? Then you must prepare in your project a resource bundle with localized strings. In any text field in UIDesigner you can use link to ResourceBundle in your project.

  • Select component to localize, find text property and press the button New Window
  • Select using of Resource Bundle, and press the browse button to find it New Window
  • Find resource bundle in your project New Window
  • Now you must find value from your resource New Window
  • Choose valid key-value pair from list New Window
  • Finally, press the OK button smile New Window

Using of components in standard palette

Please take a look at IntelliJUIDesignerSample to explain the use of standard components in UIDesigner.

Using of expected components in standard palette

Unfortunately, not all Swing components are currently presented in UIDesigner's palette. You can use the following workaround to create an unsupported component:

  • Place a JLabel where you want your component to appear.
  • Put the class name of the unsupported component in the "text" property (e.q. JSpinner).
  • Save and close the form in UIDesigner.
  • Open for edit the form's XML file externally. Find the component with property "text" which you set. For example, if we want to place JSpinner, then we try find:
  <properties>
    <text value="JSpinner"/>
  </properties>
  • Change the "class" attribute for component from javax.swing.JLabel to your component class. You can also remove "text" property:
  <component id="615f3" class="javax.swing.JSpinner">
    <constraints>
      <xy x="310" y="19" width="41" height="20"/>
      <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3"/>
    </constraints>
    <properties />
  </component>
  • Save the ".form" file and reopen it in UIDesigner. You must see JSplitter in design view. You can now use this new component in the UIDesigner. New Window

Customizing component toolbar

UIDesigner supports customization of the component toolbar, which can be achieved by performing the following steps:

  • Create an XML file containing definitions for the components. (tip.gif You can use /com/intellij/uiDesigner/default-palette.xml file from resources.jar as sample.)
  • Place the XML file into the %IDEA_CONFIG%/palette folder. If the folder palette does not exists, create it manualy.
  • In the Settings panel, choose UIDesigner configuration, and select your file from combobox ("Additional component palette").
  • You must restart IDEA to apply palette changes.

tip.gif If you use a different group than "Swing", the UIDesigner toolbar will have tabs, named per group.

Icons in custom palette

To assign icons to your components you must create "toolbar" icon - XML attribute icon, and "tree" icon (icon to showing in structure view of form) - XML attribute small-icon, for each your component definition.

tip.gif Now, both "normal" and small icons have same size - 18x18.

Then you complete icon creation put your icon set in jar, and put this jar into %IDEA_HOME%/lib.

%W% Make sure, that all your paths really exist, because if they don't, you will get an exception when you start IDEA.

Standard Swing complete toolbar

I prepared most of the possible Swing components with icons so they can be used in UIDesigner toolbar.

  • Standard Swing complete toolbar:
overview.png

You must unpack ZIP, and follow by instructions above, put XML file in %IDEA_CONFIG%/palette and put resources-ext.jar into %IDEA_HOME%/lib

Same internal IntelliJ IDEA swing components

Same components maybe used for plugin development it follow palette:

  • com.intellij.ui.ColorPanel
  • com.intellij.ui.ComboBox
  • com.intellij.ui.FieldPanel
  • com.intellij.ui.TextFieldWithBrowseButton
  • com.intellij.ui.Table
  • com.intellij.ui.Tree

Download ZIP and chose in UIDesigner configuration.

tip.gif Also, you can merge it with your existing palette.

-- AlexeyEfimov - 20 Jan 2004

Toolbar in Idea 5.x

In Idea 5.x the toolbar is saved in a different place. It is saved in every project file now "*project*.ipr". So the palette has to be extended there:

  • Download and extract swing-complete-0.2.zip
  • Shut down Idea
  • Edit your project file and look for something like <group name="Swing">
  • Add the entries out of swing-complete-0.2.xml there
  • Copy resources-ext.jar to %IDEA_HOME%/lib
  • Restart Idea

-- ThomasHartwig - 07 Sep 2005

Attachment: sort Action: Size: Date: Who: Comment:
swing-complete-0.2.zip action 11631 07 Sep 2005 - 17:23 ThomasHartwig  

e d i t a t t a c h r e f - b y d i f f s m o r e
Have ideas, requests, problems regarding this site? Send feedback.
Copyright © 2000-2003 by the contributing authors. All materials at intellij.org are the property of the contributing authors.