Intellij error with "add non-palette componente" - java

When I try to add a non-palette component in IntelliJ 14.0.3 I get this error:
Forms added to palette must have a binding for the top-level component
The component that I try to add to a tab of a scrollpane, is a class that extends a JPanel.
I can not understand why this error. With other classes does not give me problems.
The error remains even if I select the two options.

You may add the form to a pallet and then place it as a component on another form.
To do so open in a designer a form which you want to be custom component. Click right on any group (e.g. swing) and select "Add Component to Palette". After this you can open another form and place the newly added component on it.

I solved this by changing the "field name" of the JPanel of the form that is being inserted in another form.
It seems this error appears when no field name is specified which means the error is a bit misleading.

Related

In Intellij Idea, how to keep showing context information?

I know for sure that by clicking hot key alt + q, the context of current method or class could show up just like:
But is there any way to make the IDE keep showing the context information at the top of the edit area?
You can't keep the method definition for the 'currently active' method pinned to the top of the editor but if your goal is to display the method definition for the 'currently active' method while you are editing that method then you could use the Structure tool window and select Autoscroll from source. This will show you the definition of the method you are currently editing / your cursor is currently sitting in.
Here's a screenshot:
Autoscroll from source is the last icon on the right at the top of the Structure tool window.
You can activate the Structure tool window via keystokes (e.g. ALT 7), to identify the correct keystroke just have a look at the keystroke associated with the menu item: View > Tool Windows > Structure.
More details in the docs

Dynamic Jframe and Jtable

I am coding a small script and stuck on this issue. This is my scripts screenshot.
In ... button it should be automaticly open the browse and the user can select the directory.
In addition If the user click the + Button , the script should create a new path place and the user can select the second path. The problem is how can I add the second or third path place to the gui without damage general view. Like Show Me button has to always seems in gui.
For this problem what is your advice ? Should I use first JScrollPane and then Jtree? or more easy way?
I need your helps and some tricks.
Thanks in advance.

Swing shows empty tooltips, how to disable this?

I'm creating a java Swing app and I'm new to that.
The problem is that when I move cursor to menu item, for example, it shows me an empty tooltip.
Is there any way to disable this?
P.S. Using NetBeans, if it's important. Maybe it generated some odd code?
Go to the properties of the menu or menu item that displays the empty tooltip and choose tooltip. Then add "null" as a String value for setTooltipText. The empty tooltip will then dissapear.
If the toolTipText property in the designer is bold (changed), you can just press the Reset to Default button at the bottom of the above window, or even right-click on said property in the list and select Restore Default Value.
I guess you're using the (now dead) Swing Application Framework. Netbeans automatically generates an entry in the properties file associated with each panel for the tooltip, with an empty value (instead of not generating the property at all if you leave the text box blank). Just remove the property in the properties file manually.
The lines looking like the following should be removed:
someAction.shortDescription=

How to use GUI form created in IntelliJ IDEA

I'm creating a simple GUI form with one button in IntelliJ IDEA 9. The class which was created with the form is not JFrame or any other swing class. How I can call my form in my source code?
I was stumped when IntelliJ consistently errored out when choosing Form main() from the insert menu, with an error message saying something about an invalid root component.
It turns out it means that the JPanel that is the main (root) component of your Form needs to have a field bound to it, and by default it doesn't do this.
Simply select the JPanel in the form designer, and give it a name (field name) in the property pane.
After this it will generate the main() just fine.
Simply go into the class associated with your form, press alt + insert and choose "Form main()".
Resources :
GUI Designer Basics
First add private JPanel Main; inside the class. Then, in the form's panel properties, add Main to the field name. Then, go to your class and from the Alt + Insert menu, select Main.
Now, the error wont come.

Accessing look and feel default icons?

I want to change the selected icon for a JCheckbox to a different icon, let's say for example the disabled selected icon for a JCheckbox. How can I get the disabled selected icon from the UIManager?
I tried UIManager.getIcon("CheckBoxUI.disabledSelectedIcon"); Is that the wrong icon property name or is that just the wrong way to get to that resource?
Apparently there isn't one by default. At least, not when I'm trying to call it.
Just dumping the keys from UIManager.getLookAndFeelDefaults().keys() produces the following if the key contains CheckBox:
CheckBox.foreground
CheckBox.border
CheckBox.totalInsets
CheckBox.background
CheckBox.disabledText
CheckBox.margin
CheckBox.rollover
CheckBox.font
CheckBox.gradient
CheckBox.focus
CheckBox.icon
CheckBox.focusInputMap
After reading akf's answer, I started digging through the UIManager code in the plaf.synth packages and found calls that essentially delegate the null disableCheckedIcon to the look and feel classes to try to convert the standard .icon to a grayed version. So I ended up with this:
Icon checkedIcon = UIManager.getIcon("CheckBox.icon");
Icon dsiabledCheckedIcon =
UIManager.getLookAndFeel().
getDisabledSelectedIcon(new JCheckBox(), checkedIcon);
Looking through the code for AbstractButton, it appears that the disabledSelectedIcon is derived from the selectedIcon, unless it is specified on the AbstractButton (or JCheckBox in this case) through setDisabledSelectedIcon. With this being the case, calling UIManager.getIcon("...") will not return the object you are looking for.
EDIT:
Note that a JCheckBox has an icon field as defined in the AbstractButton API, just as a JButton can have an icon. It is an image that is displayed next to the text and is separate from the 'checked' or 'unchecked' box icon that you may be referring to.
The check/uncheck icon is handled by a single class, found with UIManager.getObject('CheckBox.icon'). It is a subclass Icon and handles both the painting of its checked and unchecked state. You can see examples of it in the various [L&F name]IconFactory classes.

Categories

Resources