Notes about IntelliJ IDEA 4.0 GUI Builder
- On Windows 2000, running or debugging didn't work until I added IDEA_HOME/lib/forms_rt.jar to my project's classpath. I added it to my ANT build path too for good measure because I kept getting an error about com.intellij.uiDesigner.core*.
- On Windows XP, running the form worked but I still got a red warning in my editor about com.intellij.uiDesigner.core.*
- Check out the IntelliJ component toolbar wiki for help adding the rest of the Swing components (such as JFileChooser, JSlider, JColorChooser) to the GUI builder and for adding your own custom components.
An early hurdle you might encounter in using the IDEA 4.0 GUI Builder is filling a control with data. Most of the examples you will find show how to populate your control with data when it is instantiated. You can’t really do this when the control is hidden in machine-generated-code-land, so you add it after the fact. Using a JComboBox named speciesCombo as an example, you can't just say, speciesCombo.addItem("Walleye");
Why would you think it would be that simple?
Instead create an object called a DefaultComboBoxModel, which is used to expose a changable data model for the JComboBox. There are other models for the other controls. Like it says in this tutorial on using lists. So the speciesCombo code would look like this:
comboModel = new DefaultComboBoxModel();
comboModel.addElement("walleye");
comboModel.addElement("sheepshead");
comboModel.addElement("bullhead");
comboModel.addElement("dogfish");
comboModel.addElement("catfish");
sizeCombo.setModel(comboModel);