From 7eb7a61bc957d712a3f086c63c5b5464b34d7bd6 Mon Sep 17 00:00:00 2001 From: PioDer Date: Wed, 11 Jun 2014 23:25:05 +0100 Subject: [PATCH] druga formatka - dodawanie przepisu - gotowa --- src/main/java/ksiazka/kucharska/App.java | 7 +- src/main/java/ksiazka/kucharska/FrmAdd.java | 103 +++++++++++++++++++ src/main/java/ksiazka/kucharska/FrmMain.java | 50 +++++---- 3 files changed, 135 insertions(+), 25 deletions(-) create mode 100644 src/main/java/ksiazka/kucharska/FrmAdd.java diff --git a/src/main/java/ksiazka/kucharska/App.java b/src/main/java/ksiazka/kucharska/App.java index 249f7b2..e032968 100644 --- a/src/main/java/ksiazka/kucharska/App.java +++ b/src/main/java/ksiazka/kucharska/App.java @@ -10,13 +10,14 @@ public class App { public static void main( String[] args ) { - System.out.println( "Hello World!" ); - System.out.println( "test repo!" ); - System.out.println("\rPioDer test2\n"); + System.out.println( "Książka Kucharska v1.0" ); EventQueue.invokeLater(new Runnable() { public void run() { try { + System.out.println( "tworzę fMain..." ); FrmMain fMain = new FrmMain(); + System.out.println("tworzę fAdd..."); + FrmAdd fAdd = new FrmAdd(); fMain.setVisible(true); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/ksiazka/kucharska/FrmAdd.java b/src/main/java/ksiazka/kucharska/FrmAdd.java new file mode 100644 index 0000000..6cfdbd6 --- /dev/null +++ b/src/main/java/ksiazka/kucharska/FrmAdd.java @@ -0,0 +1,103 @@ +package ksiazka.kucharska; + +import java.awt.BorderLayout; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import javax.swing.JLabel; +import javax.swing.JTextPane; +import javax.swing.border.LineBorder; +import java.awt.SystemColor; +import javax.swing.JTextField; +import javax.swing.JButton; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +public class FrmAdd extends JFrame { + + /** + * + */ + private static final long serialVersionUID = -9040508421093717296L; + private JPanel contentPane; + private JTextField txtTitle; + private JTextField txtTags; + + + /** + * Create the frame. + */ + public FrmAdd() { + setResizable(false); + setTitle("Dodaj przepis"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(100, 100, 576, 526); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + + JLabel lblTitle = new JLabel("Nazwa przepisu:"); + lblTitle.setBounds(22, 12, 119, 19); + contentPane.add(lblTitle); + + JLabel lblIngredients = new JLabel("Składniki (jeden na linię):"); + lblIngredients.setBounds(22, 44, 186, 19); + contentPane.add(lblIngredients); + + JLabel lblDescription = new JLabel("Opis przygotowania:"); + lblDescription.setBounds(22, 208, 158, 15); + contentPane.add(lblDescription); + + JLabel lblOptionalImg = new JLabel("Opcjonalna grafika:"); + lblOptionalImg.setBounds(397, 62, 149, 23); + contentPane.add(lblOptionalImg); + + JLabel lblTags = new JLabel("Tagi (oddziel spacją):"); + lblTags.setBounds(22, 443, 158, 15); + contentPane.add(lblTags); + + JTextPane txtIngredients = new JTextPane(); + txtIngredients.setEditable(false); + txtIngredients.setBounds(22, 70, 324, 126); + contentPane.add(txtIngredients); + + JLabel imgRecipe = new JLabel(""); + imgRecipe.setBorder(new LineBorder(SystemColor.textHighlightText)); + imgRecipe.setBounds(382, 97, 164, 126); + contentPane.add(imgRecipe); + + JTextPane txtDescription = new JTextPane(); + txtDescription.setEditable(false); + txtDescription.setBounds(22, 235, 324, 196); + contentPane.add(txtDescription); + + txtTitle = new JTextField(); + txtTitle.setBounds(159, 12, 187, 19); + contentPane.add(txtTitle); + txtTitle.setColumns(10); + + txtTags = new JTextField(); + txtTags.setColumns(10); + txtTags.setBounds(22, 465, 324, 19); + contentPane.add(txtTags); + + JButton btnLoad = new JButton("Wczytaj"); + btnLoad.setBounds(417, 247, 102, 25); + contentPane.add(btnLoad); + + JButton btnSave = new JButton("Zapisz"); + btnSave.setBounds(417, 406, 102, 25); + contentPane.add(btnSave); + + JButton btnCancel = new JButton("Anuluj"); + btnCancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + btnCancel.setBounds(417, 438, 102, 25); + contentPane.add(btnCancel); + } +} diff --git a/src/main/java/ksiazka/kucharska/FrmMain.java b/src/main/java/ksiazka/kucharska/FrmMain.java index eac660a..c92cb33 100644 --- a/src/main/java/ksiazka/kucharska/FrmMain.java +++ b/src/main/java/ksiazka/kucharska/FrmMain.java @@ -19,6 +19,8 @@ import javax.swing.JLabel; import java.awt.Font; import javax.swing.border.LineBorder; import java.awt.SystemColor; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; public class FrmMain extends JFrame { @@ -27,7 +29,7 @@ public class FrmMain extends JFrame { */ private static final long serialVersionUID = 2634383304749703669L; private JPanel contentPane; - private JTextField txtWpiszTytutagi; + private JTextField txtSearch; /** * Create the frame. @@ -57,15 +59,15 @@ public class FrmMain extends JFrame { gbl_panel.rowWeights = new double[]{0.0, 1.0, 0.0}; panel.setLayout(gbl_panel); - txtWpiszTytutagi = new JTextField(); - txtWpiszTytutagi.setText("wpisz tytuł/tagi..."); - GridBagConstraints gbc_txtWpiszTytutagi = new GridBagConstraints(); - gbc_txtWpiszTytutagi.insets = new Insets(0, 0, 5, 5); - gbc_txtWpiszTytutagi.fill = GridBagConstraints.HORIZONTAL; - gbc_txtWpiszTytutagi.gridx = 0; - gbc_txtWpiszTytutagi.gridy = 0; - panel.add(txtWpiszTytutagi, gbc_txtWpiszTytutagi); - txtWpiszTytutagi.setColumns(10); + txtSearch = new JTextField(); + txtSearch.setText("wpisz tytuł/tagi..."); + GridBagConstraints gbc_txtSearch = new GridBagConstraints(); + gbc_txtSearch.insets = new Insets(0, 0, 5, 5); + gbc_txtSearch.fill = GridBagConstraints.HORIZONTAL; + gbc_txtSearch.gridx = 0; + gbc_txtSearch.gridy = 0; + panel.add(txtSearch, gbc_txtSearch); + txtSearch.setColumns(10); JButton btnSearch = new JButton("Szukaj"); GridBagConstraints gbc_btnSearch = new GridBagConstraints(); @@ -97,6 +99,10 @@ public class FrmMain extends JFrame { panel_1.setLayout(new GridLayout(0, 2, 0, 0)); JButton btnAddRecipe = new JButton("Dodaj"); + btnAddRecipe.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + } + }); panel_1.add(btnAddRecipe); JButton btnDelRecipe = new JButton("Usuń"); @@ -106,15 +112,15 @@ public class FrmMain extends JFrame { splitPane.setRightComponent(panel_2); panel_2.setLayout(null); - JTextPane textPane = new JTextPane(); - textPane.setEditable(false); - textPane.setBounds(26, 88, 228, 126); - panel_2.add(textPane); + JTextPane txtIngredients = new JTextPane(); + txtIngredients.setEditable(false); + txtIngredients.setBounds(26, 88, 228, 126); + panel_2.add(txtIngredients); - JTextPane textPane_1 = new JTextPane(); - textPane_1.setEditable(false); - textPane_1.setBounds(26, 254, 410, 196); - panel_2.add(textPane_1); + JTextPane txtDescription = new JTextPane(); + txtDescription.setEditable(false); + txtDescription.setBounds(26, 254, 410, 196); + panel_2.add(txtDescription); JLabel lblRecipeTitle = new JLabel("Nazwa przepisu"); lblRecipeTitle.setFont(new Font("Dialog", Font.BOLD, 18)); @@ -129,9 +135,9 @@ public class FrmMain extends JFrame { lblDescription.setBounds(26, 227, 152, 15); panel_2.add(lblDescription); - JLabel lblNewLabel_3 = new JLabel(""); - lblNewLabel_3.setBorder(new LineBorder(SystemColor.textHighlightText)); - lblNewLabel_3.setBounds(272, 88, 164, 126); - panel_2.add(lblNewLabel_3); + JLabel imgRecipe = new JLabel(""); + imgRecipe.setBorder(new LineBorder(SystemColor.textHighlightText)); + imgRecipe.setBounds(272, 88, 164, 126); + panel_2.add(imgRecipe); } }