| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -3,16 +3,24 @@ package ksiazka.kucharska; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.BorderLayout; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.imageio.ImageIO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.JFrame; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.JPanel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.border.EmptyBorder; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.ImageIcon; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.JFileChooser; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.JSplitPane; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.JButton; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.JTextField; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.Graphics2D; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.GridLayout; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.GridBagLayout; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.GridBagConstraints; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.Image; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.Insets; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.RenderingHints; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.JList; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.JTextPane; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.JLabel; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -21,6 +29,10 @@ import javax.swing.border.LineBorder; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.SystemColor; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.event.ActionListener; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.event.ActionEvent; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.awt.image.BufferedImage; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.File; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.IOException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.swing.SwingConstants; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					public class FrmMain extends JFrame { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -41,6 +53,9 @@ public class FrmMain extends JFrame { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private JButton btnDelRecipe; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private JButton btnLoadImg; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private JLabel lblRecipeTitle; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private JLabel imgRecipe; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private JFileChooser fcImg; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						private ImageIcon imgDefaultRecipe; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						void DeactivateAddMenu() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							btnCancel.setVisible(false); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -66,6 +81,12 @@ public class FrmMain extends JFrame { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							txtIngredients.setEditable(true); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							txtTags.setEditable(true); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							lblRecipeTitle.setVisible(false); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//czyszczenie pól formularza | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							txtDescription.setText(""); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							txtEdTitle.setText(""); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							txtIngredients.setText(""); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							txtTags.setText(""); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						/** | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -84,7 +105,7 @@ public class FrmMain extends JFrame { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							JSplitPane splitPane = new JSplitPane(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							splitPane.setDividerSize(5); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							splitPane.setEnabled(false); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							splitPane.setResizeWeight(0.2); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							splitPane.setResizeWeight(0.1); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							contentPane.add(splitPane, BorderLayout.CENTER); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							JPanel panel = new JPanel(); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -139,6 +160,7 @@ public class FrmMain extends JFrame { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							btnAddRecipe.addActionListener(new ActionListener() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								public void actionPerformed(ActionEvent e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									ActivateAddMenu(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							panel_1.add(btnAddRecipe); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -153,6 +175,9 @@ public class FrmMain extends JFrame { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							btnSave = new JButton("Zapisz"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							btnSave.addActionListener(new ActionListener() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								public void actionPerformed(ActionEvent e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									System.out.println("sprawdzam ikonę..."); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									if (imgRecipe.getIcon() == imgDefaultRecipe.getImage()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										System.out.println("Ta sama ikona"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									DeactivateAddMenu(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							}); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -189,12 +214,49 @@ public class FrmMain extends JFrame { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							lblDescription.setBounds(26, 227, 152, 15); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							panel_2.add(lblDescription); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							JLabel imgRecipe = new JLabel(""); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							imgRecipe = new JLabel(""); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							imgRecipe.setHorizontalAlignment(SwingConstants.CENTER); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							imgRecipe.setBorder(new LineBorder(SystemColor.textHighlightText)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							imgRecipe.setBounds(272, 88, 164, 126); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							panel_2.add(imgRecipe); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							btnLoadImg = new JButton("Wczytaj"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							fcImg = new JFileChooser(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							imgDefaultRecipe = new ImageIcon("no_img_recipe.jpg"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							imgRecipe.setIcon(imgDefaultRecipe); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							btnLoadImg.addActionListener(new ActionListener() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								public void actionPerformed(ActionEvent arg0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									int returnVal = fcImg.showOpenDialog(FrmMain.this); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								        if (returnVal == JFileChooser.APPROVE_OPTION) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								        	File file = fcImg.getSelectedFile(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								        	try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 BufferedImage srcImg = ImageIO.read(file); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 int w = (int)Math.ceil(srcImg.getWidth()/(double)srcImg.getHeight()*imgRecipe.getHeight()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												  | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 System.out.println(w); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 BufferedImage resizedImg = new BufferedImage(w, imgRecipe.getHeight(), BufferedImage.TYPE_INT_ARGB); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 Graphics2D g2 = resizedImg.createGraphics(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												    g2.drawImage(srcImg, 0, 0, w, imgRecipe.getHeight(), null); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												    g2.dispose(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												    | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												ImageIcon iconLogo = new ImageIcon(resizedImg); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									            imgRecipe.setIcon(iconLogo); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											} catch (IOException e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												// TODO Auto-generated catch block | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												e.printStackTrace(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								             | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								             | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							btnLoadImg.setVisible(false); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							btnLoadImg.setBounds(304, 217, 102, 25); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							panel_2.add(btnLoadImg); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
 |