主界面和字体,图片设置类
Index.java
~~~
package cy.view;
import java.awt.*;
import javax.swing.*;
public class Index extends JWindow implements Runnable
{
JProgressBar jpb;//绘制进度条
JLabel jl1;
int width,height;
public static void main(String[] args)
{
Index index=new Index();
Thread t=new Thread(index);//启动线程-进度条
t.start();
}
public Index()
{
jl1=new JLabel(new ImageIcon("image/index.gif"));
jpb=new JProgressBar();
jpb.setStringPainted(true);
jpb.setIndeterminate(false);
jpb.setBorderPainted(false);
jpb.setBackground(Color.darkGray);
this.add(jl1,BorderLayout.NORTH);
this.add(jpb,BorderLayout.SOUTH);
this.setSize(400,263);
width=Toolkit.getDefaultToolkit().getScreenSize().width;
height=Toolkit.getDefaultToolkit().getScreenSize().height;
this.setLocation(width/2-200,height/2-150);
this.setVisible(true);
}
@Override
public void run() {
int []progressValue={0,1,5,8,14,17,26,35,38,43,49,56,65,71,75,78,86,94,98,99,100};
for(int i=0;i<progressValue.length;i++)
{
try {
Thread.sleep(1000);
} catch (Exception e) {}
jpb.setValue(progressValue[i]);
}
new Login();//打开登录页面
this.dispose();//当前界面关闭
}
}
~~~
Login.java
~~~
package cy.view;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.border.*;
import cy.tool.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
//import cy.moxing.*;
public class Login extends JDialog /*implements ActionListener*/
{
JLabel jl1,jl2,jl3;//标签
JTextField jname;//文本框
JPasswordField jpasswd;//密码框
JButton jlog,jcancle;//按钮
Font f1;
public static void main(String []args)
{
Login login=new Login();
}
public Login()
{
jl1=new JLabel("请输入用户名:");
jl1.setBounds(60, 190, 150, 30);
jl1.setFont(MyFont.f1);
this.add(jl1);
jl2=new JLabel("(或员工号)");
jl2.setForeground(Color.red);
jl2.setFont(MyFont.f2);
jl2.setBounds(100,210,100,30);
this.add(jl2);
jl3=new JLabel ("请输入密码:");
jl3.setBounds(60,240,150,30);
jl3.setFont(MyFont.f2);
this.add(jl3);
jname=new JTextField(20);
jname.setFocusable(true);//光标默认在这儿
jname.setBounds(180,190,120,30);
jname.setFont(f1);
this.add(jname);
jname.setBorder(BorderFactory.createLoweredBevelBorder());
jpasswd=new JPasswordField();
jpasswd.setFocusable(true);
jpasswd.setBounds(180,240,120,30);
this.add(jpasswd);
jpasswd.setBorder(BorderFactory.createLoweredBevelBorder());
jlog=new JButton("确 定");
//jlog.addActionListener(this);
jlog.setBounds(105,300,75,30);
jlog.setFont(f1);
jlog.setForeground(Color.blue);
this.add(jlog);
jcancle=new JButton("取 消");
//jcancle.addActionListener(this);
jcancle.setBounds(215,300,75,30);
jcancle.setFont(f1);
jcancle.setForeground(Color.blue);
this.add(jcancle);
this.setLayout(null);
BackImage bi=new BackImage();
bi.setBounds(0,0,360,360);
this.add(bi);
this.setUndecorated(true);
this.setSize(360, 360);
int width=getToolkit().getDefaultToolkit().getScreenSize().width;
int height=getToolkit().getDefaultToolkit().getScreenSize().height;
this.setLocation(width/2-200,height/2-200);
this.setVisible(true);
}
/* public void actionPerformed(ActionEvent e)
{
if(e.getSource()==jlog)
{
// String userName=this.jname.getText().trim();
// String passwd=new String(this.jpasswd.getPassword());
// Moxing um=new Moxing();
// String zhiwei=um.checkUser(userName, passwd);
// if(zhiwei.equals("经理")||zhiwei.equals("管理员")||zhiwei.equals("主管"))
{
new Caozuo();
this.dispose();
}
// else
// {
// JOptionPane.showMessageDialog(this,"用户名或密码错误");
// }
}
else if(e.getSource()==jcancle)
{
this.dispose();
}
} */
}
class BackImage extends JPanel
{
Image im;
public BackImage()
{
try
{
im=ImageIO.read(new File("image/login.gif"));
}
catch(Exception e){}
}
public void paint(Graphics g)
{
g.drawImage(im,0,0,360,360,this);
}
}
~~~
Main.java
~~~
package cy.view;
import cy.tool.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.Timer;
import java.util.*;
import java.awt.event.*;
import javax.imageio.*;
import java.io.*;
//import com.sun.java.swing.plaf.windows.resources.windows;
public class Main extends JFrame /*implements ActionListener,MouseListener*/
{
Image titleIcon,timebg;
JMenuBar jmb;
JMenu jm1,jm2,jm3,jm4,jm5,jm6;
JMenuItem jmm1,jmm2,jmm3,jmm4,jmm5;
ImageIcon jm1_icon1,jm1_icon2,jm1_icon3,jm1_icon4,jm1_icon5;
JToolBar jtb;
JButton jb1,jb2,jb3,jb4,jb5,jb6,jb7,jb8,jb9,jb10;
JPanel jp1,jp2,jp3,jp4,jp5;
JPanel jp3_1,jp3_2,jp3_3,jp3_4,jp3_5,jp3_6,jp3_7;
ImagePanel jp1_imgPanel;
Image jp1_bg;
JLabel jp1_lab1,jp1_lab2,jp1_lab3,jp1_lab4,jp1_lab5,jp1_lab6,jp1_lab7,jp1_lab8;
JLabel jp2_lab1,jp2_lab2;
Image jp3_bg;
JLabel jp3_l1,jp3_l2,jp3_l3,jp3_l4,jp3_l5,jp3_l6,jp3_l7;
CardLayout cardjp2,cardjp3;
JSplitPane jsp1;
JLabel timeNow;
javax.swing.Timer t;
public static void main(String[] args)
{
Main cz=new Main();
}
public void initMenu()
{
jm1_icon1=new ImageIcon("image/jm1_icon1.jpg");
jm1_icon2=new ImageIcon("image/jm1_icon2.jpg");
jm1_icon3=new ImageIcon("image/jm1_icon3.jpg");
jm1_icon4=new ImageIcon("image/jm1_icon4.jpg");
jm1_icon5=new ImageIcon("image/jm1_icon5.jpg");
jm1=new JMenu("系统管理");
jm1.setFont(MyFont.f1);
jmm1=new JMenuItem("切换用户",jm1_icon1);
jmm1.setFont(MyFont.f2);
jmm2=new JMenuItem("切换到收款界面",jm1_icon2);
jmm2.setFont(MyFont.f2);
jmm3=new JMenuItem("登陆管理",jm1_icon3);
jmm3.setFont(MyFont.f2);
jmm4=new JMenuItem("万年历",jm1_icon4);
jmm4.setFont(MyFont.f2);
jmm5=new JMenuItem("退出",jm1_icon5);
jmm5.setFont(MyFont.f2);
jm1.add(jmm1);
jm1.add(jmm2);
jm1.add(jmm3);
jm1.add(jmm4);
jm1.add(jmm5);
jm2=new JMenu("人事管理");
jm2.setFont(MyFont.f1);
jm3=new JMenu("菜单服务");
jm3.setFont(MyFont.f1);
jm4=new JMenu("报表统计");
jm4.setFont(MyFont.f1);
jm5=new JMenu("成本及库房");
jm5.setFont(MyFont.f1);
jm6=new JMenu("帮助");
jm6.setFont(MyFont.f1);
jmb=new JMenuBar();
jmb.add(jm1);
jmb.add(jm2);
jmb.add(jm3);
jmb.add(jm4);
jmb.add(jm5);
jmb.add(jm6);
this.setJMenuBar(jmb);
}
public void initToolBar()
{
jtb=new JToolBar();
jtb.setFloatable(false);
jb1=new JButton(new ImageIcon("image/jb1.jpg"));
jb2=new JButton(new ImageIcon("image/jb2.jpg"));
jb3=new JButton(new ImageIcon("image/jb3.jpg"));
jb4=new JButton(new ImageIcon("image/jb4.jpg"));
jb5=new JButton(new ImageIcon("image/jb5.jpg"));
jb6=new JButton(new ImageIcon("image/jb6.jpg"));
jb7=new JButton(new ImageIcon("image/jb7.jpg"));
jb8=new JButton(new ImageIcon("image/jb8.jpg"));
jb9=new JButton(new ImageIcon("image/jb9.jpg"));
jb10=new JButton(new ImageIcon("image/jb10.jpg"));
jtb.add(jb1);
jtb.add(jb2);
jtb.add(jb3);
jtb.add(jb4);
jtb.add(jb5);
jtb.add(jb6);
jtb.add(jb7);
jtb.add(jb8);
jtb.add(jb9);
jtb.add(jb10);
this.add(jtb,BorderLayout.NORTH);
}
public void initAllPanel()
{
jp1=new JPanel(new BorderLayout());
try {
jp1_bg=ImageIO.read(new File("image/jp1_bg.jpg"));
} catch (Exception e) {}
Cursor myCursor=new Cursor(Cursor.HAND_CURSOR);
jp1_imgPanel=new ImagePanel(jp1_bg);
this.jp1_imgPanel.setLayout(new GridLayout(8,1));
jp1_lab1=new JLabel(new ImageIcon("image/label_1.gif"));
jp1_imgPanel.add(jp1_lab1);
jp1_lab2=new JLabel("人 事 管 理",new ImageIcon("image/label_2.jpg"),0);
jp1_lab2.setFont(MyFont.f4);
jp1_lab2.setCursor(myCursor);
jp1_lab2.setEnabled(false);
//jp1_lab2.addMouseListener(this);
jp1_imgPanel.add(jp1_lab2);
jp1_lab3=new JLabel("登 陆 管 理",new ImageIcon("image/label_3.jpg"),0);
jp1_lab3.setFont(MyFont.f4);
jp1_lab3.setCursor(myCursor);
jp1_lab3.setEnabled(false);
//jp1_lab3.addMouseListener(this);
jp1_imgPanel.add(jp1_lab3);
jp1_lab4=new JLabel("菜 谱 价 格",new ImageIcon("image/label_4.jpg"),0);
jp1_lab4.setFont(MyFont.f4);
jp1_lab4.setCursor(myCursor);
jp1_lab4.setEnabled(false);
//jp1_lab4.addMouseListener(this);
jp1_imgPanel.add(jp1_lab4);
jp1_lab5=new JLabel("报 表 统 计",new ImageIcon("image/label_5.jpg"),0);
jp1_lab5.setFont(MyFont.f4);
jp1_lab5.setCursor(myCursor);
jp1_lab5.setEnabled(false);
//jp1_lab5.addMouseListener(this);
jp1_imgPanel.add(jp1_lab5);
jp1_lab6=new JLabel("成本及库房",new ImageIcon("image/label_6.jpg"),0);
jp1_lab6.setFont(MyFont.f4);
jp1_lab6.setCursor(myCursor);
jp1_lab6.setEnabled(false);
//jp1_lab6.addMouseListener(this);
jp1_imgPanel.add(jp1_lab6);
jp1_lab7=new JLabel("系 统 设 置",new ImageIcon("image/label_7.jpg"),0);
jp1_lab7.setFont(MyFont.f4);
jp1_lab7.setCursor(myCursor);
jp1_lab7.setEnabled(false);
//jp1_lab7.addMouseListener(this);
jp1_imgPanel.add(jp1_lab7);
jp1_lab8=new JLabel("动 画 帮 助",new ImageIcon("image/label_8.jpg"),0);
jp1_lab8.setFont(MyFont.f4);
jp1_lab2.setCursor(myCursor);
jp1_lab8.setEnabled(false);
//jp1_lab8.addMouseListener(this);
jp1_imgPanel.add(jp1_lab8);
jp1.add(jp1_imgPanel);
jp4=new JPanel(new BorderLayout());
this.cardjp2=new CardLayout();
jp2=new JPanel(cardjp2);
jp2_lab1=new JLabel(new ImageIcon("image/jp2_left.jpg"));
//jp2_lab1.addMouseListener(this);
jp2_lab2=new JLabel(new ImageIcon("image/jp2_right.jpg"));
//jp2_lab2.addMouseListener(this);
jp2.add(jp2_lab1,"0");
jp2.add(jp2_lab2,"1");
this.cardjp3=new CardLayout();
jp3=new JPanel(cardjp3);
try {
jp3_bg=ImageIO.read(new File("image/jp3_5.jpg"));
} catch (Exception e1) {}
ImagePanel ip_jp3=new ImagePanel(jp3_bg);
jp3_l1=new JLabel(new ImageIcon("image/jp3_1.jpg"));
jp3_l2=new JLabel(new ImageIcon("image/jp3_2.jpg"));
jp3_l3=new JLabel(new ImageIcon("image/jp3_3.jpg"));
jp3_l4=new JLabel(new ImageIcon("image/jp3_4.jpg"));
jp3_l5=new JLabel(new ImageIcon("image/jp3_5.jpg"));
jp3_l6=new JLabel(new ImageIcon("image/jp3_6.jpg"));
jp3_l7=new JLabel(new ImageIcon("image/jp3_7.jpg"));
jp3_1=new JPanel();
jp3_1.add(jp3_l1);
jp3_2=new JPanel();
jp3_2.add(jp3_l2);
jp3_3=new JPanel();
jp3_3.add(jp3_l3);
jp3_4=new JPanel();
jp3_4.add(jp3_l4);
jp3_5=new JPanel();
jp3_5.add(jp3_l5);
jp3_6=new JPanel();
jp3_6.add(jp3_l6);
jp3_7=new JPanel();
jp3_7.add(jp3_l7);
jp3.add(ip_jp3,"0");
jp3.add(jp3_1,"1");
jp3.add(jp3_2,"2");
jp3.add(jp3_3,"3");
jp3.add(jp3_4,"4");
jp3.add(jp3_5,"5");
jp3.add(jp3_6,"6");
jp3.add(jp3_7,"7");
jp4.add(jp2,BorderLayout.WEST);
jp4.add(jp3,BorderLayout.CENTER);
jsp1=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,jp1,jp4);
jsp1.setDividerLocation(150);
jsp1.setDividerSize(0);
this.add(jsp1,BorderLayout.CENTER);
}
public void initJp5()
{
jp5=new JPanel();
jp5.setLayout(new BorderLayout());
//t=new Timer(1000,this);
//t.start();
timeNow=new JLabel(Calendar.getInstance().getTime().toLocaleString());
timeNow.setFont(MyFont.f3);
try {
timebg=ImageIO.read(new File("image/time_bg.jpg"));
} catch (Exception e) {}
ImagePanel ip1=new ImagePanel(timebg);
ip1.setLayout(new BorderLayout());
ip1.add(timeNow,BorderLayout.EAST);
jp5.add(ip1);
this.add(jp5,BorderLayout.SOUTH);
}
public Main()
{
try {
titleIcon=ImageIO.read(new File("image/title.gif"));
} catch (IOException e) {}
this.setIconImage(titleIcon);
this.setTitle("满汉楼餐饮管理系统");
this.setFont(MyFont.f0);
this.initMenu();
this.initToolBar();
this.initAllPanel();
this.initJp5();
int width=Toolkit.getDefaultToolkit().getScreenSize().width;
int height=Toolkit.getDefaultToolkit().getScreenSize().height;
this.setSize(width,height-32);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
//@Override
/*public void actionPerformed(ActionEvent e)
{
this.timeNow.setText("当前系统时间:"+Calendar.getInstance().getTime().toLocaleString()+" ");
}
public void mouseClicked(MouseEvent e) {
if(e.getSource()==this.jp1_lab2)
{
this.cardjp3.show(jp3, "1");
}
else if(e.getSource()==this.jp1_lab3)
{
this.cardjp3.show(jp3, "2");
}
else if(e.getSource()==this.jp1_lab4)
{
this.cardjp3.show(jp3, "3");
}
else if(e.getSource()==this.jp1_lab5)
{
this.cardjp3.show(jp3, "4");
}
else if(e.getSource()==this.jp1_lab6)
{
this.cardjp3.show(jp3, "5");
}
else if(e.getSource()==this.jp1_lab7)
{
this.cardjp3.show(jp3, "6");
}
else if(e.getSource()==this.jp1_lab8)
{
this.cardjp3.show(jp3, "7");
}
else if(e.getSource()==jp2_lab1)
{
this.jsp1.setDividerLocation(0);
this.cardjp2.show(jp2,"1");
}
else if(e.getSource()==jp2_lab2)
{
this.jsp1.setDividerLocation(150);
this.cardjp2.show(jp2,"0");
}
}
public void mouseEntered(MouseEvent e) {
if(e.getSource()==this.jp1_lab2)
{
this.jp1_lab2.setEnabled(true);
}
else if(e.getSource()==this.jp1_lab3)
{
this.jp1_lab3.setEnabled(true);
}
else if(e.getSource()==this.jp1_lab4)
{
this.jp1_lab4.setEnabled(true);
}
else if(e.getSource()==this.jp1_lab5)
{
this.jp1_lab5.setEnabled(true);
}
else if(e.getSource()==this.jp1_lab6)
{
this.jp1_lab6.setEnabled(true);
}
else if(e.getSource()==this.jp1_lab7)
{
this.jp1_lab7.setEnabled(true);
}
else if(e.getSource()==this.jp1_lab8)
{
this.jp1_lab8.setEnabled(true);
}
}
public void mouseExited(MouseEvent e) {
if(e.getSource()==this.jp1_lab2)
{
this.jp1_lab2.setEnabled(false);
}
else if(e.getSource()==this.jp1_lab3)
{
this.jp1_lab3.setEnabled(false);
}
else if(e.getSource()==this.jp1_lab4)
{
this.jp1_lab4.setEnabled(false);
}
else if(e.getSource()==this.jp1_lab5)
{
this.jp1_lab5.setEnabled(false);
}
else if(e.getSource()==this.jp1_lab6)
{
this.jp1_lab6.setEnabled(false);
}
else if(e.getSource()==this.jp1_lab7)
{
this.jp1_lab7.setEnabled(false);
}
else if(e.getSource()==this.jp1_lab8)
{
this.jp1_lab8.setEnabled(false);
}
}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e){}*/
}
~~~
MyFont.java
~~~
package cy.tool;
import java.awt.Font;
public class MyFont {
public static Font f0=new Font("宋体",Font.PLAIN,18);
public static Font f1=new Font("宋体",Font.PLAIN,16);
public static Font f2=new Font("宋体",Font.PLAIN,14);
public static Font f3=new Font("宋体",Font.PLAIN,15);
public static Font f4=new Font("宋体",Font.PLAIN,13);
}
~~~
ImagePanel.java
~~~
package cy.tool;
import java.awt.*;
import javax.swing.*;
import javax.imageio.*;
public class ImagePanel extends JPanel{
Image im;
public ImagePanel(Image im)
{
this.im=im;
int width=Toolkit.getDefaultToolkit().getScreenSize().width;
int height=Toolkit.getDefaultToolkit().getScreenSize().height;
this.setSize(width,height);
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.drawImage(im,0,0,this.getWidth(),this.getHeight(),this);
}
}
~~~
![](https://box.kancloud.cn/abae7843b40ac0c7f4ddbce7c5210a43_1366x728.png)
- 书写心得
- 基础回顾
- 异常的处理
- equils方法
- 集合类
- ArrayList的遍历和添加
- ArrayList的删除插入
- 实例:食品库存管理
- HashMap
- 集合类的区别和选择
- 泛型和反射机制
- 图形化用户界面(GUI)
- JFrame容器
- 边界布局管理器
- 流式布局管理器
- 网格布局管理器
- Jpanel面板
- 文本框和标签
- 单选按钮和复选按钮
- 下拉列表框和滚动条
- 拆分窗口
- 聊天窗口
- 用户登录界面
- 记事本界面
- 线程
- 创建线程的方法
- 线程的优先级
- 线程的睡眠
- 线程的让步与阻塞
- 买票问题
- 生产消费问题
- IO流
- 字符流
- 字节流
- 缓冲流
- 数据流传输
- 转换流
- 空字符串区别
- Print流
- Object
- IO流补充
- 绘图技术和事件处理机制
- 绘图基础-绘制图形
- 绘图基础-绘制图像
- 绘图基础-绘制文字
- 事件处理-事件监听
- 事件处理-控件事件
- 事件处理-键盘事件
- 事件处理-鼠标事件
- 事件处理-窗口事件
- 记事本
- 坦克大战
- 阶段1
- 阶段2
- 阶段3
- 阶段4
- 阶段5
- 阶段6
- 阶段7
- 阶段8
- 阶段9
- 阶段10
- 阶段11
- 阶段12
- 阶段13
- 阶段14
- SQL Server 2005
- 简易学生管理系统
- 阶段(1)-显示
- 阶段(2)-查询
- 阶段(3)-添加
- 阶段(4)-删除
- 阶段(5)-修改
- 简易餐饮管理系统
- 阶段-01
- 阶段-02
- 阶段-03
- 阶段-04
- Index.java
- Login.java
- Main.java
- MyFont.java
- ImagePanel.java
- Conn.java
- Moxing.java
- 网络编程基础
- 互发信息(1)-传输
- 互发信息(2)-互发
- 互发信息(3)-GUI
- 互发信息(4)-对象流
- 网络聊天工具
- 阶段--01--界面
- Server
- Index
- Client
- Login
- Chat
- List