Exemple #1
0
  /** Constructor for allocating memory and simple initializing. */
  public GameBoard() {
    dealerPanel = new JPanel();
    playerPanel = new JPanel();
    controlPanel = new JPanel();
    money = new JLabel();
    record = new JLabel();
    inputImage = new JLabel(new ImageIcon("res/INPUT.gif"));
    moneyLabel = new JLabel(new ImageIcon("res/MONEY.gif"));
    betLabel = new JLabel(new ImageIcon("res/MAKE_YOUR_BET.gif"));
    recordLabel = new JLabel(new ImageIcon("res/BEST_SCORE.gif"));
    betButton = new JButton(new ImageIcon("res/BET.gif"));
    resultButton = new JButton(new ImageIcon("res/RESULT.gif"));
    betInput = new JTextField();

    try {
      recordReader = new BufferedReader(new FileReader("res/record"));
      bestScore = Integer.parseInt(recordReader.readLine());
      recordReader.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    inputImage.setLayout(new BorderLayout());
    controlPanel.setLayout(new FlowLayout());

    betInput.setHorizontalAlignment(JTextField.CENTER);
    betButton.setBorder(BorderFactory.createEmptyBorder());
    betButton.setContentAreaFilled(false);
    resultButton.setBorder(BorderFactory.createEmptyBorder());
    resultButton.setContentAreaFilled(false);
    resultButton.setEnabled(false);
    betButton.addMouseListener(new BetListener());
    resultButton.addMouseListener(new ResultListener());
    betInput.setOpaque(false);
    betInput.setBorder(BorderFactory.createEmptyBorder());
    money.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 30));
    record.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 30));
    setOpaque(false);

    initGame();
    initRound();
  }
Exemple #2
0
  public void gold() throws Exception {
    frm = new JFrame();
    frm.setTitle("Background Color for JFrame");
    // frm.setSize(400, 400);
    frm.setLocationRelativeTo(null);
    // frm.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frm.setVisible(true);
    frm.setLayout(new BorderLayout());
    JLabel background =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\Untitled.jpg"));
    frm.add(background);
    // background.setLayout(new FlowLayout());
    background.setLayout(null);
    lh2 = (int) (((((Math.random()) * 5) * 5) * 5) * 7);
    lh3 = (int) (((((Math.random()) * 5) * 5) * 5) * 7);
    lh4 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh5 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh6 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh7 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh8 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh9 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh0 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);

    // JLabel l1=new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\images.gif"));
    JLabel l1 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\images.gif"));
    JLabel l2 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l3 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l4 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l5 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l6 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l7 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l8 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l9 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l0 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));

    txter = new JTextField(100);
    txter.setBounds(3, 4, 0, 35);

    txter.addKeyListener(this);
    txter.getCursor();
    txter.setText(strgr);
    row += 10;
    for (int it = 1; it > 0; it += 7) {
      // Rectangle r=compu
      l1.setBounds(300 + my_car.row, 400 + my_car.col, 90, 190);
      l2.setBounds(lh2, -250 + chg, 90, 190);
      l3.setBounds(lh3, -750 + chg, 90, 190);
      l4.setBounds(lh4, -1200 + chg, 90, 190);
      l5.setBounds(lh5, -1750 + chg, 90, 190);
      l6.setBounds(lh6, -2250 + chg, 90, 190);
      l7.setBounds(lh7, -2700 + chg, 90, 190);
      l8.setBounds(lh8, -3250 + chg, 90, 190);
      l9.setBounds(lh9, -3800 + chg, 90, 190);
      l0.setBounds(lh0, -4250 + chg, 90, 190);
      chg += 20;
      if (chg >= (5000)) {
        chg = 0;
        lh2 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh3 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh4 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh5 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh6 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh7 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh8 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh9 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh0 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
      }
      txter.requestDefaultFocus();
      {
      }

      Thread.sleep(50);
      System.out.println(my_car.row);
      l1.repaint();
      l2.repaint();

      // b1=new JButton("I am a button");
      background.add(l1);
      background.add(l2);
      background.add(l3);
      background.add(l4);
      background.add(l5);
      background.add(l6);
      background.add(l7);
      background.add(l8);
      background.add(l9);
      background.add(l0);
      background.add(txter);

      // background.add(b1);
      // frm.setSize(799, 699);
      frm.setBounds(0, 0, 800, 700);
      frm.setResizable(false);
    }
  }
Exemple #3
0
  public void createLayout() {
    top = new JPanel();
    wModel.panel.add(top, BorderLayout.NORTH);
    top.setLayout(new BorderLayout(0, 0));

    bottom = new JPanel();
    wModel.panel.add(bottom, BorderLayout.SOUTH);
    bottom.setLayout(new BorderLayout(0, 0));

    center = new JPanel();
    wModel.panel.add(center, BorderLayout.CENTER);
    center.setLayout(new BorderLayout(0, 0));

    // Spielfeld
    gameField = new JPanel();
    gameField.setPreferredSize(new Dimension(550, 800));
    wModel.panel.add(gameField, BorderLayout.WEST);
    gameField.setLayout(new GridLayout(4, 4, 5, 5));

    /**
     * *********************************************************** Sidebar
     * ************************************************************
     */
    dates = new JPanel();
    dates.setLayout(new BorderLayout());
    JLabel background = new JLabel(new ImageIcon("../gfx/datesBack.png"));
    dates.add(background);

    GridBagLayoutModel gblModel = new GridBagLayoutModel();
    GridBagLayout gbl = new GridBagLayout();
    background.setLayout(gbl);

    l1 = new JLabel(new ImageIcon("../gfx/spieler1.png"));
    points1 = new JLabel(new ImageIcon("../gfx/punkte.png"));
    points1Num = new JLabel("0");
    l2 = new JLabel(new ImageIcon("../gfx/spieler2.png"));
    points2 = new JLabel(new ImageIcon("../gfx/punkte.png"));
    points2Num = new JLabel("0");

    JLabel namePlayer1 = new JLabel(player1.getName());
    JLabel namePlayer2 = new JLabel(player2.getName());

    JButton end = new JButton("Beenden");

    gblModel.addComponent(background, gbl, l1, 0, 2, 1, 1, 1.0, 0.5);
    gblModel.addComponent(background, gbl, namePlayer1, 1, 2, 1, 1, 1.0, 0.5);
    gblModel.addComponent(background, gbl, points1, 0, 3, 1, 1, 1.0, 0.2);
    gblModel.addComponent(background, gbl, points1Num, 1, 3, 1, 1, 1.0, 0.2);
    gblModel.addComponent(background, gbl, l2, 0, 4, 1, 1, 1.0, 1.0);
    gblModel.addComponent(background, gbl, namePlayer2, 1, 4, 1, 1, 1.0, 1.0);
    gblModel.addComponent(background, gbl, points2, 0, 5, 1, 1, 1.0, 0.2);
    gblModel.addComponent(background, gbl, points2Num, 1, 5, 1, 1, 1.0, 0.2);
    gblModel.addComponent(background, gbl, end, 1, 6, 1, 1, 0.0, 0.2);

    wModel.panel.add(dates, BorderLayout.EAST);

    end.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
  }
Exemple #4
0
  public p2() throws Exception {

    // setBorder(BorderFactory.createEtchedBorder(Color.lightGray, Color.DARK_GRAY));
    p = new JPanel();
    // setBackground(Color.white);
    p.setLayout(new GridLayout(11, 3));
    p.setBounds(0, 20, 309, 130);

    un = new JLabel("*  Username");
    ps1 = new JLabel("*  Password");
    ps2 = new JLabel("*  Confirm Password");
    fn = new JLabel("*  First Name");
    ln = new JLabel("   Last Name");
    eid = new JLabel("*  Email ID");
    mb = new JLabel("*  Mobile");
    cct = new JLabel("*  Current City");
    hquali = new JLabel("*  Highest Qualification");
    dob = new JLabel("   DOB");
    dober = new JLabel();
    dd = new JLabel("DD");
    mm = new JLabel("MM");
    yy = new JLabel("YY");
    member = new Label("     already a member?");
    member.addMouseListener(this);

    er1 = new Label("");
    er2 = new Label("");
    er3 = new Label("");
    er4 = new Label("");
    er5 = new Label("");
    er6 = new Label("");
    er7 = new Label("");
    er8 = new Label("");
    er9 = new Label("");
    er10 = new Label("");

    un1 = new JTextField(15);
    ps11 = new JPasswordField(15);
    ps21 = new JPasswordField(15);
    fn1 = new JTextField(15);
    ln1 = new JTextField(15);
    eid1 = new JTextField(15);
    mb1 = new JTextField(15);
    cct1 = new JTextField(15);
    hquali1 = new JTextField(15);
    dober1 = new JTextField(2);
    dober2 = new JTextField(2);
    dober3 = new JTextField(2);

    sub = new JButton("Sign up");
    sub.setBorderPainted(false);
    sub.setFocusable(true);
    sub.addActionListener(this);

    dober.setLayout(new FlowLayout());
    dober.add(dober1);
    dober.add(dd);
    dober.add(dober2);
    dober.add(mm);
    dober.add(dober3);
    dober.add(yy);

    p.add(fn);
    p.add(fn1);
    p.add(er1);
    p.add(ln);
    p.add(ln1);
    p.add(er2);
    p.add(un);
    p.add(un1);
    p.add(er3);
    p.add(ps1);
    p.add(ps11);
    p.add(er4);
    p.add(ps2);
    p.add(ps21);
    p.add(er5);
    p.add(eid);
    p.add(eid1);
    p.add(er6);
    p.add(mb);
    p.add(mb1);
    p.add(er7);
    p.add(cct);
    p.add(cct1);
    p.add(er8);
    p.add(hquali);
    p.add(hquali1);
    p.add(er9);
    p.add(dob);
    p.add(dober);
    p.add(er10);

    p.add(sub);
    p.add(member);
    add(p);
  }