Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package oregon;
- /**
- *
- * @author wayne
- */
- import javax.swing.JOptionPane;
- public class GameJFrame extends javax.swing.JFrame {
- /**
- * Creates new form GameJFrame
- */
- public GameJFrame() {
- initComponents();
- WagonMember member1 = new WagonMember();
- member1.setName(JOptionPane.showInputDialog(this, "What is the first traveler's name?"));
- WagonMember member2 = new WagonMember();
- member2.setName(JOptionPane.showInputDialog(this, "What is the second traveler's name?"));
- WagonMember member3 = new WagonMember();
- member3.setName(JOptionPane.showInputDialog(this, "What is the third traveler's name?"));
- WagonMember member4 = new WagonMember();
- member4.setName(JOptionPane.showInputDialog(this, "What is the fourth traveler's name?"));
- WagonMember member5 = new WagonMember();
- member5.setName(JOptionPane.showInputDialog(this, "What is the fifth traveler's name?"));
- City independence = new City("Independence", 102);
- River kansas = new River("Kansas", 82);
- River bigBlue = new River("Big Blue River", 118);
- Fort kearney = new Fort("Fort Kearney", 86);
- Landmark chimneyRock = new Landmark("Chimney Rock", 86);
- Fort laramie = new Fort("Fort Laramie", 190);
- Landmark independenceRock = new Landmark("Independence Rock", 102);
- Landmark southPass = new Landmark("South Pass", 57, 125);
- River green = new River("Green River", 143);
- Fort bridger = new Fort("Fort Bridger", 162);
- Landmark sodaSprings = new Landmark("Soda Springs", 57);
- Fort hall = new Fort("Fort Hall", 182);
- River snake = new River("Snake River", 113);
- Fort boise = new Fort("Fort Boise", 160);
- Landmark blueMountains = new Landmark("Blue Mountains", 55, 125);
- Fort wallaWalla = new Fort("Fort Walla Walla", 120);
- Landmark dalles = new Landmark("The Dalles", 100);
- kansas.setWidth(620);
- kansas.setDepth(4);
- bigBlue.setWidth(300);
- bigBlue.setDepth(6);
- green.setWidth(400);
- green.setDepth(20);
- snake.setWidth(1000);
- snake.setDepth(7);
- Object[] locations = new Object[] {
- independence,
- kansas,
- bigBlue,
- kearney,
- chimneyRock,
- laramie,
- independenceRock,
- southPass,
- green,
- bridger,
- sodaSprings,
- hall,
- snake,
- boise,
- blueMountains,
- wallaWalla,
- dalles
- };
- }
- /**
- * 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.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- locationLabel = new javax.swing.JLabel();
- toNextLabel = new javax.swing.JLabel();
- healthLabel = new javax.swing.JLabel();
- traveledLabel = new javax.swing.JLabel();
- foodLabel = new javax.swing.JLabel();
- dateLabel = new javax.swing.JLabel();
- evaluateButton = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- locationLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
- locationLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- locationLabel.setText("LocationLabel");
- locationLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
- toNextLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
- toNextLabel.setText("Miles to next Landmark:");
- healthLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
- healthLabel.setText("Health:");
- traveledLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
- traveledLabel.setText("Miles Traveled:");
- foodLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
- foodLabel.setText("Food Left:");
- dateLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
- dateLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- dateLabel.setText("Date:");
- dateLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
- evaluateButton.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
- evaluateButton.setText("Evaluate Situation");
- evaluateButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- evaluateButtonActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGap(115, 115, 115)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(toNextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)
- .addComponent(healthLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 146, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(traveledLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 384, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(foodLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 384, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(185, 185, 185))
- .addGroup(layout.createSequentialGroup()
- .addGap(431, 431, 431)
- .addComponent(evaluateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGap(386, 386, 386)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(6, 6, 6)
- .addComponent(dateLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 373, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(locationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 357, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(0, 0, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(45, 45, 45)
- .addComponent(locationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(5, 5, 5)
- .addComponent(dateLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(toNextLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(healthLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 345, Short.MAX_VALUE)
- .addComponent(evaluateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(38, 38, 38))
- .addGroup(layout.createSequentialGroup()
- .addComponent(traveledLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(foodLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
- );
- pack();
- }// </editor-fold>
- private void evaluateButtonActionPerformed(java.awt.event.ActionEvent evt) {
- String s = locations[0].getName();ca
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(GameJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(GameJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(GameJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(GameJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new GameJFrame().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JLabel dateLabel;
- private javax.swing.JButton evaluateButton;
- private javax.swing.JLabel foodLabel;
- private javax.swing.JLabel healthLabel;
- private javax.swing.JLabel locationLabel;
- private javax.swing.JLabel toNextLabel;
- private javax.swing.JLabel traveledLabel;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement