blob: 6770f7d650fa6c5f39bad330b861006973c4e414 [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= I want to show my own component(s) in the main window - where do I start?
:page-layout: wikidev
:page-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqWindowsComponentHowTo
:description: Apache NetBeans wiki DevFaqWindowsComponentHowTo
:toc: left
:toc-title:
:page-syntax: true
:page-wikidevsection: _window_system
:page-position: 5
include::front::partial$database.adoc[]
Use File -> New File wizard, Module Development category and Window Component item. It will generate all necessary background code for you and open GUI Builder to design UI of your own component.
== But what is behind the scenes, created by wizard?
* Subclass of xref:./DevFaqWindowsTopComponent.adoc[TopComponent] is created. Design it just as you would a JPanel.
* Simple subclass of `javax.swing.AbstractAction` in created and xref:./DevFaqActionAddMenuBar.adoc[added to main menu]. It's implemented it to open your component like follows:
[source,java]
----
public class MyAction extends AbstractAction {
public MyAction() {
putValue (Action.NAME, "Open My Component");
}
public void actionPerformed(ActionEvent ae) {
new MyComponent().open();
}
}
----
* Declarative XML descriptions of component are created following xref:./DevFaqWindowsWstcrefAndFriends.adoc[declarative XML API] principles.
TopComponents are part of the link:{apidoclink}org-openide-windows/org/openide/windows/doc-files/api.html[Windows API].