| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package org.leumasjaffe.recipe.view;
- import java.io.File;
- import java.io.IOException;
- import javax.swing.JFrame;
- import javax.swing.JTabbedPane;
- import org.leumasjaffe.recipe.model.Product;
- import org.leumasjaffe.recipe.model.Recipe;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
- @SuppressWarnings("serial")
- public class RecipeFrame extends JFrame {
- public RecipeFrame() {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
- JTabbedPane tabbedPane = new JTabbedPane();
- setContentPane(tabbedPane);
- SummaryPanel summaryPanel = new SummaryPanel();
- tabbedPane.addTab("Summary", summaryPanel);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.registerModule(new Jdk8Module());
- try {
- Recipe recipe = mapper.readValue(new File("src/test/resources/example.json"), Recipe.class);
- for (Product comp : recipe.getProducts()) {
- tabbedPane.addTab(comp.getName(), new ProductPanel(comp));
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- pack();
- repaint();
- setVisible(true);
- }
- }
|