1 | package negotiator.onetomany;
|
---|
2 |
|
---|
3 | import java.awt.BorderLayout;
|
---|
4 | import java.awt.Canvas;
|
---|
5 | import java.awt.Color;
|
---|
6 | import java.awt.Dimension;
|
---|
7 | import java.awt.Font;
|
---|
8 | import java.awt.Image;
|
---|
9 | import java.awt.Toolkit;
|
---|
10 |
|
---|
11 | import javax.swing.JButton;
|
---|
12 | import javax.swing.JComponent;
|
---|
13 | import javax.swing.JFrame;
|
---|
14 | import javax.swing.JLabel;
|
---|
15 | import javax.swing.JPanel;
|
---|
16 |
|
---|
17 | import negotiator.onetomany.etc.Bob;
|
---|
18 | import negotiator.onetomany.etc.Drawing1;
|
---|
19 | import negotiator.onetomany.etc.Line;
|
---|
20 | //import negotiator.onetomany.etc.Line;
|
---|
21 | import net.miginfocom.swing.MigLayout;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * @author Faria Nassiri-Mofakham
|
---|
25 | *
|
---|
26 | */
|
---|
27 | public class GUI extends JFrame
|
---|
28 | {
|
---|
29 | Main main;
|
---|
30 | private static final long serialVersionUID = -5602032021645365870L;
|
---|
31 |
|
---|
32 |
|
---|
33 | public GUI(Main m) //throws MalformedURLException, IOException
|
---|
34 | {
|
---|
35 | super("Bob gets ready for negotiation ...");
|
---|
36 | main = m;
|
---|
37 |
|
---|
38 |
|
---|
39 | // Show the GUI
|
---|
40 | setLayout(new MigLayout("", "", ""));
|
---|
41 |
|
---|
42 | // how to change to url address of Bob ? "./NegotiatorGUI/src/main/java/negotiator/onetomany/etc/Bob.png"
|
---|
43 | Canvas canvas0 = new Bob("C:\\Users\\fnm\\eclipse-workspace\\NegotiatorGUI\\src\\main\\java\\negotiator\\onetomany\\etc\\Bob.png");
|
---|
44 | // Canvas canvas0 = new Bob("NegotiatorGUI.src.main.java.negotiator.onetomany.etc.Bob.png");
|
---|
45 | canvas0.setSize(400, 200);
|
---|
46 | add(canvas0, "cell 0 0, span 1 4, growx, center"); //cannot make it center
|
---|
47 |
|
---|
48 | //defining a font
|
---|
49 | Font f1 = new Font("TimesRoman",Font.BOLD,20);
|
---|
50 | Font f2 = new Font("TimesRoman",Font.ITALIC,20);
|
---|
51 |
|
---|
52 |
|
---|
53 | JLabel l1_1 = new JLabel("The `Agent' receives Bob's PORTFOLIO containing "+m.getPortfolio().size()+" differnt products as follows:");
|
---|
54 | l1_1.setFont(f2);
|
---|
55 | //l1_1.setForeground(Color.GRAY);
|
---|
56 | add(l1_1, "cell 1 1, center, width 100:650:1000, wrap"); // no notice to min and max constraints for column width, just the preferred (the middle number)
|
---|
57 |
|
---|
58 | Canvas canvas1 = new Drawing1(m.getPortfolio());
|
---|
59 | canvas1.setBackground(Color.decode("#5C8585"));
|
---|
60 | canvas1.setSize(200, 200);
|
---|
61 | add(canvas1, "cell 1 2, growx, center, wrap");
|
---|
62 |
|
---|
63 | add(new JLabel(" "), "center, wrap");
|
---|
64 |
|
---|
65 | //a line
|
---|
66 | int w = (canvas0.getWidth()+canvas1.getWidth())*3; // doesn't calculate dynamically well!
|
---|
67 | System.out.println(w);
|
---|
68 | Canvas canvas2 = new Line(Color.BLACK,w);
|
---|
69 | canvas2.setSize(1, 1);
|
---|
70 | add(canvas2, "span 2 0, growx, center, wrap");
|
---|
71 |
|
---|
72 | add(new JLabel(" "), "center, wrap");
|
---|
73 |
|
---|
74 |
|
---|
75 | JLabel l2 = new JLabel("It also receives Bob's DEMAND PLAN as follows:");
|
---|
76 | l2.setFont(f1);
|
---|
77 | add(l2, "span 2 0, center, wrap");
|
---|
78 |
|
---|
79 | // Canvas canvas3 = new Drawing(m.getDemandPlan());
|
---|
80 | // canvas3.setSize(200, 200);
|
---|
81 | // add(canvas3, "center");
|
---|
82 |
|
---|
83 | add(new JLabel(" "), "center, wrap");
|
---|
84 |
|
---|
85 | Canvas canvas3 = new Drawing1(m.getPortfolio());
|
---|
86 | canvas3.setBackground(Color.WHITE);
|
---|
87 | canvas3.setSize(200, 200);
|
---|
88 | add(canvas3, "span 2 0, growx, growy, center, wrap");
|
---|
89 | //
|
---|
90 | add(new JLabel(" "), "span 2 0, center, wrap");
|
---|
91 |
|
---|
92 | //a line
|
---|
93 | Canvas canvas4 = new Line(Color.BLACK,w);
|
---|
94 | canvas4.setSize(1, 1);
|
---|
95 | add(canvas4, "span 2 0, growx, center, wrap");
|
---|
96 |
|
---|
97 | add(new JLabel(" "), "span 2 0, center, wrap");
|
---|
98 |
|
---|
99 | //buttons
|
---|
100 |
|
---|
101 | add(new JButton("Edit..."), "cell 0 12, span 2 0, center, w 90"); // at dynamic position ? for the height ?! by canvases heights, or counting the rows and columns?
|
---|
102 | add(new JButton("Delete..."), "cell 0 12, span 2 0, center, w 90");
|
---|
103 | add(new JButton("Next..."), "cell 0 12, span 2 0, center, w 90");
|
---|
104 | add(new JButton("Close"), "cell 0 12, span 2 0, center, wrap, w 90");
|
---|
105 |
|
---|
106 | //setting the background as the Bob's image
|
---|
107 | getContentPane().setBackground(Color.decode("#AFD6D6"));
|
---|
108 |
|
---|
109 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
---|
110 | pack();
|
---|
111 |
|
---|
112 | setLocationRelativeTo(null);
|
---|
113 | // Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
114 | // setBounds(0,0,screenSize.width, screenSize.height);
|
---|
115 | setVisible(true);
|
---|
116 | }
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * @param args
|
---|
120 | */
|
---|
121 | public static void main(String[] args)
|
---|
122 | {
|
---|
123 | Main main = new Main();
|
---|
124 | GUI gui = new GUI(main);
|
---|
125 |
|
---|
126 | }
|
---|
127 |
|
---|
128 | }
|
---|
129 |
|
---|
130 |
|
---|