Пример #1
0
  /** Creates new form RaceMenu1 */
  public RaceMenu() {
    RACENUM = 6;
    initComponents();
    OKButton.setEnabled(false);
    DescriptionContainer.setViewportView(DescriptionText);

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    if ((screenSize.getWidth() > getContentPane().getWidth())
        && (screenSize.getHeight() > getContentPane().getHeight())) {
      int intwidth =
          new Double(((screenSize.getWidth() - getContentPane().getWidth()) / 2)).intValue();
      int intheight =
          new Double(((screenSize.getHeight() - getContentPane().getHeight()) / 2)).intValue();
      setLocation(intwidth, intheight);
    } else {
      setLocation(0, 0);
    }

    menucreate = TLKFactory.getCreateMenu();
    menucreate.BlockWindow(true);
    TLKFAC = menucreate.getTLKFactory();
    RESFAC = menucreate.getResourceFactory();
    String imagestring = "";
    DescriptionText.setText(TLKFAC.getEntry(485));
    try {
      racialmap = RESFAC.getResourceAs2DA("racialtypes");
    } catch (IOException err) {
      JOptionPane.showMessageDialog(
          null,
          "Fatal Error - racialtypes.2da not found. Your data files might be corrupt.",
          "Error",
          0);
      System.exit(0);
    }
    for (int i = 0; i < racialmap.length; i++) {
      String tempispc = racialmap[i][racialtypes.PlayerRace];
      if (tempispc != null && tempispc.equalsIgnoreCase("1")) {
        RaceButton racebutton = new RaceButton();
        descstr = racialmap[i][racialtypes.Name];
        int descnum = ChkHex.ChkHex(descstr);
        racebutton.RaceButton.setText(TLKFAC.getEntry(descnum));
        racebutton.setSize(240, 52);
        racebutton.InfoNum.setText(Integer.toString(i));
        RaceButtonList.add(racebutton, -1);
      }
    }

    pack();
  }
Пример #2
0
    private void initComponents() {
      RaceButton = new JButton();
      InfoNum = new JLabel();
      setLayout(new GridBagLayout());
      RaceButton.setBackground(new Color(0, 0, 0));
      RaceButton.setForeground(new Color(222, 200, 120)); // Text color for buttons
      RaceButton.setText("Name Place Holder");
      RaceButton.setHorizontalAlignment(2);
      RaceButton.setPreferredSize(new Dimension(240, 52));
      RaceButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
              RaceButtonActionPerformed(evt);
            }
          });
      GridBagConstraints gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.fill = 2;
      add(RaceButton, gridBagConstraints);
      InfoNum.setText("Num");
      gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.gridy = 0;
      add(InfoNum, gridBagConstraints);
    }