Example #1
0
  public void paint(Graphics g) {
    super.paint(g);
    if (screen.equalsIgnoreCase("title")) {
      MyPanel.score = 0;
      hs = new Highscore();
      c.removeAll();
      c.add(ts);
      panel = null;
      ts.revalidate();
    } else if (screen.equalsIgnoreCase("instructions")) {
      c.removeAll();
      c.add(instructions);
      instructions.revalidate();
    } else if (screen.equalsIgnoreCase("mode")) {
      c.removeAll();
      c.add(mode);
      mode.revalidate();
    } else if (screen.equalsIgnoreCase("difficulty")) {
      c.removeAll();
      c.add(dif);
      dif.revalidate();
    } else if (screen.equalsIgnoreCase("highscore")) {
      if (hs.returnCount() == 0) {
        c.removeAll();
        c.add(hs);
        c.validate();
      }
    } else if (screen.equalsIgnoreCase("gameover")) {
      if (!once) {
        c.removeAll();
        c.add(gg);
        once = true;
        c.validate();
      }

    } else {
      if (once) {
        c.removeAll();
        panel = new MyPanel(THA.WIDTH, THA.HEIGHT, ai, diff);
        c.setLayout(new BorderLayout());
        c.add(panel.returnNs(), BorderLayout.WEST);
        c.add(panel, BorderLayout.CENTER);
        c.add(btns, BorderLayout.SOUTH);
        c.add(panel.returnAmmo(), BorderLayout.EAST);
        c.validate();
        once = false;
      }
    }
    repaint();
  }
  @Override
  public void dispose() {
    PropertiesComponent instance = PropertiesComponent.getInstance();
    instance.setValue(PROP_SORTED, Boolean.toString(isAlphabeticallySorted()));
    instance.setValue(PROP_SHOWCLASSES, Boolean.toString(myShowClasses));

    if (myCopyJavadocCheckbox != null) {
      instance.setValue(PROP_COPYJAVADOC, Boolean.toString(myCopyJavadocCheckbox.isSelected()));
    }

    final Container contentPane = getContentPane();
    if (contentPane != null) {
      contentPane.removeAll();
    }
    mySelectedNodes.clear();
    myElements = null;
    super.dispose();
  }
Example #3
0
  private void init() {
    setLayout(new BorderLayout());
    setVisible(false);

    state = 2;

    con.removeAll();

    setSize(600, 450);

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frameSize = getSize();
    setLocation(
        (int) (screen.getWidth() / 2 - frameSize.getWidth() / 2),
        (int) (screen.getHeight() / 2 - frameSize.getHeight() / 2));

    con = getContentPane();
    setVisible(true);

    ladderWidth = player;
    ladderMap = new int[ladderHeight][ladderWidth];

    player_pl = new JPanel();
    goal_pl = new JPanel();
    player_pl.setLayout(new GridLayout(1, 1, 5, 5));
    goal_pl.setLayout(new GridLayout(1, 1, 5, 5));

    player_bt = new JButton[player];
    goal_bt = new JButton[player];

    for (int i = 0; i < player; i++) {
      String s = String.valueOf(i + 1) + "번";
      player_bt[i] = new JButton(s);
      goal_bt[i] = new JButton("꽝");
      player_bt[i].setBounds(
          (int) (frameSize.getWidth() / player * i + frameSize.getWidth() / player * 0.1), 5,
          (int) (frameSize.getWidth() / player * 0.85), 25);
      goal_bt[i].setBounds(
          (int) (frameSize.getWidth() / player * i + frameSize.getWidth() / player * 0.05),
          (int) (frameSize.getHeight() - 50),
          (int) (frameSize.getWidth() / player * 0.9),
          25);
      player_pl.add(player_bt[i]);
      goal_pl.add(goal_bt[i]);
      player_bt[i].addActionListener(this);
      goal_bt[i].addActionListener(this);
    }

    while (true) {
      int i = (int) (Math.random() * 10);
      if (i < player) {
        goal_bt[i].setText("당첨");
        break;
      }
    }

    con.add(player_pl, "North");
    con.add(goal_pl, "South");

    draw = new Draw();
    con.add(draw, "Center");
    draw.init();
    initLadder();
    validate();
    repaint();

    // play = new Play(this, draw, frameSize,1);
    // play.start();
    //
    // play2 = new Play(this, draw, frameSize,5);
    // play2.start();
    play = new Play[player];

    addComponentListener(new ComponentResizedHdl());
  }