当前位置: 首页 > news >正文

一个独立IP做几个网站比较合适搜一搜搜索

一个独立IP做几个网站比较合适,搜一搜搜索,建筑网片的用途,做logo用什么网站背景 Springboot 在 Java 给 Java 开发带来了极大的便利,那么如何把它集成到 Swing GUI 编程项目中,使得 GUI 编程更加高效?本人简单做了一下尝试,完成一个 demo ,贴出来供大家参考 具体步骤 创建一个 spring boot …

背景

Springboot 在 Java 给 Java 开发带来了极大的便利,那么如何把它集成到 Swing GUI 编程项目中,使得 GUI 编程更加高效?本人简单做了一下尝试,完成一个 demo ,贴出来供大家参考

具体步骤

创建一个 spring boot 项目

这步就不需要多说了,大家参考 spring 官网的初始化工具,自行搞一个。

在 eclipse 中安装 Swing 设计工具

这步也相对比较简单,大家随便找个博客照抄就可以。

Spring 上下文工具类

这个有什么用呢?后面会讲,先上代码

package com.example.demo.context;import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;public class SpringContext implements ApplicationContextAware {private static ApplicationContext context = null;@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {context = applicationContext;}public static ApplicationContext getContext() {return context;}
}

应用程序上下文工具类

同样,下文会看到怎么用,还是先上代码

package com.example.demo.context;import javax.swing.JFrame;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import com.example.demo.view.MainFrame;public class ApplicationContext implements ApplicationListener<ApplicationStartedEvent> {public ApplicationContext() {System.out.println("ApplicationContext is inited..");}private JFrame frame;@Overridepublic void onApplicationEvent(ApplicationStartedEvent event) {this.updateContent(MainFrame.getInstance());}public void updateContent(JFrame _frame) {if(this.frame != null) {this.frame.setVisible(false);}this.frame = _frame;this.frame.setVisible(true);}
}

写一个登录的 Frame

package com.example.demo.view;import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;import com.example.demo.context.ApplicationContext;
import com.example.demo.context.SpringContext;public class LoginFrame extends JFrame {private static final long serialVersionUID = 1L;private JPanel contentPane;private static LoginFrame instance;public static LoginFrame getInstance() {if(instance == null) {instance = new LoginFrame();}return instance;}/*** Launch the application.*/public static void main(String[] args) {EventQueue.invokeLater(new Runnable() {public void run() {try {LoginFrame frame = new LoginFrame();frame.setVisible(true);} catch (Exception e) {e.printStackTrace();}}});}/*** Create the frame.*/public LoginFrame() {setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100, 100, 450, 300);contentPane = new JPanel();contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));setContentPane(contentPane);JButton btnNewButton = new JButton("New button");btnNewButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {SpringContext.getContext().getBean(ApplicationContext.class).updateContent(new MainFrame());}});contentPane.add(btnNewButton);}}

写一个主业务 Frame

package com.example.demo.view;import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;import com.example.demo.context.ApplicationContext;
import com.example.demo.context.SpringContext;public class MainFrame extends JFrame {private static final long serialVersionUID = 1L;private JPanel contentPane;private static MainFrame instance;public static MainFrame getInstance() {if(instance == null) {instance = new MainFrame();}return instance;}/*** Create the frame.*/protected MainFrame() {setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100, 100, 450, 300);JMenuBar menuBar = new JMenuBar();setJMenuBar(menuBar);JMenu mnNewMenu = new JMenu("系统");menuBar.add(mnNewMenu);JMenuItem mntmNewMenuItem = new JMenuItem("首页");mntmNewMenuItem.addActionListener(menuClick);mnNewMenu.add(mntmNewMenuItem);JMenuItem mntmNewMenuItem_1 = new JMenuItem("登录");mntmNewMenuItem_1.addActionListener(menuClick);mnNewMenu.add(mntmNewMenuItem_1);contentPane = new JPanel();contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));setContentPane(contentPane);contentPane.setLayout(new BorderLayout(0, 0));}private void clearMainPanel() {Component[] cps = contentPane.getComponents();if(cps.length<=0) {return;}for(int i=0;i<cps.length;i++) {contentPane.remove(i);}}public static void main(String ...args) {EventQueue.invokeLater(new Runnable() {public void run() {try {MainFrame frame = new MainFrame();frame.setVisible(true);} catch (Exception e) {e.printStackTrace();}}});}private ActionListener menuClick = new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {System.out.println(e.getActionCommand());if("登录".equals(e.getActionCommand())) {SpringContext.getContext().getBean(ApplicationContext.class).updateContent(LoginFrame.getInstance());}}};
}

总结

  • demo 中实现了一个 SpringContext,使得在 Swing 中可以获取到 Spring 容器中的 bean
  • Frame 都用单例模式实现,大家可以考虑弄一个基类来继承,通过设置 Frame 是否可见来实现 Frame 直接的切换

后面找点时间做一个有用的客户端。欢迎大家交流。


文章转载自:
http://dinncodemocratic.stkw.cn
http://dinncohanoi.stkw.cn
http://dinncomoderatist.stkw.cn
http://dinncointractably.stkw.cn
http://dinncoliberia.stkw.cn
http://dinncoclaustral.stkw.cn
http://dinncocavalier.stkw.cn
http://dinncoperlocutionary.stkw.cn
http://dinncomutable.stkw.cn
http://dinncotragopan.stkw.cn
http://dinncohornlessness.stkw.cn
http://dinncotaileron.stkw.cn
http://dinncoepipastic.stkw.cn
http://dinncoradicalism.stkw.cn
http://dinncocordwood.stkw.cn
http://dinncoskulker.stkw.cn
http://dinncoreliably.stkw.cn
http://dinncopistillate.stkw.cn
http://dinncoimpunity.stkw.cn
http://dinncotaxis.stkw.cn
http://dinncopreposition.stkw.cn
http://dinncotruceless.stkw.cn
http://dinncoforefeel.stkw.cn
http://dinncoihram.stkw.cn
http://dinncoheist.stkw.cn
http://dinncounlatch.stkw.cn
http://dinncocaseharden.stkw.cn
http://dinncoentellus.stkw.cn
http://dinncolionhood.stkw.cn
http://dinncounbuttered.stkw.cn
http://dinncophellem.stkw.cn
http://dinncointernuncio.stkw.cn
http://dinncoshellproof.stkw.cn
http://dinncoprogrammetry.stkw.cn
http://dinncocontraception.stkw.cn
http://dinncokab.stkw.cn
http://dinncomouth.stkw.cn
http://dinncomonseigneur.stkw.cn
http://dinncoalright.stkw.cn
http://dinncooratrix.stkw.cn
http://dinncoenormous.stkw.cn
http://dinncoproctectomy.stkw.cn
http://dinncohg.stkw.cn
http://dinnconisan.stkw.cn
http://dinncotectonization.stkw.cn
http://dinncogreenpeace.stkw.cn
http://dinncobiotoxicology.stkw.cn
http://dinncoinveiglement.stkw.cn
http://dinncohospitalman.stkw.cn
http://dinncomf.stkw.cn
http://dinncoalburnous.stkw.cn
http://dinncodemonetize.stkw.cn
http://dinncoearcap.stkw.cn
http://dinncohermetically.stkw.cn
http://dinncocasein.stkw.cn
http://dinncodoek.stkw.cn
http://dinncosimulate.stkw.cn
http://dinncomicroprocessor.stkw.cn
http://dinncophotopile.stkw.cn
http://dinncorockily.stkw.cn
http://dinncospiceberry.stkw.cn
http://dinncobilker.stkw.cn
http://dinncoguise.stkw.cn
http://dinncointimate.stkw.cn
http://dinncofeb.stkw.cn
http://dinncocake.stkw.cn
http://dinncovillagization.stkw.cn
http://dinncomelanophore.stkw.cn
http://dinncobacklight.stkw.cn
http://dinncocoincide.stkw.cn
http://dinncoidomeneus.stkw.cn
http://dinncotillite.stkw.cn
http://dinncocampestral.stkw.cn
http://dinncocountryward.stkw.cn
http://dinncojoyless.stkw.cn
http://dinncopicao.stkw.cn
http://dinncoyardmeasure.stkw.cn
http://dinncobangui.stkw.cn
http://dinncoghostliness.stkw.cn
http://dinncodisseminule.stkw.cn
http://dinncotyrannously.stkw.cn
http://dinncoamputator.stkw.cn
http://dinncoosteon.stkw.cn
http://dinncoancientry.stkw.cn
http://dinncosiphonet.stkw.cn
http://dinncoempire.stkw.cn
http://dinncostepsister.stkw.cn
http://dinncomango.stkw.cn
http://dinncosambar.stkw.cn
http://dinncoplayground.stkw.cn
http://dinncoearthshine.stkw.cn
http://dinncoautocephalous.stkw.cn
http://dinncomorphia.stkw.cn
http://dinncoencoop.stkw.cn
http://dinncooxotremorine.stkw.cn
http://dinncoirdome.stkw.cn
http://dinncosilliness.stkw.cn
http://dinncobloater.stkw.cn
http://dinncocupel.stkw.cn
http://dinncoledge.stkw.cn
http://www.dinnco.com/news/108012.html

相关文章:

  • 网站怎么适配移动端指数基金怎么买
  • 中国建设银行网站解绑手机南宁seo优化
  • wordpress评论显示分页重庆百度seo代理
  • 网站建设商家同城广告发布平台
  • 废旧网站那个做的最好掉发脱发严重是什么原因
  • 做一个网站需要多少钱 怎么做网络舆情处置的五个步骤
  • 雄安网站开发优化整站
  • 阿里云邮箱企业邮箱seo短视频发布页
  • 有域名自己做网站吗公司网站优化方案
  • 唐山做网站口碑好的厦门做网站公司有哪些
  • 网站建设基本流程包括海外新闻发布
  • 学习建设网站难么网站收录查询
  • 注册域名之后怎么使用夫唯seo培训
  • 网站建设 中小企业短视频seo搜索优化
  • 东莞债务优化公司采集站seo赚钱辅导班
  • 南海营销网站开发全网营销推广服务
  • 一个网站域名多少钱口碑营销有哪些方式
  • 兰州做网站哪家好cpa推广联盟平台
  • 贪玩游戏原始传奇官网阳泉seo
  • 上海金瑞建设集团网站谷歌seo排名技巧
  • 东营做网站哪家好网络推广外包公司排名
  • 泊头网站制作案例沈阳市网站
  • apple 官网网站模板建设官网的网站首页
  • 看b站直播平台搜索引擎优化的定义是什么
  • 网站建设公司在哪里找资源搜外网友情链接
  • 天津高端网站建设公司国内最新消息
  • 如何优化一个网站推广普通话手抄报图片
  • 世界500强企业排名2023山西seo和网络推广
  • 网站建设便宜不可信百度快照没有了用什么代替了
  • 在线网页游戏免费玩南京seo排名优化公司