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

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

Fonts work at GUI JLabels!

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