public class RecordPanel extends JPanel{
static{
GUIUtil.useLNF();//应用流体皮肤
}
public static RecordPanel instance = new RecordPanel();//单例
JLabel lSpend = new JLabel("花费(¥)");
JLabel lCategory = new JLabel("分类");
JLabel lComment = new JLabel("备注");
JLabel lDate = new JLabel("日期");
public JTextField tfSpend = new JTextField("0");
public CategoryComboBoxModel cbModel = new CategoryComboBoxModel();//分类按钮实例类
public JComboBox<String> cbCategory = new JComboBox<>(cbModel);
public JTextField tfComment = new JTextField();
public JXDatePicker datepick = new JXDatePicker(new Date());//日期控件
JButton bSubmit = new JButton("记一笔");
public RecordPanel() {
GUIUtil.setColor(ColorUtil.grayColor, lSpend,lCategory,lComment,lDate);
GUIUtil.setColor(ColorUtil.blueColor, bSubmit);
JPanel pInput =new JPanel();
JPanel pSubmit = new JPanel();
int gap = 40;
pInput.setLayout(new GridLayout(4,2,gap,gap));//四行两列
pInput.add(lSpend);
pInput.add(tfSpend);
pInput.add(lCategory);
pInput.add(cbCategory);
pInput.add(lComment);
pInput.add(tfComment);
pInput.add(lDate);
pInput.add(datepick);
pSubmit.add(bSubmit);
this.setLayout(new BorderLayout());
this.add(pInput,BorderLayout.NORTH);//上面板
this.add(pSubmit,BorderLayout.CENTER);//中面板
}
public static void main(String[] args) {
GUIUtil.showPanel(RecordPanel.instance);
}
}