source: src/main/java/negotiator/onetomany/GUI.java@ 220

Last change on this file since 220 was 220, checked in by Faria Nassiri Mofakham, 6 years ago

Bob works now! It shows Bob's image through updated GUI.

File size: 3.9 KB
Line 
1package negotiator.onetomany;
2
3import java.awt.Canvas;
4import java.awt.Color;
5import java.awt.Dimension;
6import java.awt.Image;
7import java.awt.Toolkit;
8
9import javax.swing.JButton;
10import javax.swing.JComponent;
11import javax.swing.JFrame;
12import javax.swing.JLabel;
13import javax.swing.JPanel;
14
15import negotiator.onetomany.etc.Bob;
16import negotiator.onetomany.etc.Drawing;
17import negotiator.onetomany.etc.Line;
18//import negotiator.onetomany.etc.Line;
19import net.miginfocom.swing.MigLayout;
20
21/**
22 * @author Faria Nassiri-Mofakham
23 *
24 */
25public class GUI extends JFrame
26{
27 Main main;
28 private static final long serialVersionUID = -5602032021645365870L;
29
30
31 public GUI(Main m) //throws MalformedURLException, IOException
32 {
33 super("Bob gets ready for negotiation ...");
34 main = m;
35
36
37 // Show the GUI
38 setLayout(new MigLayout("", "", ""));
39
40 //add(new JLabel("This is Bob, Bob is a buyer"), "center, wrap");
41
42// add(new JComponent("/NegotiatorGUI/src/main/java/negotiator/onetomany/etc/Bob.png"), "growx, center, wrap");
43
44 Canvas canvas0 = new Bob("C:\\Users\\fnm\\eclipse-workspace\\NegotiatorGUI\\src\\main\\java\\negotiator\\onetomany\\etc\\Bob.png");
45 canvas0.setSize(400, 200);
46 add(canvas0, "growx, center, wrap");
47
48 add(new JLabel(" "), "center, wrap");
49
50
51
52 add(new JLabel("The `Agent' receives Bob's PORTFOLIO as follows:"), "center, wrap");
53
54
55 Canvas canvas1 = new Drawing(m.getPortfolio());
56 canvas1.setSize(200, 200);
57 add(canvas1, "growx, center, wrap");
58
59 //add(new Line()); // for drawing a line!
60 //add(new Line2D.Float(100, 100, 400, 100), "center");
61
62
63 Canvas canvas2 = new Line(Color.BLACK,800);
64 canvas2.setSize(1, 1);
65 add(canvas2, "growx, center, wrap");
66
67
68// add(new JLabel("It also receives Bob's DEMAND PLAN as follows:"), "center, wrap");
69
70 // Canvas canvas2 = new Drawing(m.getDemandPlan());
71 // canvas2.setSize(200, 200);
72 // add(canvas2, "center");
73
74
75// Canvas canvas2 = new Drawing(m.getPortfolio());
76// canvas2.setSize(200, 200);
77// add(canvas2, "growx, growy, center, wrap");
78//
79// add(new JLabel("--------------------------------------------------------------------------------------------------"), "center, wrap, w 100");
80//
81//
82// //*********************
83// add(new JButton("Edit..."), "cell 0 10, center, w 90");
84// add(new JButton("Delete..."), "cell 0 10, center, w 90");
85// add(new JButton("Next..."), "cell 0 10,center, w 90");
86// add(new JButton("Close"), "cell 0 10, center, wrap, w 90");
87
88
89
90 // setting the background as the Bob's image
91 getContentPane().setBackground(Color.decode("#AFD6D6"));
92
93
94 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
95 pack();
96
97
98 setLocationRelativeTo(null);
99// Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
100// setBounds(0,0,screenSize.width, screenSize.height);
101 setVisible(true);
102 }
103
104 /**
105 * @param args
106 */
107 public static void main(String[] args)
108 {
109 Main main = new Main();
110 GUI gui = new GUI(main);
111
112 }
113
114}
115
116//import java.awt.geom.Line2D;
117//import java.awt.image.BufferedImage;
118//import java.io.File;
119//import java.io.IOException;
120
121//import javax.swing.*;
122//import javax.imageio.ImageIO;
123
124//import javax.swing.ImageIcon;
125
126//import java.awt.FlowLayout;
127//import java.net.MalformedURLException;
128
129
130
131
132
133//ImageIcon ii = new ImageIcon("/NegotiatorGUI/src/main/java/negotiator/onetomany/etc/Bob.png");
134//JLabel lable = new JLabel(ii);
135//JScrollPane jsp = new JScrollPane(lable);
136//
137//getContentPane().add(jsp);
138// setSize(1000, 700);
139
140
141
142//BufferedImage img = ImageIO.read(new URL("NegotiatorGUI.src.main.java.negotiator.onetomany.etc.Bob.png"));
143//ImageIcon icon = new ImageIcon(img);
144//setLayout(new FlowLayout());
145//setSize(200, 300);
146//JLabel lbl = new JLabel();
147//lbl.setIcon(icon);
148//add(lbl);
149
150
151//canvas2.setBounds(x, y, width, height); //for changing its margin !?
Note: See TracBrowser for help on using the repository browser.