Roman
Roman

Reputation: 301

Why can't i use palette in netbeans 8.2?

I don't really get the function of palette. (IDE Tools -> Palette) Great tool, works nice in html and php, but in javascript it doesn't let me add anything nor does it show anything i could use. It is locked or something?

Upvotes: 0

Views: 568

Answers (1)

skomisa
skomisa

Reputation: 17383

Why can't i use palette in netbeans 8.2?

You can, but probably not in the way that you want, assuming that you want to be able to use the Palette with JavaScript files, because:

  • The Palette in NetBeans is primarily intended to be used for form development. It is not a general purpose tool for the automatic insertion of code.
  • The content of the Palette window is context sensitive, and the categories available in the Palette at any time are directly tied to the type of the file currently open in the editor window. For example, the categories available in the Palette for *.html files are different to those for *.jsf files.
  • Some file types, including JavaScript files (*.js) and Java files (*.java), have no associated categories. Although you can add a new category to the Palette for file types which already have one or more categories, you cannot create a new category in the Palette for a file type with no existing categories. This means that you cannot use the Palette with *.js files.

While NetBeans does not provide a category for JavaScript in the palette, you could add one yourself, but it would have to be tied to one of the file types that are already supported (e.g. *.html or *.jsp, but not *.js). For example, you could:

  • Create a new category named JavaScript, and add it to the Palette for *.html files.
  • Add an item named alert to that category which would allow you to insert <script>alert('Hello world!');</script> into *.html files by double clicking that alert entry in the Palette.

It is locked or something?

"locked" isn't the appropriate term since that would imply that you could somehow unlock the functionality, but you can't. At least not through the Palette user interface. NetBeans just doesn't support the use of the Palette with *.js files.

The alternative to using the Palette for JavaScript files is to add your own code templates: Tools > Options > Editor > Code Templates > select Language JavaScript > click New

Upvotes: 2

Related Questions