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

📄 addclothespanel.java

📁 一个优秀的干洗店管理系统
💻 JAVA
字号:
package view.panel.getClothes;

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

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import view.common.GBC;

public class AddClothesPanel extends JPanel{
	private JLabel clothesNameLb,serviceTypeLb,priceLb,discountLb;
	private JTextField quantityTxFld,totalPriceTxFld;
	
	private JComboBox colorCmbBox,accesoriesCmbBox,brandCmbBox,flawCmbBox;
	private JTextArea additionTxArea;
	private JButton okBtn,cancelBtn;
	
	public AddClothesPanel(){
		this.setLayout(new BorderLayout());
		
		JPanel panelOne = new JPanel();
		panelOne.setLayout(new GridLayout(2,1));
		panelOne.add(buildSquarePanel());
		panelOne.add(buildClthsAdditionalInfoPanel());
		
		JPanel panelTwo = new JPanel();
		panelTwo.setLayout(new FlowLayout());
		panelTwo.add(buildBtnPanel());
		
		this.add(panelOne);
		this.add(panelTwo,BorderLayout.SOUTH);
	}
	
	public JPanel buildSquarePanel(){
		JPanel bottomPanel = new JPanel();
		bottomPanel.setLayout(new BorderLayout());
		
		//构造统计已选的衣服面板,用于结账
		JPanel panel = new JPanel();		
		panel.setLayout(new GridBagLayout());
		
		panel.add(buildLabel("衣服名称"),new GBC(0,0).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildClothesNameLb(),new GBC(1,0).setFill(GBC.HORIZONTAL).setWeight(100, 100).setInset(10));
		panel.add(buildLabel("服务类型"),new GBC(2,0).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildServiceTypeLb(),new GBC(3,0).setFill(GBC.HORIZONTAL).setWeight(100, 100).setInset(10));
		panel.add(buildLabel("原价"),new GBC(0,1).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildPriceLb(),new GBC(1,1).setFill(GBC.HORIZONTAL).setWeight(100, 100).setInset(10));
		panel.add(buildLabel("折扣"),new GBC(2,1).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildDiscountLb(),new GBC(3,1).setFill(GBC.HORIZONTAL).setWeight(100, 100).setInset(10));
		panel.add(buildLabel("数量"),new GBC(0,2).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildQuantityTxFld(),new GBC(1,2).setFill(GBC.HORIZONTAL).setWeight(100, 100).setInset(10));
		panel.add(buildLabel("合计(¥)"),new GBC(2,2).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildTotalPriceTxFld(),new GBC(3,2).setFill(GBC.HORIZONTAL).setWeight(100, 100).setInset(10));
		//用于构造一个提示信息,提示用户最后折扣怎么确定
		String tip = "提示:如果该衣服的最低折扣大于会员卡折扣,该衣服须按照该衣服允许的最低折扣进行打折,如果最低折扣为0," +
		"则表示按照会员卡折扣打折";
		JLabel tipLabel = buildLabel(tip);
		tipLabel.setForeground(Color.RED);
		
		bottomPanel.add(panel);
		bottomPanel.add(tipLabel,BorderLayout.SOUTH);
		bottomPanel.setBorder(BorderFactory.createTitledBorder("洗衣信息"));
		return bottomPanel;
	}
	
	public JLabel buildLabel(String content){
		return new JLabel(content);
	}
	
	public JLabel buildClothesNameLb(){
		if(clothesNameLb == null){
			clothesNameLb = new JLabel();
		}
		return clothesNameLb;
	}
	
	public JLabel buildServiceTypeLb(){
		if(serviceTypeLb == null){
			serviceTypeLb = new JLabel();
		}
		return serviceTypeLb;
	}
	
	public JLabel buildPriceLb(){
		if(priceLb == null){
			priceLb = new JLabel();
		}
		return priceLb;
	}
	
	public JLabel buildDiscountLb(){
		if(discountLb == null){
			discountLb = new JLabel();
		}
		return discountLb;
	}
	
	public JTextField buildQuantityTxFld(){
		if(quantityTxFld == null){
			quantityTxFld = new JTextField();
		}
		return quantityTxFld;
	}
	
	public JTextField buildTotalPriceTxFld(){
		if(totalPriceTxFld == null){
			totalPriceTxFld = new JTextField();
			totalPriceTxFld.setEditable(false);
		}
		return totalPriceTxFld;
	}
	
	public JPanel buildClthsAdditionalInfoPanel(){
		JPanel panel = new JPanel();
		panel.setLayout(new GridBagLayout());
		
		panel.add(buildLabel("颜色"),new GBC(0,0,1,1).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildColorCmbBox(),new GBC(1,0,3,1).setFill(GBC.BOTH).setWeight(100, 100).setInset(10));
		panel.add(buildLabel("附件"),new GBC(4,0,1,1).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildAccesoriesCmbBox(),new GBC(5,0,3,1).setFill(GBC.BOTH).setWeight(100, 100).setInset(10));
		panel.add(buildLabel("品牌"),new GBC(0,1,1,1).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildBrandCmbBox(),new GBC(1,1,3,1).setFill(GBC.BOTH).setWeight(100, 100).setInset(10));
		panel.add(buildLabel("瑕疵"),new GBC(4,1,1,1).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildFlawCmbBox(),new GBC(5,1,3,1).setFill(GBC.BOTH).setWeight(100, 100).setInset(10));
		panel.add(buildLabel("备注"),new GBC(0,2,1,1).setFill(GBC.WEST).setWeight(100, 100).setInset(10));
		panel.add(buildAdditionTxArea(),new GBC(1,2,8,2).setFill(GBC.BOTH).setWeight(100, 100).setInset(10));
		
		panel.setBorder(BorderFactory.createTitledBorder("衣服附加信息"));
		return panel;
	}
	
	public JComboBox buildColorCmbBox(){
		if(colorCmbBox == null){
			colorCmbBox = new JComboBox();
		}
		return colorCmbBox;
	}
	
	public JComboBox buildAccesoriesCmbBox(){
		if(accesoriesCmbBox == null){
			accesoriesCmbBox = new JComboBox();
		}
		return accesoriesCmbBox;
	}
	
	public JComboBox buildFlawCmbBox(){
		if(flawCmbBox == null){
			flawCmbBox = new JComboBox();
		}
		return flawCmbBox;
	}
	
	public JComboBox buildBrandCmbBox(){
		if(brandCmbBox == null){
			brandCmbBox = new JComboBox();
		}
		return brandCmbBox;
	}
	
	public JTextArea buildAdditionTxArea(){
		if(additionTxArea == null){
			additionTxArea = new JTextArea();
			additionTxArea.setEditable(true);
			additionTxArea.setLineWrap(true);
		}
		return additionTxArea;
	}
	
	public JPanel buildBtnPanel(){
		JPanel panel = new JPanel();
		panel.setLayout(new FlowLayout());
		panel.add(buildOkBtn());
		panel.add(buildCancelBtn());
		return panel;
	}
	
	public JButton buildOkBtn() {
		if (okBtn == null) {
			okBtn = new JButton("确定");
		}
		return okBtn;
	}

	public JButton buildCancelBtn() {
		if (cancelBtn == null) {
			cancelBtn = new JButton("取消");
		}
		return cancelBtn;
	}
}

⌨️ 快捷键说明

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