网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

使用idea插件怎么制作一个弹出框-创新互联

本篇文章给大家分享的是有关使用idea插件怎么制作一个弹出框,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

十多年的通河网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整通河建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联从事“通河网站设计”,“通河网站推广”以来,每个客户项目都认真落实执行。

一、JBPopupFactory

JBPopupFactory 是idea 提供给用户自定义窗口的接口,比较常见的方法如下

  • createComponentPopupBuilder() 允许您在弹出窗口中显示任何Swing组件。

  • createPopupChooserBuilder() 创建一个多选/单选框

  • createConfirmation() 创建一个确认框

  • createActionGroupPopup() 创建一个显示方法组的窗口,选中会执行方法。

创建弹出窗口后,需要通过调用show() 方法之一来显示它。您可以通过调用showInBestPositionFor() 让IntelliJ平台根据上下文自动选择位置,或者通过showUnderneathOf() 和ShowInCenter() 等方法显式指定位置。

show() 方法立即返回,不等待弹出窗口关闭。

如果需要在弹出窗口关闭时执行某些操作,可以使用addListener() 方法将侦听器附加到它,然后重写弹出试的方法,例如onChosen(),或在弹出窗口中将事件处理程序附加到您自己的组件。

二、demo

 1.showInBestPositionFor

Shows the popup in the position most appropriate for the specified data context.
在最适合指定数据上下文的位置显示弹出窗口。

acaction 定义按钮功能

public class TextBoxes extends AnAction {

 public TextBoxes() {
  super("MYSQL_COLUMN_ADD_PRO");
 }


 @Override
 public void actionPerformed(@NotNull AnActionEvent event) {
   // 获取 JBPopupFactory
  JBPopupFactory instance = JBPopupFactory.getInstance();
  
  // 创建需要执行的任务
  Runnable runnable = new Runnable() {
   @Override
   public void run() {
    Messages.showMessageDialog("aaa", "hello", Messages.getInformationIcon());
   }
  };
  ListPopup popup = instance.createConfirmation("hello", runnable, 1);
  popup.showInBestPositionFor(event.getDataContext());
 }
}

plugins.xml


 org.example.myPlugins
 MyPlugin
 lieying
 first test plugin
 
  
 
 
  
  
   
   
    
   
  
 

实际效果

使用idea插件怎么制作一个弹出框

2.show()

Shows the popup at the specified point.
显示指定点的弹出窗口。

@Override
 public void actionPerformed(@NotNull AnActionEvent event) {
  // 获取 JBPopupFactory
  JBPopupFactory instance = JBPopupFactory.getInstance();

  // 创建需要执行的任务
  Runnable runnable = new Runnable() {
   @Override
   public void run() {
    Messages.showMessageDialog("aaa", "hello", Messages.getInformationIcon());
   }
  };
  ListPopup popup = instance.createConfirmation("hello", runnable, 1);

  // 固定指定一个点显示
  Point point = new Point(200,300);
  RelativePoint relativePoint = new RelativePoint(point);
  popup.show(relativePoint);
 }

效果如下

使用idea插件怎么制作一个弹出框

3.showUnderneathOf()

Shows the popup at the bottom left corner of the specified component.
显示指定组件左下角的弹出窗口。

@Override
 public void actionPerformed(@NotNull AnActionEvent event) {
  // 获取 JBPopupFactory
  JBPopupFactory instance = JBPopupFactory.getInstance();

  // 创建需要执行的任务
  Runnable runnable = new Runnable() {
   @Override
   public void run() {
    Messages.showMessageDialog("aaa", "hello", Messages.getInformationIcon());
   }
  };
  ListPopup popup = instance.createConfirmation("hello", runnable, 1);

  // 获取焦点的组件
  Component component = event.getDataContext().getData(PlatformDataKeys.CONTEXT_COMPONENT);
  // 组件下方显示 popup
  popup.showUnderneathOf(component); 
 }

event.getDataContext().getData(PlatformDataKeys.CONTEXT_COMPONENT); 会返回获取焦点的组件
比如

使用idea插件怎么制作一个弹出框

4.showInFocusCenter

Shows the popups in the center of currently focused component
在获取焦点组件的中间弹出popup

@Override
 public void actionPerformed(@NotNull AnActionEvent event) {
  // 获取 JBPopupFactory
  JBPopupFactory instance = JBPopupFactory.getInstance();

  // 创建需要执行的任务
  Runnable runnable = new Runnable() {
   @Override
   public void run() {
    Messages.showMessageDialog("aaa", "hello", Messages.getInformationIcon());
   }
  };
  ListPopup popup = instance.createConfirmation("hello", runnable, 1);

  popup.showInFocusCenter();
 }

以上就是使用idea插件怎么制作一个弹出框,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。


网页名称:使用idea插件怎么制作一个弹出框-创新互联
文章分享:http://bjjierui.cn/article/dsjgps.html

其他资讯