private void RaceButtonActionPerformed(ActionEvent evt) { int tmp = (new Integer(InfoNum.getText())).intValue(); descstr = racialmap[tmp][racialtypes.Description]; int descnum = ChkHex.ChkHex(descstr); // int descnum = (new Integer((String)racialmap[tmp].get(new // Integer(racialtypes.Description)))).intValue(); DescriptionText.setText(TLKFAC.getEntry(descnum)); DescriptionContainer.scrollRectToVisible(new Rectangle(10, 10)); DescriptionContainer.getViewport().setViewPosition(new Point(0, 0)); // @DUG RACENUM = tmp; OKButton.setEnabled(true); }
/** 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(); }
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ private void initComponents() { // GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; RaceButtonContainer = new javax.swing.JScrollPane(); RaceButtonBak = new javax.swing.JPanel(); RaceButtonList = new javax.swing.JPanel(); RecommendedButton = new javax.swing.JButton(); OKButton = new javax.swing.JButton(); CancelButton = new javax.swing.JButton(); DescriptionContainer = new javax.swing.JScrollPane(); DescriptionText = new javax.swing.JTextArea(); PadPanel = new javax.swing.JPanel(); PadPanel2 = new javax.swing.JPanel(); PadPanel3 = new javax.swing.JPanel(); PadPanel4 = new javax.swing.JPanel(); jPanel16 = new javax.swing.JPanel(); jPanel17 = new javax.swing.JPanel(); getContentPane().setLayout(new java.awt.GridBagLayout()); setTitle("Choose a Race for your character."); addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); RaceButtonContainer.setHorizontalScrollBarPolicy( javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); RaceButtonContainer.setVerticalScrollBarPolicy( javax.swing.JScrollPane .VERTICAL_SCROLLBAR_ALWAYS); // was that weird green color on the menus RaceButtonContainer.setViewportBorder( new javax.swing.border.MatteBorder( new java.awt.Insets(10, 10, 10, 10), new java.awt.Color(0, 0, 0))); RaceButtonContainer.setMaximumSize(new java.awt.Dimension(32767, 300)); RaceButtonContainer.setPreferredSize(new java.awt.Dimension(283, 300)); RaceButtonContainer.setAutoscrolls(true); RaceButtonContainer.getVerticalScrollBar().setUnitIncrement(52); RaceButtonContainer.getVerticalScrollBar().setBlockIncrement(52); RaceButtonBak.setLayout(new java.awt.GridBagLayout()); RaceButtonBak.setBackground(new java.awt.Color(0, 0, 0)); RaceButtonBak.setForeground(new java.awt.Color(255, 255, 255)); // color not seen RaceButtonBak.setAlignmentX(0.0F); RaceButtonBak.setAlignmentY(0.0F); RaceButtonBak.setAutoscrolls(true); RaceButtonList.setLayout(new java.awt.GridLayout(0, 1)); RaceButtonList.setBackground(new java.awt.Color(0, 0, 0)); // outline behind buttons RaceButtonList.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(3, 3, 3, 3))); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; RaceButtonBak.add(RaceButtonList, gridBagConstraints); RaceButtonContainer.setViewportView(RaceButtonBak); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.gridheight = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; getContentPane().add(RaceButtonContainer, gridBagConstraints); RecommendedButton.setText("Recommended"); RecommendedButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RecommendedButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 8; getContentPane().add(RecommendedButton, gridBagConstraints); OKButton.setText("OK"); OKButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { OKButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 8; getContentPane().add(OKButton, gridBagConstraints); CancelButton.setText("Cancel"); CancelButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CancelButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 8; getContentPane().add(CancelButton, gridBagConstraints); DescriptionContainer.setHorizontalScrollBarPolicy( javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); DescriptionContainer.setVerticalScrollBarPolicy( javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // behind text description DescriptionContainer.setViewportBorder( new javax.swing.border.MatteBorder( new java.awt.Insets(10, 10, 10, 10), new java.awt.Color(0, 0, 0))); DescriptionContainer.setPreferredSize(new java.awt.Dimension(400, 300)); DescriptionText.setBackground(new java.awt.Color(0, 0, 0)); DescriptionText.setForeground(new java.awt.Color(240, 216, 130)); // text for description DescriptionText.setLineWrap(true); DescriptionText.setWrapStyleWord(true); DescriptionText.setPreferredSize(new java.awt.Dimension(400, 800)); DescriptionText.setAutoscrolls(false); DescriptionContainer.setViewportView(DescriptionText); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; getContentPane().add(DescriptionContainer, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 9; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; getContentPane().add(PadPanel, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; getContentPane().add(PadPanel2, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; getContentPane().add(PadPanel3, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; getContentPane().add(PadPanel4, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; getContentPane().add(jPanel16, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 7; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; getContentPane().add(jPanel17, gridBagConstraints); pack(); } // GEN-END:initComponents