Esempio n. 1
0
 /** Handles the key press event. */
 private void handleKeyPress(String key) {
   if (key.equals("enter")) {
     handleStartGame();
   } else {
     passwordInputLabel.handleKeyPress(key);
     if (passwordInputLabel.wasTextChanged()) {
       String password = passwordInputLabel.getText();
       if (password.length() > 0) {
         checkPassword(password);
       }
     }
   }
 }
Esempio n. 2
0
  /** Initializes the screen. */
  public void initScreen() {
    gameScreen.setCurrentLevelNumber(1); // reset level

    gameScreen.setBackground("start_screen.png");

    startGameButton = new Button("Start Game", 130, 30, GameScreen.FONT_M);
    startGameButton.setBorderColor(Color.RED);
    startGameButton.setIcon(GameScreen.ICON_START);
    startGameButton.setBackgroundColor(new Color(255, 205, 205));
    gameScreen.addObject(startGameButton, GameScreen.WIDTH_IN_CELLS / 2, 10);

    if (MyKara.HIGHSCORE_ENABLED) {
      highscoreButton = new Button("Highscore", 130, 30, GameScreen.FONT_M);
      highscoreButton.setBorderColor(Color.RED);
      highscoreButton.setIcon(GameScreen.ICON_HIGHSCORE);
      highscoreButton.setBackgroundColor(new Color(255, 205, 205));
      gameScreen.addObject(highscoreButton, GameScreen.WIDTH_IN_CELLS / 2, 12);
    }

    Label enterPasswordLabel =
        new Label("Enter Level Password With Keyboard:", 230, 21, GameScreen.FONT_S);
    enterPasswordLabel.setBackgroundColor(Color.BLACK);
    enterPasswordLabel.setTextColor(new Color(255, 205, 205));
    gameScreen.addObject(enterPasswordLabel, GameScreen.WIDTH_IN_CELLS / 2, 14);

    passwordInputLabel = new InputLabel("", 180, 21, GameScreen.FONT_M);
    passwordInputLabel.setBorderColor(null);
    passwordInputLabel.setBackgroundColor(new Color(255, 205, 205));
    // passwordInputLabel.setMaxLength(10);
    gameScreen.addObject(passwordInputLabel, GameScreen.WIDTH_IN_CELLS / 2, 15);

    passwordOkLabel = new Label(95, 24, GameScreen.ICON_LOCKED);
    passwordOkLabel.setBackgroundTransparency(0);
    passwordOkLabel.setTextColor(new Color(255, 205, 205));
    passwordOkLabel.setFont(GameScreen.FONT_S);
    passwordOkLabel.setIconVisible(true);
    passwordOkLabel.setAlign(Label.ALIGN_LEFT);
    gameScreen.addObject(passwordOkLabel, GameScreen.WIDTH_IN_CELLS / 2 + 5, 15);
  }
  /**
   * 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">//GEN-BEGIN:initComponents
  private void initComponents() {

    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    AuthorLabel = new javax.swing.JLabel();
    InputDataField = new javax.swing.JTextField();
    ConversionButton = new javax.swing.JButton();
    OutputDataField = new javax.swing.JTextField();
    InputLabel = new javax.swing.JLabel();
    OutputLabel = new javax.swing.JLabel();

    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    jScrollPane1.setViewportView(jTextArea1);

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Conversor de Temperatura");
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    setResizable(false);

    AuthorLabel.setText(" Héctor Garbisu DiU 2015");

    InputDataField.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            InputDataFieldActionPerformed(evt);
          }
        });

    ConversionButton.setText("Convertir");
    ConversionButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            ConversionButtonActionPerformed(evt);
          }
        });

    InputLabel.setText("Temperatura (Celsius)");

    OutputLabel.setText("Temperatura (Fahrenheit))");

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(AuthorLabel)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addComponent(
                                                        InputDataField,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        141,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement
                                                            .RELATED)
                                                    .addComponent(ConversionButton))
                                            .addComponent(InputLabel))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(OutputLabel)
                                            .addComponent(
                                                OutputDataField,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                140,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout
                    .createSequentialGroup()
                    .addContainerGap(34, Short.MAX_VALUE)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(InputLabel, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(OutputLabel, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                InputDataField,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ConversionButton)
                            .addComponent(
                                OutputDataField,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(29, 29, 29)
                    .addComponent(AuthorLabel)
                    .addContainerGap()));

    pack();
  } // </editor-fold>//GEN-END:initComponents