import java.awt.GridLayout; import java.awt.Graphics; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JFrame; import javax.swing.ImageIcon; import java.awt.*; import javax.swing.*; import java.awt.Color; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.image.BufferedImage; import java.io.*; import javax.imageio.ImageIO; import java.util.Random; public class Board implements ActionListener{ private JButton draw, roll, done; private Container background, buttonst, buttonsl, buttonsr, buttonsb; private JButton a, b, c, d , e, f, g, h, i, j, k, l; private JButton m, n, o, p, q, r; private JButton s, t, u, v ,w ,x; private JButton y, z, aa, ab, ac, ad, ae, af, ag, ah, ai, aj,Roll,DrawCard; private JLabel P1,P2,P3,P4,testes; private JPanel totalGUI, buttonsTop, buttonsLeft, buttonsRight, buttonsBottom, MainButt, PlayerInfo; private ImageIcon icon, test, test1; private Character player1,player2,player3,player4; private int coordx1,coordy1; private JLayeredPane layeredPane; public JPanel createContentPane (){ JPanel totalGUI = new JPanel(); totalGUI.setOpaque(false); totalGUI.setLayout(null); totalGUI.setVisible(false); ImageIcon test1 = new ImageIcon(getClass().getResource("buffguychar.png")); ImageIcon test = new ImageIcon(getClass().getResource("upgradebuildingcard.png")); player1 = new Character(300, 300); player2 = new Character(); player3 = new Character(); player4 = new Character(); PlayerInfo = new JPanel(); PlayerInfo.setLayout(null); PlayerInfo.setLocation(100,100); PlayerInfo.setSize(1000,600); PlayerInfo.setOpaque(false); PlayerInfo.add(player1); totalGUI.add(PlayerInfo); totalGUI.add(player1); MainButt = new JPanel(); MainButt.setLocation(500,500); MainButt.setSize(100,100); totalGUI.add(MainButt); buttonsTop = new JPanel(); buttonsTop.setLayout(null); buttonsTop.setLocation(0, 0); buttonsTop.setSize(1200, 100); buttonsTop.setOpaque(false); totalGUI.add(buttonsTop); buttonsLeft = new JPanel(); buttonsLeft.setLayout(null); buttonsLeft.setLocation(0, 100); buttonsLeft.setSize(100, 600); buttonsLeft.setOpaque(false); totalGUI.add(buttonsLeft); buttonsRight = new JPanel(); buttonsRight.setLayout(null); buttonsRight.setLocation(1100, 100); buttonsRight.setSize(100, 600); buttonsRight.setOpaque(false); totalGUI.add(buttonsRight); buttonsBottom = new JPanel(); buttonsBottom.setLayout(null); buttonsBottom.setLocation(0, 700); buttonsBottom.setSize(1200, 100); buttonsBottom.setOpaque(false); totalGUI.add(buttonsBottom); a = new JButton(test); a.setIcon(test); a.setLocation(0, 0); a.setSize(100, 100); a.addActionListener(this); buttonsTop.add(a); b = new JButton(test); b.setIcon(test1); b.setText("hI"); b.setLocation(100, 0); b.setSize(100, 100); b.addActionListener(this); buttonsTop.add(b); c = new JButton(test1); c.setLocation(200, 0); c.setSize(100, 100); c.addActionListener(this); buttonsTop.add(c); d = new JButton(test); d.setLocation(300, 0); d.setSize(100, 100); d.addActionListener(this); buttonsTop.add(d); e = new JButton(test); e.setLocation(400, 0); e.setSize(100, 100); e.addActionListener(this); buttonsTop.add(e); f = new JButton(test); f.setLocation(500, 0); f.setSize(100, 100); f.addActionListener(this); buttonsTop.add(f); g = new JButton(test); g.setLocation(600, 0); g.setSize(100, 100); g.addActionListener(this); buttonsTop.add(g); h = new JButton(test); h.setLocation(700, 0); h.setSize(100, 100); h.addActionListener(this); buttonsTop.add(h); i = new JButton(test); i.setLocation(800, 0); i.setSize(100, 100); i.addActionListener(this); buttonsTop.add(i); j = new JButton(test); j.setLocation(900, 0); j.setSize(100, 100); j.addActionListener(this); buttonsTop.add(j); k = new JButton(test); k.setLocation(1000, 0); k.setSize(100, 100); k.addActionListener(this); buttonsTop.add(k); l = new JButton(test); l.setLocation(1100, 0); l.setSize(100, 100); l.addActionListener(this); buttonsTop.add(l); m = new JButton(test); m.setLocation(0, 0); m.setSize(100, 100); m.addActionListener(this); buttonsLeft.add(m); n = new JButton(test); n.setLocation(0, 100); n.setSize(100, 100); n.addActionListener(this); buttonsLeft.add(n); o = new JButton(test); o.setLocation(0, 200); o.setSize(100, 100); o.addActionListener(this); buttonsLeft.add(o); p = new JButton(test); p.setLocation(0, 300); p.setSize(100, 100); p.addActionListener(this); buttonsLeft.add(p); q = new JButton(test); q.setLocation(0, 400); q.setSize(100, 100); q.addActionListener(this); buttonsLeft.add(q); r = new JButton(test); r.setLocation(0, 500); r.setSize(100, 100); r.addActionListener(this); buttonsLeft.add(r); s = new JButton(test); s.setLocation(0, 0); s.setSize(100, 100); s.addActionListener(this); buttonsRight.add(s); t = new JButton(test); t.setLocation(0, 100); t.setSize(100, 100); t.addActionListener(this); buttonsRight.add(t); u = new JButton(test); u.setLocation(0, 200); u.setSize(100, 100); u.addActionListener(this); buttonsRight.add(u); v = new JButton(test); v.setLocation(0, 300); v.setSize(100, 100); v.addActionListener(this); buttonsRight.add(v); w = new JButton(test); w.setLocation(0, 400); w.setSize(100, 100); w.addActionListener(this); buttonsRight.add(w); x = new JButton(test); x.setLocation(0, 500); x.setSize(100, 100); x.addActionListener(this); buttonsRight.add(x); y = new JButton(test); y.setLocation(0, 0); y.setSize(100, 100); y.addActionListener(this); buttonsBottom.add(y); z = new JButton(test); z.setLocation(100, 0); z.setSize(100, 100); z.addActionListener(this); buttonsBottom.add(z); aa = new JButton(test); aa.setLocation(200, 0); aa.setSize(100, 100); aa.addActionListener(this); buttonsBottom.add(aa); ab = new JButton(test); ab.setIcon(test); ab.setLocation(300, 0); ab.setSize(100, 100); ab.addActionListener(this); buttonsBottom.add(ab); ac = new JButton(test); ac.setLocation(400, 0); ac.setSize(100, 100); ac.addActionListener(this); buttonsBottom.add(ac); ad = new JButton(test); ad.setLocation(500, 0); ad.setSize(100, 100); ad.addActionListener(this); buttonsBottom.add(ad); ae = new JButton(test); ae.setLocation(600, 0); ae.setSize(100, 100); ae.addActionListener(this); buttonsBottom.add(ae); af = new JButton(test); af.setLocation(700, 0); af.setSize(100, 100); af.addActionListener(this); buttonsBottom.add(af); ag = new JButton(test); ag.setLocation(800, 0); ag.setSize(100, 100); ag.addActionListener(this); buttonsBottom.add(ag); ah = new JButton(test); ah.setLocation(900, 0); ah.setSize(100, 100); ah.addActionListener(this); buttonsBottom.add(ah); ai = new JButton(test); ai.setLocation(1000, 0); ai.setSize(100, 100); ai.addActionListener(this); buttonsBottom.add(ai); aj = new JButton("Start"); aj.setLocation(1100, 0); aj.setSize(100, 100); aj.addActionListener(this); buttonsBottom.add(aj); DrawCard = new JButton("Draw"); DrawCard.setSize(200,120); DrawCard.setLocation(400,200); DrawCard.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ Commands.Roll(); } }); PlayerInfo.add(DrawCard); Roll = new JButton("Roll"); Roll.setLocation(460,400); Roll.setSize(75,75); Roll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {Commands.Roll(); } }); PlayerInfo.add(Roll); P1 = new JLabel("P1 Money:" + player1.getMoney()); P1.setSize(200,100); P1.setLocation(0,0); PlayerInfo.add(P1); P2 = new JLabel("P2 Money:" + player2.getMoney()); P2.setSize(200,100); P2.setLocation(800,0); PlayerInfo.add(P2); P3 = new JLabel("P3 Money:" + player3.getMoney()); P3.setSize(200,100); P3.setLocation(0,500); PlayerInfo.add(P3); P4 = new JLabel("P4 Money:" + player4.getMoney()); P4.setSize(200,100); P4.setLocation(800,500); PlayerInfo.add(P4); /* buttonst = new Container(); buttonst.setLayout(new GridLayout(1,12)); buttonst.add(a); buttonst.add(b); buttonst.add(c); buttonst.add(d); buttonst.add(e); buttonst.add(f); buttonst.add(g); buttonst.add(h); buttonst.add(i); buttonst.add(j); buttonst.add(k); buttonst.add(l); buttonsl = new Container(); buttonsl.setLayout(new GridLayout(6, 1)); buttonsl.add(m); buttonsl.add(n); buttonsl.add(o); buttonsl.add(p); buttonsl.add(q); buttonsl.add(r); buttonsr = new Container(); buttonsr.setLayout(new GridLayout(6, 1)); buttonsr.add(s); buttonsr.add(t); buttonsr.add(u); buttonsr.add(v); buttonsr.add(w); buttonsr.add(x); buttonsb = new Container(); buttonsb.setLayout(new GridLayout(1, 12)); buttonsb.add(y); buttonsb.add(z); buttonsb.add(aa); buttonsb.add(ab); buttonsb.add(ac); buttonsb.add(ad); buttonsb.add(ae); buttonsb.add(af); buttonsb.add(ag); buttonsb.add(ah); buttonsb.add(ai); buttonsb.add(aj); */ /* buttonsTop.add(buttonst); buttonsLeft.add(buttonsl); buttonsRight.add(buttonsr); buttonsBottom.add(buttonsb); */ totalGUI.setOpaque(false); return totalGUI; } private static void createAndShowGUI() { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("Thugopoly"); //Create and set up the content pane. Board demo = new Board(); Character s = new Character(400,400); frame.add(s); frame.setContentPane(demo.createContentPane()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(1210, 830); frame.setVisible(true); frame.setResizable(false); } public void actionPerformed(ActionEvent e) { int x = 1; if(e.getSource() == a){ x = 1; } } public static void main(String[] args) { //Schedule a job for the event-dispatching thread: //creating and showing this application's GUI. SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } } ); } } import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Character extends JPanel{ private String name; private int x ,y, money; private ImageIcon image; public void paintComponent(Graphics g){ super.paintComponent(g); ImageIcon image = new ImageIcon(getClass().getResource("buffguychar.png")); image.paintIcon(this, g, x, y); validate(); } public Character(int a, int b ){ x = a; y = b; name = "tester"; money = 1000; } public Character(){ x = 1200; y = 800; money = 1000; } public void addMoney(int a){ money += a; } public int getMoney(){ return money; } public int getx(){ return x; } public int gety(){ return y; } public void setx(int n){ x = n; } public void sety(int n){ y = n; } }