⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainframesetdialog.java

📁 一个简单的图书馆的管理系统,该系统主要是针对学校的图书馆而做的
💻 JAVA
字号:
package librarymanagement.view.dialog;

import java.awt.Color;
import java.awt.GridBagLayout;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import librarymanagement.view.common.GBC;

/**
 * 构建系统设置对话框
 * @author 虎兴龙
 *
 */

public class MainFrameSetDialog extends JDialog{
    private JPanel basePanel,panel1,panel2,panel3,panel4;
    private JLabel libraryName,address,mail,tel,sponsorMan,faJinPerDay,yajinBeiShu;
    private JComboBox sponsorManCombo;
	private JTextField libraryNameTxt,addressTxt,mailTxt,telTxt,faJinPerDayTxt,yajinBeiShuTxt;
	private JRadioButton bookIdBtn,readerIdBtn;
	private JCheckBox CB1,CB2,CB3,CB4,CB5,CB6;
    /**
	 * @see initThisDialog()
	 *
	 */
  public MainFrameSetDialog(){
	 super();
	 this.setModal(true);
	 this.setName("系统设置");
	 initThisDialog();
 }

private void initThisDialog() {
	this.setLayout(new GridBagLayout());
	this.setSize(400, 600);
	this.add(buildPanel1(),new GBC(0,0));
	this.add(buildPanel2());
	this.add(buildPanel3());
	this.add(buildPanel4());
	this.add(buildBtn("保存"));
	this.add(buildBtn("取消"));
	
}
/*private JPanel buildBasePanel(){
	if(basePanel ==null){
		basePanel = new JPanel();
		basePanel.setLayout(new GridBagLayout());
		this.setLayout(new GridBagLayout());
		this.setSize(400, 600);
		this.add(buildPanel1(),new GBC(0,0));
		this.add(buildPanel2());
		this.add(buildPanel3());
		this.add(buildPanel4());
		this.add(buildBtn("保存"));
		this.add(buildBtn("取消"));
		
	}
	return basePanel;
}*/
/**
 * 构建第一个面板
 * @return 返回一个JPanel 类型的对象
 * @see 		initJLabel();
 *		      initJTextField();
 */
private JPanel buildPanel1(){
	if(panel1 == null ){
		panel1 = new JPanel();
		initJLabel();
		initJTextField();
		panel1.setLayout(new GridLayout(7,2));
		panel1.add(libraryName);
		panel1.add(libraryNameTxt);
		panel1.add(address);
		panel1.add(addressTxt);
		panel1.add(mail);
		panel1.add(mailTxt);
		
		panel1.add(sponsorMan);
		panel1.add(sponsorManCombo);
		panel1.add(faJinPerDay);
		panel1.add(faJinPerDayTxt);
		panel1.add(yajinBeiShu);
		panel1.add(yajinBeiShuTxt);
		panel1.setBorder(BorderFactory.createLineBorder(Color.BLUE));
	}
	return panel1;
}
/**
 * 构建第一个面板
 * @return 返回一个JPanel 类型的对象
 * @see buildRadioButton()
 */
private JPanel buildPanel2(){
	if(panel2 == null){
		panel2 = new JPanel();
		panel2.setLayout(new GridLayout(2,1));
		buildRadioButton();
		panel2.add(bookIdBtn);
		panel2.add(readerIdBtn);
		panel2.setBorder(BorderFactory.createTitledBorder("归还焦点"));
	}
	return panel2;
}
/**
 * 构建第三个面板
 * @return 返回一个JPanel 类型的对象
 * @see buildCheckBox()
 */
private JPanel buildPanel3(){
	if(panel3 == null){
		panel3 = new JPanel();
		panel3.setLayout(new GridLayout(2,3));
		buildCheckBox();
		panel3.add(CB1);
		panel3.add(CB2);
		panel3.add(CB3);
		panel3.add(CB4);
		panel3.add(CB5);
		panel3.add(CB6);
		panel3.setBorder(BorderFactory.createLineBorder(Color.RED));
	}
	return panel3;
}
/**
 * 构造第四个面板
 * @return 返回一个JPanel对象
 */
private JPanel buildPanel4(){
	if(panel4 == null){
		panel4 = new JPanel();
		panel4.add(new JTextArea());
		panel4.setBorder(BorderFactory.createLineBorder(Color.YELLOW));
	}
	return panel4;
}
/**
 * 初始化各个Checkbox
 *
 */
private void buildCheckBox(){
	CB1 = new JCheckBox("借出时打印清单");
	CB2 = new JCheckBox("启用超期罚金");
	CB3 = new JCheckBox("启用租金功能");
	CB4 = new JCheckBox("启用借阅数量限制");
	CB5 = new JCheckBox("启用读者有效期");
	CB6 = new JCheckBox("其用读者租金");
	
}
private void buildRadioButton(){
	bookIdBtn = new JRadioButton("图书编号");
	readerIdBtn = new JRadioButton("读者编号");
}
/**
 * 初始化各个Textfield
 */
private void initJTextField(){
	libraryNameTxt = new JTextField(15);
	addressTxt = new JTextField(15);
	mailTxt = new JTextField(15);
	telTxt = new JTextField(15);
	faJinPerDayTxt = new JTextField(15);
	yajinBeiShuTxt = new JTextField(15);
	
}
/**
 * 初始化各个标签JLabel
 */
private void initJLabel(){
	libraryName= new JLabel("图书馆名:");
	address= new JLabel("书馆地址:");
	mail= new JLabel("书馆邮箱:");
	tel= new JLabel("联系电话:");
	sponsorMan= new JLabel("负责人:");
	faJinPerDay= new JLabel("超期每日罚金:");
	yajinBeiShu= new JLabel("押金倍数:");
	
}
/**
 * 构造负责人的ComboBox
 * @return  返回一个JComboBox对象
 */
private JComboBox buildSponsorManCombo(){
	if(sponsorManCombo==null){
		String[] s = {"陈兵","曾荣廷","虎兴龙","廖运球"};
		sponsorManCombo= new JComboBox(s);
	}
	return sponsorManCombo;
}
/**
*构建JButton按钮
*@return 返回一个JButton对象
*/

private JButton buildBtn(String name){
	JButton b = new JButton(name);
	return b;
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -