📄 changepet.java
字号:
package yd.pethospital.petregister.view;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import yd.pethospital.petregister.jdbc.*;
public class ChangePet extends JFrame{
JLabel LNum,LName,LType,LSex,LBirth,LFace,LHost,LDate; //标签:编号 名称 类型 性别 出生 外貌 主人 登记
public static JTextField TNum,TName,TBirth,TFace,THost,TDate; //文本:编号 名称 类型 出生 外貌 主人 登记
public static JRadioButton male,female; //
JButton BSure,BCancel;
public static Choice CType; //性别的下拉列表
public ChangePet(){
this.setTitle("修改宠物"); //设置窗体 标题 不可改变大小 位置 大小 空布局
this.setResizable(false);
this.setBounds(400, 150, 400, 410);
this.setLayout(null);
this.validate();
LNum=new JLabel("宠物编号"); //设置编号标签
LNum.setBounds(30,15,70,50);
LNum.setFont(new Font(null,Font.BOLD,15));
this.add(LNum);
LName=new JLabel("宠物名称"); //设置名称标签
LName.setBounds(30,50,70,50);
LName.setFont(new Font(null,Font.BOLD,15));
this.add(LName);
LType=new JLabel("宠物类别"); //设置类别 标签
LType.setBounds(30,85,70,50);
LType.setFont(new Font(null,Font.BOLD,15));
this.add(LType);
LSex=new JLabel("性 别"); //设置性别标签
LSex.setBounds(30,120,70,50);
LSex.setFont(new Font(null,Font.BOLD,15));
this.add(LSex);
LBirth=new JLabel("出生日期"); //设置日期标签
LBirth.setBounds(30,155,70,50);
LBirth.setFont(new Font(null,Font.BOLD,15));
this.add(LBirth);
LFace=new JLabel("外部特证"); //设置外貌标签
LFace.setBounds(30,190,70,50);
LFace.setFont(new Font(null,Font.BOLD,15));
this.add(LFace);
LHost=new JLabel("宠物主人"); //设置主人标签
LHost.setBounds(30,225,70,50);
LHost.setFont(new Font(null,Font.BOLD,15));
this.add(LHost);
LDate=new JLabel("登记日期"); //设置登陆日期标签
LDate.setBounds(30,260,70,50);
LDate.setFont(new Font(null,Font.BOLD,15));
this.add(LDate);
TNum=new JTextField(20); //设置编号文本
TNum.setBounds(115,25,110,25);
TNum.setEditable(false);
this.add(TNum);
TName=new JTextField(20); //设置名称文本
TName.setBounds(115,65,110,25);
this.add(TName);
TBirth=new JTextField(30); //设置出生文本
TBirth.setBounds(115,170,130,25);
TBirth.setToolTipText("请输入YYYY-MM-DD格式时间");
this.add(TBirth);
TFace=new JTextField(20); //设置外貌文本
TFace.setBounds(115,206,260,25);
this.add(TFace);
THost=new JTextField(20); //设置主人文本
THost.setBounds(115,242,130,25);
this.add(THost);
TDate=new JTextField(30); //设置登陆文本
TDate.setBounds(115,277,130,25);
TDate.setToolTipText("请输入YYYY-MM-DD格式时间");
this.add(TDate);
CType=new Choice(); //设置类型下拉列表
CType.setBounds(115,103,100,25);
CType.addItem("猫"); //添加下拉选项
CType.addItem("狗");
CType.addItem("猪");
CType.addItem("羊");
CType.addItem("龟");
CType.addItem("鸟");
CType.addItem("鱼");
CType.addItem("蛇");
CType.addItem("其它");
this.add(CType);
ButtonGroup group=new ButtonGroup(); //单选按钮组
male=new JRadioButton("雄性",true);
female=new JRadioButton("雌性",false);
male.setBounds(115,130,65,40);
female.setBounds(180,130,65,40);
group.add(male);
group.add(female);
this.add(male);
this.add(female);
BSure=new JButton("确定"); //确定按钮
BSure.setBounds(60,320,70,25);
this.add(BSure);
BSure.addActionListener(new ActionListener(){ //添加确定的事件监听器
public void actionPerformed(ActionEvent e) {
new ChangePetGet(ChangePet.this);
}
});
BCancel=new JButton("取消"); //取消按钮
BCancel.setBounds(200,320,70,25);
this.add(BCancel);
BCancel.addActionListener(new ActionListener(){ //添加取消的事件监听器
public void actionPerformed(ActionEvent e) {
ChangePet.this.dispose();
new PetRegister();
}
});
this.setVisible(true); //设置窗体可视
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -