/Users/e1818782/NetBeansProjects/IA Stuff/RecipeDatabase_Nicolas/src/nicolas/DetailsGUI.java |
1
2
3
4
5
6 package nicolas;
7
8 import java.util.ArrayList;
9 import javax.swing.JOptionPane;
10
11
12
13 @author
14
15 public class DetailsGUI extends javax.swing.JFrame {
16
17
18
19
20 public DetailsGUI() {
21 initComponents();
22 }
23 public DetailsGUI(String method, String ingredients, double calories, double cost, String name, double servings, ArrayList<Recipe> recipeList )
24 {
25 myInit(method,ingredients,calories,cost,name,servings);
26 initComponents();
27 }
28 public void myInit(String method, String ingredients, double calories, double cost, String name, double servings)
29 {
30 caloriesLabel.setText("Calories: "+calories);
31 costLabel.setText("Cost: "+cost);
32 nameLabel.setText(name);
33 servingsLabel.setText("Servings: "+servings);
34 ingredientsArea.setText(""+ingredients);
35 methodsArea.setText(""+method);
36
37 }
38 public void setMethod(String method)
39 {
40 methodsArea.setText(""+method);
41 }
42 public void setIngredients(String ingredients)
43 {
44 ingredientsArea.setText(ingredients);
45 }
46 public void setCalories (double calories)
47 {
48 caloriesLabel.setText("Calories: "+calories);
49
50 }
51 public void setCost(double cost)
52 {
53 costLabel.setText("Cost: "+cost);
54 }
55 public void setName(String name)
56 {
57 nameLabel.setText(name);
58 }
59 public void setServings(double servings)
60 {
61 servingsLabel.setText("Servings: "+servings);
62 }
63
64
65 This method is called from within the constructor to initialize the form.
66
67
68
69 @SuppressWarnings("unchecked")
70 // <editor-fold defaultstate="collapsed" desc="Generated Code">
71 private void initComponents() {
72
73 costLabel = new javax.swing.JLabel();
74 caloriesLabel = new javax.swing.JLabel();
75 servingsLabel = new javax.swing.JLabel();
76 nameLabel = new javax.swing.JLabel();
77 jScrollPane1 = new javax.swing.JScrollPane();
78 methodsArea = new javax.swing.JTextArea();
79 jScrollPane2 = new javax.swing.JScrollPane();
80 ingredientsArea = new javax.swing.JTextArea();
81 jLabel1 = new javax.swing.JLabel();
82 jLabel2 = new javax.swing.JLabel();
83 closeBut = new javax.swing.JButton();
84
85 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
86
87 costLabel.setText("jLabel1");
88
89 caloriesLabel.setText("jLabel1");
90
91 servingsLabel.setText("jLabel1");
92
93 nameLabel.setText("jLabel1");
94 nameLabel.addMouseListener(new java.awt.event.MouseAdapter() {
95 public void mouseClicked(java.awt.event.MouseEvent evt) {
96 nameLabelMouseClicked(evt);
97 }
98 });
99
100 methodsArea.setColumns(20);
101 methodsArea.setRows(5);
102 jScrollPane1.setViewportView(methodsArea);
103
104 ingredientsArea.setColumns(20);
105 ingredientsArea.setRows(5);
106 jScrollPane2.setViewportView(ingredientsArea);
107
108 jLabel1.setText("Ingredients");
109
110 jLabel2.setText("Method");
111
112 closeBut.setText("Close");
113 closeBut.addActionListener(new java.awt.event.ActionListener() {
114 public void actionPerformed(java.awt.event.ActionEvent evt) {
115 closeButActionPerformed(evt);
116 }
117 });
118
119 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
120 getContentPane().setLayout(layout);
121 layout.setHorizontalGroup(
122 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
123 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
124 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
125 .addGroup(layout.createSequentialGroup()
126 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
127 .addComponent(closeBut))
128 .addGroup(layout.createSequentialGroup()
129 .addGap(16, 16, 16)
130 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
131 .addGroup(layout.createSequentialGroup()
132 .addComponent(jLabel1)
133 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
134 .addComponent(jLabel2))
135 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
136 .addComponent(costLabel)
137 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
138 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
139 .addComponent(caloriesLabel, javax.swing.GroupLayout.Alignment.TRAILING)
140 .addComponent(nameLabel, javax.swing.GroupLayout.Alignment.TRAILING))
141 .addGap(181, 181, 181)
142 .addComponent(servingsLabel))
143 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
144 .addComponent(jScrollPane2)
145 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
146 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
147 .addGap(24, 24, 24))
148 );
149 layout.setVerticalGroup(
150 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
151 .addGroup(layout.createSequentialGroup()
152 .addGap(17, 17, 17)
153 .addComponent(nameLabel)
154 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
155 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
156 .addComponent(servingsLabel)
157 .addComponent(caloriesLabel)
158 .addComponent(costLabel))
159 .addGap(18, 18, 18)
160 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
161 .addComponent(jLabel1)
162 .addComponent(jLabel2))
163 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
164 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
165 .addComponent(jScrollPane1)
166 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE))
167 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
168 .addComponent(closeBut))
169 );
170
171 pack();
172 }// </editor-fold>
173
174 private void nameLabelMouseClicked(java.awt.event.MouseEvent evt) {
175 JOptionPane.showInputDialog(nameLabel.getText());
176
177 }
178
179 private void closeButActionPerformed(java.awt.event.ActionEvent evt) {
180 setVisible(false);
181
182 }
183
184
185 @param args
186
187 public static void main(String args[]) {
188
189
190
191
192
193 try {
194 for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
195 if ("Nimbus".equals(info.getName())) {
196 javax.swing.UIManager.setLookAndFeel(info.getClassName());
197 break;
198 }
199 }
200 } catch (ClassNotFoundException ex) {
201 java.util.logging.Logger.getLogger(DetailsGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
202 } catch (InstantiationException ex) {
203 java.util.logging.Logger.getLogger(DetailsGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
204 } catch (IllegalAccessException ex) {
205 java.util.logging.Logger.getLogger(DetailsGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
206 } catch (javax.swing.UnsupportedLookAndFeelException ex) {
207 java.util.logging.Logger.getLogger(DetailsGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
208 }
209
210
211
212 java.awt.EventQueue.invokeLater(new Runnable() {
213 public void run() {
214 new DetailsGUI().setVisible(true);
215 }
216 });
217 }
218
219 // Variables declaration - do not modify
220 private javax.swing.JLabel caloriesLabel;
221 private javax.swing.JButton closeBut;
222 private javax.swing.JLabel costLabel;
223 private javax.swing.JTextArea ingredientsArea;
224 private javax.swing.JLabel jLabel1;
225 private javax.swing.JLabel jLabel2;
226 private javax.swing.JScrollPane jScrollPane1;
227 private javax.swing.JScrollPane jScrollPane2;
228 private javax.swing.JTextArea methodsArea;
229 private javax.swing.JLabel nameLabel;
230 private javax.swing.JLabel servingsLabel;
231 // End of variables declaration
232 }
233