idea插件访问浏览器web地址实现方式

 更新时间:2025年09月12日 17:26:16   作者:疯癫的老码农  
用户分享了在IntelliJ IDEA开发插件的简要流程:新建项目、配置plugin.xml、创建工厂类、构建打包、安装并重启IDE,最后运行插件,重点在于通过Idea平台实现插件开发,与Eclipse流程类似但需注意配置细节

背景

以往在eclipse上面开发插件,有兴致想尝试Idea上玩一下插件开发。想要在idea上面访问web地址

概要

记录在idea上面访问web地址

正文

1、点击File->New->Project… 选择IntelliJ Platform Plugin

2、点击下一步后,输入Project Name,然后点击完成

3、新建Factory

package com.demo.view;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManager;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/**
 * @author twilight
 * @since V1.0
 */
public class MyToolWindowFactory implements ToolWindowFactory {
    @Override
    public void createToolWindowContent(
            @NotNull Project project,
            @NotNull ToolWindow toolWindow) {
        ContentManager contentManager = toolWindow.getContentManager();

        JFXPanel jfxPanel = new JFXPanel();
        jfxPanel.setBounds(0,0,100,200);

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                WebView webView = new WebView();
                jfxPanel.setScene(new Scene(webView));
                webView.getEngine().load("https://m.runoob.com/maven/");
            }
        });

        Content labelContent =
                contentManager.getFactory()
                        .createContent(
                                jfxPanel,
                                "",
                                false
                        );

        contentManager.addContent(labelContent);
    }
}

4、修改plugin.xml

<idea-plugin>
  <id>com.demo.view.plugin.id</id>
  <name>com.jcef.company</name>
  <version>1.0</version>
  <vendor email="support1@yourcompany.com" url="http://www.yourcomp1any.com">Your111Company</vendor>

  <description>com.demo.view.plugin.desc/com.demo.view.plugin.desc</description>

  <change-notes>com.demo.view.plugin.desccom.demo.view.plugin.desc
  </change-notes>

  <!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
  <idea-version since-build="173.0"/>

  <!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
       on how to target different products -->
  <!-- uncomment to enable plugin in all products
  <depends>com.intellij.modules.lang</depends>
  -->

  <!-- plugin.xml文件 -->
  <extensions defaultExtensionNs="com.intellij">
    <!-- Add your extensions here -->
    <!-- id是必须的属性,我们进行添加 -->
    <!-- anchor锚点非必须,但是为了像Gradle插件一样默认显示在右边,我们设置为right -->
    <toolWindow id="web browser"
                anchor="right"
                factoryClass="com.demo.view.MyToolWindowFactory"
    />
  </extensions>
</idea-plugin>

5、打包插件

Build->PreparePlugin Module "XXX" For Deployment 

6、安装插件

File->settings...->Plugins

Restart IDE

7、运行插件

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • 一篇文章带你深入了解Java线程池

    一篇文章带你深入了解Java线程池

    这篇文章主要介绍了Java 线程池的相关资料,文中讲解非常细致,帮助大家更好的理解和学习,感兴趣的朋友可以了解下,希望能给你带来帮助
    2021-08-08
  • java实现入栈push和出栈pop过程

    java实现入栈push和出栈pop过程

    文章详细介绍了栈的概念、特点以及如何使用数组和链表实现栈,通过入栈(push)和出栈(pop)操作,展示了栈的数据处理过程,并提供了具体的代码实现
    2024-12-12
  • Java中关于线程安全的三种解决方式

    Java中关于线程安全的三种解决方式

    这篇文章主要介绍了Java中关于线程安全的三种解决方式,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2021-09-09
  • Java编程基础测试题分享

    Java编程基础测试题分享

    这篇文章主要介绍了Java编程基础测试题分享,具有一定参考价值,需要的朋友可以了解下。
    2017-10-10
  • Jenkins环境搭建之下载与安装过程

    Jenkins环境搭建之下载与安装过程

    Jenkins是一个功能强大的应用程序,允许持续集成和持续交付项目,集成Jenkins可以用于一些测试和部署技术,对Jenkins环境搭建之下载与安装过程感兴趣的朋友跟随小编一起看看吧
    2021-12-12
  • Spring Cloud OAuth2实现自定义token返回格式

    Spring Cloud OAuth2实现自定义token返回格式

    Spring Security OAuth的token返回格式都是默认的,但是往往这个格式是不适配系统。本文将用一个接口优雅的实现 Spring Cloud OAuth2 自定义token返回格式,需要的可以参考一下
    2022-06-06
  • MyBatis与Spring中的SqlSession详解

    MyBatis与Spring中的SqlSession详解

    在MyBatis中,你可以使用SqlSessionFactory来创建SqlSession,使用MyBatis-Spring之后,你不再需要直接使用SqlSessionFactory了,接下来通过示例代码讲解MyBatis与Spring中的SqlSession,需要的朋友可以参考下
    2024-05-05
  • Java之Zookeeper注册中心原理剖析

    Java之Zookeeper注册中心原理剖析

    这篇文章主要介绍了Java之Zookeeper注册中心原理剖析,本篇文章通过简要的案例,讲解了该项技术的了解与使用,以下就是详细内容,需要的朋友可以参考下
    2021-07-07
  • RocketMQ的push消费方式实现示例

    RocketMQ的push消费方式实现示例

    这篇文章主要为大家介绍了RocketMQ的push消费方式实现示例详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪<BR>
    2022-08-08
  • 详解Java环境变量配置方法(Windows)

    详解Java环境变量配置方法(Windows)

    这篇文章主要介绍了Java环境变量配置方法(Windows),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-03-03

最新评论