source: src/main/java/onetomany/etc/GUI.java@ 265

Last change on this file since 265 was 263, checked in by Faria Nassiri Mofakham, 5 years ago

Offer class updated; Message enum created; parapoloid tried in GUI; some small changes in some previous classes (Bundle, stack,.. ); UF_Silly renamed to UF_Crazy; started to add role to UF classes...

File size: 5.6 KB
RevLine 
[253]1package onetomany.etc;
[257]2
3import java.awt.Canvas;
4import java.awt.Color;
5import java.awt.Dimension;
6import java.awt.Font;
7import java.awt.Toolkit;
8import java.awt.image.BufferedImage;
9
10import javax.swing.BorderFactory;
11import javax.swing.JButton;
12import javax.swing.JFrame;
13import javax.swing.JLabel;
14import javax.swing.JPanel;
15
[263]16import onetomany.Paraboloid;
[257]17import onetomany.etc.CloseButtonListener;
18import net.miginfocom.swing.MigLayout;
19
20/**
21 * @author Faria Nassiri-Mofakham
22 *
23 */
24public class GUI extends JFrame
25{
26 Main main;
27 private static final long serialVersionUID = -5602032021645365870L;
28
29
30 public GUI(Main m) //throws MalformedURLException, IOException
31 {
32 super("Bob gets ready for negotiation ...");
33 main = m;
34
35
36 // Show the GUI
37 setLayout(new MigLayout("", "", ""));
38
39 // Could not `resize' and show small CWI-ACUMEX QR-code
40// Canvas canvas00 = new PutImage("C:\\Users\\fnm\\Pictures\\qr_code.png");
41// canvas00.setBounds(0,0,50,50);
42// canvas00.setSize(50, 50);
43// add(canvas00);
44
45
46
47
48 // how to change to url address of Bob ? "./NegotiatorGUI/src/main/java/negotiator/onetomany/etc/Bob.png"
49 Canvas canvas0 = new DrawImage("C:\\Users\\fnm\\Pictures\\Bob.png");
50// Canvas canvas0 = new Bob("NegotiatorGUI.src.main.java.negotiator.onetomany.etc.Bob.png");
51 canvas0.setSize(400, 200);
52 add(canvas0, "cell 0 0, span 1 4, growx, center"); //cannot make it center
53
54 //defining a font
55 Font f1 = new Font("TimesRoman",Font.BOLD,20);
56 Font f2 = new Font("TimesRoman",Font.ITALIC,20);
57 Font f3 = new Font("TimesRoman",Font.PLAIN,16);
58
59
60// JLabel l1 = new JLabel("The `Agent' receives Bob's PORTFOLIO containing "+m.getPortfolio().size()+" different products as follows:");
61 JLabel l1 = new JLabel("Bob's PORTFOLIO contains "+m.getPortfolio().size()+" different products as follows:");
62 l1.setFont(f1);
63
64 add(l1, "cell 1 1, center, width 100:550:1000, wrap"); // no notice to min and max constraints for column width, just the preferred (the middle number)
65
66
67 JPanel panel1 = new JPanel();
68 panel1.setForeground(Color.WHITE);
69 panel1.setFont(f3);
70
71 panel1.setBorder(BorderFactory.createTitledBorder("Portfolio"));
72 panel1.setBackground(Color.decode("#5C8585"));
73 Canvas canvas1 = new PortfolioDrawing(m.getPortfolio());
74 canvas1.setBackground(Color.decode("#5C8585"));
75 canvas1.setSize(550, 200);
76 panel1.add(canvas1);
77 add(panel1, "cell 1 2, growx, center, wrap");
78
79
80
[226]81// Canvas canvas1 = new PortfolioDrawing(m.getPortfolio());
82// canvas1.setBackground(Color.decode("#5C8585"));
[257]83// canvas1.setSize(200, 200);
84// add(canvas1, "cell 1 2, growx, center, wrap");
85
86 add(new JLabel(" "), "center, wrap");
87
88
89
90
91 //a line
92 int w = (canvas0.getWidth()+canvas1.getWidth())*3; // doesn't calculate dynamically well!
93
[263]94
[257]95
96 Canvas canvas2 = new Line(Color.BLACK,w);
97 canvas2.setSize(1, 1);
98 add(canvas2, "span 2 0, growx, center, wrap");
99
100 add(new JLabel(" "), "center, wrap");
101
102
103// JLabel l2 = new JLabel("It also receives Bob's DEMAND PLAN as follows:");
104 JLabel l2 = new JLabel("And his DEMAND has been planed as the following quantities:");
105 l2.setFont(f1);
106
107 add(l2, "span 2 0, center, wrap");
108
109
110
111
112 add(new JLabel(" "), "center, wrap");
113
114 JLabel n = new JLabel(m.getDemandPlan().toString());
115 n.setFont(f2);
116 add(n, "span 2 0, center, wrap");
117
118
119 JPanel panel2 = new JPanel();
120 //panel2.setFont(f1);
121 panel2.setBackground(Color.WHITE);
122 panel2.setBorder(BorderFactory.createTitledBorder("Demand Plan"));
123
124
125 //Canvas canvas3 = new DemandPlan(m.getDemandPlan());
126 //canvas3.setBackground(Color.WHITE);
127 //canvas3.setSize(800, 300);
128
129
130 //panel2.add(canvas3);
131 //add(panel2, "span 2 0, growx, growy, center, wrap");
132
133
134
135// Canvas canvas3 = new DemandPlanDrawing(m.getDemandPlan());
[226]136// canvas3.setBackground(Color.WHITE);
[257]137// canvas3.setSize(200, 400);
138// add(canvas3, "span 2 0, growx, growy, center, wrap");
139
140
141
142
143
144 add(new JLabel(" "), "span 2 0, center, wrap");
145
146 //a line
147// Canvas canvas4 = new Line(Color.BLACK,w);
148// canvas4.setSize(1, 1);
149// add(canvas4, "span 2 0, growx, center, wrap");
150
151 add(new JLabel(" "), "span 2 0, center, wrap");
152
[263]153
154
155
156
157 Canvas canvas222 = new Paraboloid(Color.BLACK,w, 0.4, 0.4, 0.4);
158 canvas222.setSize(800, 800);
159 add(canvas222, "span 2 0, growx, center, wrap");
160
161
162
[257]163 //buttons
164
165 JButton a = new JButton("Edit...");
166 add(a, "cell 0 12, span 2 0, center, w 90");
167 // at dynamic position ? for the height ?! by canvases heights, or counting the rows and columns?
168 JButton b = new JButton("Delete...");
169 add(b, "cell 0 12, span 2 0, center, w 90");
170
171 add(new JButton("Next..."), "cell 0 12, span 2 0, center, w 90");
172
173 JButton d = new JButton("Close");
174 d.addActionListener(new CloseButtonListener(this)); // <-- only this was added to this from examples closeButtonListenner and ClosableWindow
175 add(d, "cell 0 12, span 2 0, center, wrap, w 90");
176
177
178 //setting the background as the Bob's image
179 getContentPane().setBackground(Color.decode("#AFD6D6"));
[263]180
[257]181 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
182 pack();
183
184 setLocationRelativeTo(null);
185// Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
186// setBounds(0,0,screenSize.width, screenSize.height);
187
188 setVisible(true);
189 }
190
191 /**
192 * @param args
193 */
194 public static void main(String[] args)
195 {
196 Main main = new Main();
197 GUI gui = new GUI(main);
198
199 }
200
201}
202
203
Note: See TracBrowser for help on using the repository browser.