source: src/main/java/bargainingchips/etc/GUI.java@ 343

Last change on this file since 343 was 316, checked in by Tim Baarslag, 5 years ago

new packages complete

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