package org.leumasjaffe.recipe.view.summary; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JTextField; import javax.swing.JTextPane; import org.jdesktop.swingx.VerticalLayout; import org.leumasjaffe.recipe.model.Element; import org.leumasjaffe.recipe.view.ImagePanel; import lombok.AccessLevel; import lombok.experimental.FieldDefaults; @SuppressWarnings("serial") @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true) public class SummaryPanel extends JPanel { JPanel panelIngredients; public SummaryPanel() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[]{0, 0, 0}; gridBagLayout.rowHeights = new int[]{0, 0, 0, 0}; gridBagLayout.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE}; gridBagLayout.rowWeights = new double[]{1.0, 1.0, 1.0, Double.MIN_VALUE}; setLayout(gridBagLayout); JPanel panelHeader = new JPanel(); GridBagConstraints gbc_panelHeader = new GridBagConstraints(); gbc_panelHeader.gridwidth = 2; gbc_panelHeader.insets = new Insets(0, 0, 5, 0); gbc_panelHeader.fill = GridBagConstraints.BOTH; gbc_panelHeader.gridx = 0; gbc_panelHeader.gridy = 0; add(panelHeader, gbc_panelHeader); GridBagLayout gbl_panelHeader = new GridBagLayout(); gbl_panelHeader.columnWidths = new int[]{0, 0, 0}; gbl_panelHeader.rowHeights = new int[]{0, 0}; gbl_panelHeader.columnWeights = new double[]{1.0, 0.0, Double.MIN_VALUE}; gbl_panelHeader.rowWeights = new double[]{0.0, Double.MIN_VALUE}; panelHeader.setLayout(gbl_panelHeader); JTextField txtTitle = new JTextField(); txtTitle.setText("Title"); GridBagConstraints gbc_txtTitle = new GridBagConstraints(); gbc_txtTitle.insets = new Insets(0, 0, 0, 5); gbc_txtTitle.fill = GridBagConstraints.HORIZONTAL; gbc_txtTitle.gridx = 0; gbc_txtTitle.gridy = 0; panelHeader.add(txtTitle, gbc_txtTitle); txtTitle.setColumns(10); JLabel lblDuration = new JLabel("Duration"); GridBagConstraints gbc_lblDuration = new GridBagConstraints(); gbc_lblDuration.gridx = 1; gbc_lblDuration.gridy = 0; panelHeader.add(lblDuration, gbc_lblDuration); panelIngredients = new JPanel(); GridBagConstraints gbc_panelIngredients = new GridBagConstraints(); gbc_panelIngredients.gridheight = 2; gbc_panelIngredients.insets = new Insets(0, 0, 0, 5); gbc_panelIngredients.fill = GridBagConstraints.BOTH; gbc_panelIngredients.gridx = 0; gbc_panelIngredients.gridy = 1; add(panelIngredients, gbc_panelIngredients); panelIngredients.setLayout(new VerticalLayout()); JPanel panelPhoto = new ImagePanel(); GridBagConstraints gbc_panelPhoto = new GridBagConstraints(); gbc_panelPhoto.insets = new Insets(0, 0, 5, 0); gbc_panelPhoto.fill = GridBagConstraints.BOTH; gbc_panelPhoto.gridx = 1; gbc_panelPhoto.gridy = 1; add(panelPhoto, gbc_panelPhoto); JTextPane txtpnDescription = new JTextPane(); txtpnDescription.setPreferredSize(new Dimension(0, 100)); txtpnDescription.setText("Description"); GridBagConstraints gbc_txtpnDescription = new GridBagConstraints(); gbc_txtpnDescription.fill = GridBagConstraints.BOTH; gbc_txtpnDescription.gridx = 1; gbc_txtpnDescription.gridy = 2; add(txtpnDescription, gbc_txtpnDescription); } public void addProduct(final Element comp) { panelIngredients.add(new ElementSummaryPanel(comp)); panelIngredients.add(new JSeparator()); } }