|
@ -11,6 +11,7 @@ import javax.swing.DefaultListModel; |
|
|
import javax.swing.ImageIcon; |
|
|
import javax.swing.ImageIcon; |
|
|
import javax.swing.JFileChooser; |
|
|
import javax.swing.JFileChooser; |
|
|
import javax.swing.JOptionPane; |
|
|
import javax.swing.JOptionPane; |
|
|
|
|
|
import javax.swing.JScrollPane; |
|
|
import javax.swing.JSplitPane; |
|
|
import javax.swing.JSplitPane; |
|
|
import javax.swing.JButton; |
|
|
import javax.swing.JButton; |
|
|
import javax.swing.JTextField; |
|
|
import javax.swing.JTextField; |
|
@ -47,7 +48,7 @@ public class FrmMain extends JFrame { |
|
|
private static final long serialVersionUID = 2634383304749703669L; |
|
|
private static final long serialVersionUID = 2634383304749703669L; |
|
|
private JPanel contentPane; |
|
|
private JPanel contentPane; |
|
|
private JTextField txtSearch; |
|
|
private JTextField txtSearch; |
|
|
public static JTextField txtEdTitle; |
|
|
|
|
|
|
|
|
public static JTextField txtEdTitle; |
|
|
public static JTextField txtTags; |
|
|
public static JTextField txtTags; |
|
|
private JButton btnSave; |
|
|
private JButton btnSave; |
|
|
private JButton btnCancel; |
|
|
private JButton btnCancel; |
|
@ -93,8 +94,6 @@ public class FrmMain extends JFrame { |
|
|
lblRecipeTitle.setVisible(false); |
|
|
lblRecipeTitle.setVisible(false); |
|
|
recipesList.setEnabled(false); |
|
|
recipesList.setEnabled(false); |
|
|
imgRecipe.setIcon(imgDefaultRecipe); |
|
|
imgRecipe.setIcon(imgDefaultRecipe); |
|
|
|
|
|
|
|
|
//czyszczenie pól formularza |
|
|
|
|
|
txtDescription.setText(""); |
|
|
txtDescription.setText(""); |
|
|
txtEdTitle.setText(""); |
|
|
txtEdTitle.setText(""); |
|
|
txtIngredients.setText(""); |
|
|
txtIngredients.setText(""); |
|
@ -287,14 +286,12 @@ public class FrmMain extends JFrame { |
|
|
|
|
|
|
|
|
btnLoadImg.addActionListener(new ActionListener() { |
|
|
btnLoadImg.addActionListener(new ActionListener() { |
|
|
public void actionPerformed(ActionEvent arg0) { |
|
|
public void actionPerformed(ActionEvent arg0) { |
|
|
//otwórz okno dialogowe |
|
|
|
|
|
int returnVal = fcImg.showOpenDialog(FrmMain.this); |
|
|
int returnVal = fcImg.showOpenDialog(FrmMain.this); |
|
|
if (returnVal == JFileChooser.APPROVE_OPTION) { |
|
|
if (returnVal == JFileChooser.APPROVE_OPTION) { |
|
|
File file = fcImg.getSelectedFile(); |
|
|
File file = fcImg.getSelectedFile(); |
|
|
try { |
|
|
try { |
|
|
BufferedImage srcImg = ImageIO.read(file); //czytaj plik |
|
|
|
|
|
|
|
|
BufferedImage srcImg = ImageIO.read(file); |
|
|
|
|
|
|
|
|
//wyznacz szerokość obrazka jako stosunek (przy maksymalizacji wysokości |
|
|
|
|
|
int w = (int)Math.ceil(srcImg.getWidth()/(double)srcImg.getHeight()*imgRecipe.getHeight()); |
|
|
int w = (int)Math.ceil(srcImg.getWidth()/(double)srcImg.getHeight()*imgRecipe.getHeight()); |
|
|
|
|
|
|
|
|
BufferedImage resizedImg = new BufferedImage(w, imgRecipe.getHeight(), BufferedImage.TYPE_INT_ARGB); |
|
|
BufferedImage resizedImg = new BufferedImage(w, imgRecipe.getHeight(), BufferedImage.TYPE_INT_ARGB); |
|
|