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
RevLine 
[209]1package negotiator.onetomany;
2
[212]3import java.awt.Canvas;
[218]4import java.awt.Color;
[219]5import java.awt.Dimension;
[221]6import java.awt.Font;
[220]7import java.awt.Image;
[219]8import java.awt.Toolkit;
[218]9
[209]10import javax.swing.JButton;
[219]11import javax.swing.JComponent;
[209]12import javax.swing.JFrame;
13import javax.swing.JLabel;
[219]14import javax.swing.JPanel;
[209]15
[216]16import negotiator.onetomany.etc.Bob;
[212]17import negotiator.onetomany.etc.Drawing;
[219]18import negotiator.onetomany.etc.Line;
[216]19//import negotiator.onetomany.etc.Line;
[209]20import net.miginfocom.swing.MigLayout;
21
[210]22/**
23 * @author Faria Nassiri-Mofakham
24 *
25 */
[209]26public class GUI extends JFrame
27{
28 Main main;
[216]29 private static final long serialVersionUID = -5602032021645365870L;
30
[211]31
[216]32 public GUI(Main m) //throws MalformedURLException, IOException
[209]33 {
[215]34 super("Bob gets ready for negotiation ...");
[209]35 main = m;
36
[211]37
[209]38 // Show the GUI
[215]39 setLayout(new MigLayout("", "", ""));
[211]40
[221]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");
[220]44 canvas0.setSize(400, 200);
[216]45
[221]46 add(canvas0, "growx, center, wrap"); //cannot make it center
47
[219]48 add(new JLabel(" "), "center, wrap");
[216]49
[221]50
51 //defining a font
52 Font f1 = new Font("TimesRoman",Font.BOLD,20);
53 Font f2 = new Font("TimesRoman",Font.ITALIC,20);
[215]54
[221]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");
[216]60
61
[215]62 Canvas canvas1 = new Drawing(m.getPortfolio());
63 canvas1.setSize(200, 200);
64 add(canvas1, "growx, center, wrap");
65
66
[221]67 //a line
[219]68 Canvas canvas2 = new Line(Color.BLACK,800);
69 canvas2.setSize(1, 1);
[221]70 add(canvas2, "growx, center, wrap");
[219]71
[221]72 JLabel l2 = new JLabel("It also receives Bob's DEMAND PLAN as follows:");
73 l2.setFont(f1);
74 add(l2, "center, wrap");
[215]75
76 // Canvas canvas2 = new Drawing(m.getDemandPlan());
77 // canvas2.setSize(200, 200);
78 // add(canvas2, "center");
79
[216]80
[219]81// Canvas canvas2 = new Drawing(m.getPortfolio());
82// canvas2.setSize(200, 200);
83// add(canvas2, "growx, growy, center, wrap");
84//
[218]85
[221]86// //a line
87// Canvas canvas4 = new Line(Color.BLACK,800);
88// canvas4.setSize(1, 1);
89// add(canvas4, "growx, center, wrap");
[218]90
[221]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
[219]98 getContentPane().setBackground(Color.decode("#AFD6D6"));
[221]99
[209]100 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
101 pack();
[221]102
[209]103 setLocationRelativeTo(null);
[219]104// Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
105// setBounds(0,0,screenSize.width, screenSize.height);
[209]106 setVisible(true);
107 }
[211]108
[210]109 /**
110 * @param args
111 */
[209]112 public static void main(String[] args)
113 {
114 Main main = new Main();
115 GUI gui = new GUI(main);
[211]116
[209]117 }
118
[216]119}
[211]120
121
Note: See TracBrowser for help on using the repository browser.