No java desktop application in netbeans

NetBeans Platform Quick Start

The NetBeans Platform is a generic application framework primarily for Java desktop applications. The main benefit of the NetBeans Platform is its predefined modular architecture. Secondary benefits are the NetBeans Platform’s reusable solutions such as its docking framework and its out-of-the-box pluggable components, in combination with the tools provided by its SDK, NetBeans IDE, in particular its award winning «Matisse» GUI Builder for designing GUI components.

In this quick start, you are introduced to the benefits and usages of modularity on the Java desktop via a very simple example, contributed by Thomas Würthinger, a PhD student at the Johannes Kepler University in Linz, Austria. Once you have grasped the concepts introduced in this quick start, you will be ready to step onto the NetBeans Platform Learning Trail, providing a very rich variety of tutorials for many different scenarios relating to the NetBeans Platform.

If you are new to the NetBeans Platform, it is highly recommended to get hold of NetBeans Platform for Beginners (published in 2014).

For troubleshooting purposes, you are welcome to download the completed tutorial source code.

Even though it is a separate product, there is no need to download the NetBeans Platform separately. Typically, you develop the application in NetBeans IDE and then exclude the modules that are specific to the IDE but that are not required for your application.
Читайте также:  Python row to dict

A Single Module NetBeans Platform Application

We start by creating a new NetBeans Platform application, containing a single module.

Create the Application

In this section, you create your first NetBeans Platform application.

  1. Choose File | New Project and then choose NetBeans Modules. Select «NetBeans Platform Application». You should see this:

quickstart platform new project 1

The difference between the 4 templates above is as follows:

  • NetBeans Platform Application. A project that groups a set of module projects and library wrapper module projects that have dependencies on each other, and lets you deploy them together as a unit. Automatically included are a subset of the modules that make up the NetBeans Platform.
  • Module Suite. Same as above, except that the pre-included modules are more than only those relating to the NetBeans Platform—in this case, all the modules that make up NetBeans IDE are included as well.
  • Library Wrapper Module. A project that puts a library JAR file on its classpath and exports some or all of the JAR file’s packages from the module as public packages.
  • Module. A project for implementing the functionality, business logic, and user interface of a module or application built on the NetBeans Platform.

quickstart platform new project 2

Click Finish. The new project appears as follows in the Projects window:

quickstart platform new project 3

Create the Module

In this section, you create your first NetBeans Platform module.

quickstart platform new module 1

The New Module Project dialog will appear. Name the new module WordEditorCore :

quickstart platform new module 2

  1. Specify «org.word.editor.core» as the Code Name Base, which is a unique string identifying the module. The Module Display Name is used as a label for the module in the Projects window.

quickstart platform new module 3

Click Finish. The new module is created and its structure is shown in the Projects window:

quickstart platform new module 4

Create the Window

Having created a module, you now create your first NetBeans window.

quickstart platform new window 1

The New File dialog appears. In the Module Development category, select «Window»:

quickstart platform new window 2

  1. You should now see a dialog for specifying the position where the new window will appear in the application frame, as well as whether it will open automatically when the application starts, among other settings.

Set the Window Position to be editor , which is the default central position within the application frame, and select «Open on Application Start».

quickstart platform new window 3

quickstart platform new window 4

Click Finish. The new window («WordTopComponent.java») is added to the source structure of your module:

quickstart platform new window 5

  1. The new window should have opened in the Design view of the «Matisse» GUI Builder. You can double-click (or select «Open» from the context menu) it if it didn’t open automatically.

quickstart platform new window 6

The Palette should be open on the right side (you can use Window IDE Tools Palette or Ctrl + Shift + 8 if not). Drag and drop a Button and a Text Area from the Palette onto the window:

quickstart platform new window 7

Do the following to make the new GUI components more meaningful:

  • Right-click the text area, choose «Change Variable Name», and then name it text .
  • Right-click the button, choose «Edit Text», and then set the text of the button to Filter! . Also rename the variable to filterButton .

quickstart platform new window 7

  1. Double click on the button. This will create an event handling method in the Source editor. The method is called whenever the button is clicked. Change the body of the method to the following code:
 private void filterButtonActionPerformed(java.awt.event.ActionEvent evt)

You have now created the window module. When the «Filter!» button is clicked, the filterButtonActionPerformed method will be called, which will get the content of the text text area, convert that text to upper case, and put the upper case version into the text text area.

Run the Application

In this section, you deploy the application.

quickstart platform new app 1

Doing so will start up your new NetBeans Platform application and install your module. You will have a new window, as well as a new menu item for opening it, as shown below:

quickstart platform new app 2

quickstart platform new app 3

You should see that the text is now shown in uppercase:

quickstart platform new app 4

You have learned how to create a new Apache NetBeans Platform application and how to add new modules to it. In the next section, you will be introduced to the Apache NetBeans Platform’s pluggable service infrastructure.

A Modular Application Using Lookup

In this section, you create two additional modules. The first new module, «WordEditorAPI», contains a service provider interface. The second module, «UppercaseFilter», is a service provider for the interface.

The GUI module, which you created in the previous section, will be loosely coupled from the «UppercaseFilter» service provider because the GUI module will not refer to any code from the «UppercaseFilter» service provider. That will be possible because the «UppercaseFilter» service provider will be registered in the META-INF/services folder and loaded via the NetBeans Lookup class, which is comparable to the JDK 6 ServiceLoader class.

You will then create another loosely coupled service provider, named «LowercaseFilter».

The concept is that instead of all the different functions needing to be added to «WordEditorCore», each function can be implemented separately, without coupling the filter operation to the display of the result.

Источник

В NetBeans 8.0.2 отсутствует настольное приложение Java

Я недавно установил последнюю версию NetBeans, и когда я попытался создать новый тип проекта «Java Desktop Application», он не появится в категории Java. Пожалуйста помоги? Я установил этот плагин:

Даже я установил все плагины java. Но не повезло!

2 ответа

Под Java Desktop Application вы можете иметь в виду «Swing Application Framework», который был остановлен Sun Microsystems до Java 7 примерно в конце 2009 года.

Для разработки настольных приложений с использованием Java в NetBeans у вас есть несколько следующих вариантов:

  1. Использование Matisse UI Builder. Matisse UI Builder доступен в NetBeans, и вы можете создавать классы JFrame и JDialog в своем приложении, которые можно использовать в качестве UI в любом приложении Java. Этот подход требует написания большого количества шаблонного кода для создания окон, меню и диалоговых окон. Следующий вариант лучше, если вам нужно профессиональное кроссплатформенное настольное приложение Java.
  2. Использование платформы NetBeans в качестве основы вашего приложения IDE NetBeans построена на основе платформы NetBeans, и вы также можете использовать платформу NetBeans для создания собственного настольного приложения со многими стандартными функциями из коробки, поступающими с платформы NetBeans. IDE NetBeans поставляется с типами проектов модулей NetBeans, в которых вы можете выбрать тип проекта «Приложение платформы NetBeans: тип проекта для создания настольного приложения. В списке пользователей NetBeans и списке рассылки платформы имеется множество учебных пособий и справки.

Если вы все еще ищете ответ или кому-то нужна помощь, то вот вариант. Я думаю, вам нужен вариант перетаскивания, верно? Ну вот.

Просто запустите new project как Java и Java Application , как показано ниже:

Selecting new project

А затем дайте своему проекту любое имя, например helloworld , как показано ниже:

setting project name

После того, как вы нажмете кнопку «Готово», откроется пакет helloworld . Теперь перейдите в левую (в основном) или правую часть экрана, там есть список projects . Перейдите в свой проект и щелкните правой кнопкой мыши Source Packages -> New -> Other , как показано ниже:

looking for the way

Теперь открывается другое окно, в котором выберите Swing GUI Forms из Categories и JFrame Form из File Types , затем Next и задайте name и > для класса.

goigng through the way

finish

Теперь форма должна появиться в окне. Теперь вы можете вернуться к source code и перейти к Design , как хотите. Удачного кодирования.

Источник

Почему я не могу найти настольное приложение Java в Netbeans 7.1

Я загрузил Netbeans 7.1 со всем пакетом из http://netbeans.org/downloads и успешно установил его в Windows 7.

Но я не могу найти приложение Java Desktop, которое должно быть в категории Java при добавлении нового проекта, как это делает 7.0.

Где это находится? Или какой подменный в 7.1? Мне нужно что-то для создания графического интерфейса путем перетаскивания компонентов.

4 ответы

Поддержка [B] SAF (JSR 296, в основном фреймворк, лежащий в основе вашего шаблона проекта «Java Desktop Application») была внезапно прекращена (без уважительной причины, позвольте мне добавить).

Однако, как говорит Билл в своем ответе, нет необходимости использовать SAF для визуального проектирования формы. Swing-Designer NetBeans (известный как Matisse) можно использовать для разработки любых JFrame, JDialog, JPanel и т. Д.

Щелкните правой кнопкой мыши -> New -> JFrame Form.

и вы готовы к перетаскиванию!

(Возможности, которые вам будет не хватать, — это дополнительные навороты, которые предоставляет такая структура, такие как действия SAF, постоянство окон, упрощенное управление для длительно выполняемых задач и связанная визуальная обратная связь [теперь вам нужно испачкать руки с классом SwingWorker] , так далее)

Вы по-прежнему можете получить библиотеку Swing Application Framework в Центре обновлений NetBeans. Однако обратите внимание, что он не включает возможность создавать или редактировать формы SWAF — Тим Спарг

Или, что еще лучше, получите BSAF (Better Swing Application Framework, в основном активно поддерживаемая ветка с исправлениями ошибок и небольшими улучшениями с обратной совместимостью) отсюда: kenai.com/projects/bsaf/pages/Главная — Унаи Виви

Java Desktop относится к усилиям по созданию стандарта или библиотеки (библиотек), которые никогда не производили ничего значимого. Я думаю, что вполне вероятно, что они наконец удалили его из Netbeans.

Проще просто создать новый проект Java-приложения, не заморачиваться с основным, а затем создать новую форму JFrame. У этого класса будет main, который вы можете использовать, и вы также можете создать фрейм в форме. Вы также можете создавать классы JPanel Form. Примечание: вы можете сделать это практически в любом проекте в netbeans, в проектах для них нет ничего особенного.

Вероятно, OP также использовал все дополнительные навороты, которые предлагала Swing Application Framework, такие как действия SAF, постоянство окон и т. Д. Унаи Виви

Есть ли шанс, что вы знаете, что делать со старым проектом, который использует Java Desktop (включая org.jdesktop.beansbinding. *) Из эпохи NetBeans 7, чтобы перенести его на современные NetBeans, такие как Apache NetBeans 11? У меня есть проект с кучей ссылок на классы beansbinding в сгенерированном коде в классах форм, с которыми я не знаю, что делать, чтобы избавиться от зависимости. — Эндрю Янке

лучше использовать NetBeans 7.0 для полной поддержки компонентов Swing. многие учебные пособия и руководства содержат «Настольное приложение Java» (например, для JXMapKit: http://today.java.net/pub/a/today/2007/10/30/building-maps-into-swing-app-with-jxmapviewer.html )

Источник

Оцените статью