前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >图书管理系统代码 6 AboutFrame (…

图书管理系统代码 6 AboutFrame (…

作者头像
明明如月学长
发布2021-08-27 10:59:31
3440
发布2021-08-27 10:59:31
举报
文章被收录于专栏:明明如月的技术专栏

import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.Graphics; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Image; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;

import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException;

public class AboutFrame extends JFrame { public AboutFrame(){ setTitle("图书管理系统—关于"); Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screenSize = kit.getScreenSize(); double screenWidth = screenSize.getWidth(); double screenHeight = screenSize.getHeight(); setBounds((int)screenWidth/2-DEFAULT_WIDTH/2,(int)screenHeight/2-DEFAULT_HEIGHT/2,DEFAULT_WIDTH,DEFAULT_HEIGHT); //设置图标 Image ima = kit.getImage("library.png"); setIconImage(ima); //设置 观感 String plaf = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"; try { UIManager.setLookAndFeel(plaf); } catch (ClassNotFoundException e2) { e2.printStackTrace(); } catch (InstantiationException e2) { e2.printStackTrace(); } catch (IllegalAccessException e2) { e2.printStackTrace(); } catch (UnsupportedLookAndFeelException e2) {  e2.printStackTrace(); } SwingUtilities.updateComponentTreeUI(this);

this.setResizable(false); //设置字体 Font f1 = new Font("隶书",Font.PLAIN,20); Font f2 = new Font("隶书",Font.PLAIN,20); this.setLayout(new BorderLayout()); JPanel northPanel = new JPanel(); JPanel southPanel = new JPanel(); this.add(northPanel,BorderLayout.CENTER); this.add(southPanel,BorderLayout.SOUTH); northPanel.setLayout(new GridBagLayout()); lb1 = new JLabel("作者:"); lb1.setForeground(FG1); lb1.setFont(f1); lb2 = new JLabel("刘汪洋"); lb2.setForeground(FG2); lb2.setFont(f2); lb3 = new JLabel("版本:"); lb3.setForeground(FG1); lb3.setFont(f1); lb4 = new JLabel("1.0.0"); lb4.setForeground(FG2); lb4.setFont(f2); northPanel.add(lb1,new GBC(0,0)); northPanel.add(lb2,new GBC(1,0)); northPanel.add(lb3,new GBC(0,1)); northPanel.add(lb4,new GBC(1,1)); southPanel.setLayout(new FlowLayout()); JButton ok = new JButton("确定",new ImageIcon("ok.png")); southPanel.add(ok); ok.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { AboutFrame.this.setVisible(false); AboutFrame.this.dispose(); } }); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

} public  static final int DEFAULT_WIDTH =350; public  static final int DEFAULT_HEIGHT =200; private Image image; private JLabel lb1; private JLabel lb2; private JLabel lb3; private JLabel lb4; Color FG1 = Color.RED; Color FG2 = Color.BLUE; }

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2015/06/20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档