📄 bedmanage.java
字号:
//床位管理 运用cardLayout布局 调用函数room()
package src;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.JLabel;
public class bedManage implements MouseListener{
public static JFrame fm;
private JPanel jp2;
public bedManage(){
fm=new JFrame("床位管理");
fm.setLocation(220,150);
fm.setSize(650,450);
//modify title image
ImageIcon title=new ImageIcon("images/pill.gif");
fm.setIconImage(title.getImage());
CardLayoutDemo(fm.getContentPane()); //调用cardlayout布局
fm.setResizable(false);
fm.setVisible(true);
}
public void CardLayoutDemo(Container pane){
//病房和床位安排及详细信息
JPanel jp0=new JPanel();
jp0.add(new JLabel(new ImageIcon("images/head2.gif")));
pane.add("North",jp0);
JPanel jp1=new JPanel(new GridLayout(5,1));
jp1.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("科室"),
BorderFactory.createEmptyBorder(0,1,1,1)));
ImageIcon office=new ImageIcon("images/img11.gif");
JLabel room1=new JLabel("Office51",office,JLabel.TRAILING);
room1.addMouseListener(this);
room1.setName("51");//office51
JLabel room2=new JLabel("Office52",office,JLabel.TRAILING);
room2.addMouseListener(this);
room2.setName("52");//office52
JLabel room3=new JLabel("Office53",office,JLabel.TRAILING);
room3.addMouseListener(this);
room3.setName("53");//office53
JLabel room4=new JLabel("Office54",office,JLabel.TRAILING);
room4.addMouseListener(this);
room4.setName("54");//office54
JLabel room5=new JLabel("Office55",office,JLabel.TRAILING);
room5.addMouseListener(this);
room5.setName("55");//office55
jp1.add(room1);jp1.add(room2);jp1.add(room3);jp1.add(room4);jp1.add(room5);
jp2=new JPanel(new CardLayout());
room office1=new room("office51-01","office51-02","office51-03","office51-04","office51-05","office51-06");
room office2=new room("office52-01","office52-02","office52-03","office52-04","office52-05","office52-06","office52-07","office52-08");
room office3=new room("office53-01","office53-02","office53-03","office53-04","office53-05","office53-06");
room office4=new room("office54-01","office54-02","office54-03","office54-04","office54-05","office54-06","office54-07","office54-08");
room office5=new room("office55-01","office55-02","office55-03","office55-04","office55-05","office55-06");
jp2.add(office1,"51");
jp2.add(office2,"52");
jp2.add(office3,"53");
jp2.add(office4,"54");
jp2.add(office5,"55");
pane.add("West",jp1);
pane.add("Center",jp2);
}
public void mouseClicked(MouseEvent e){
}
public void mouseEntered(MouseEvent e){
CardLayout layout = (CardLayout)(jp2.getLayout());
e.getComponent().setForeground(Color.BLUE);
layout.show(jp2,e.getComponent().getName());
}
public void mouseExited(MouseEvent e){
e.getComponent().setForeground(Color.BLACK);
}
public void mousePressed(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -