// int jlabel3_state=0;
  public void mouseClicked(MouseEvent e) {
    JLabel source = (JLabel) e.getSource();
    if (label_state.get(source) == 0) {
      if (source.getName() == "jLabel11") {
        if (challenge_file == null) {
          JOptionPane.showMessageDialog(null, "Challenge File Not Loaded");
        } else {
          reset_labelState();
          active_label = (JLabel) source;
          label_state.put(source, 1);
          try {
            ImageIcon icon =
                new javax.swing.ImageIcon(getClass().getResource("resources/images/pause.jpg"));
            jLabel11.setIcon(icon);
          } catch (Exception et) {
            JOptionPane.showMessageDialog(null, et.toString());
          }
        }

      } else {
        reset_labelState();
        active_label = (JLabel) source;
        label_state.put(source, 1);
      }
      source.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLUE));
    } else {
      active_label = null;
      label_state.put(source, 0);
      if (source.getName() == "jLabel11") {
        try {
          ImageIcon icon =
              new javax.swing.ImageIcon(getClass().getResource("resources/images/play.jpg"));
          jLabel11.setIcon(icon);
        } catch (Exception et) {
          JOptionPane.showMessageDialog(null, et.toString());
        }
      }
      source.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, Color.BLUE));
    }
  }
  public void setGoal(File file) throws FileNotFoundException, IOException {
    FileInputStream fstream = new FileInputStream(file);
    // Get the object of DataInputStream
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    // Read File Line By Line
    strLine = br.readLine();
    input_count = Integer.valueOf(br.readLine());
    results = new String[input_count];
    tapes = new String[input_count];

    for (int i = 0; i < input_count; i++) {
      results[i] = br.readLine();
      tapes[i] = br.readLine();
    }
    jLabel1.setText(strLine);
    jLabel1.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK));
    br.close();
  }
예제 #3
0
파일: BoggleGUI.java 프로젝트: nv23/Boggle
    BoggleBoardPanel(int rows, int cols) {
      this.rows = rows;
      this.cols = cols;

      // create a JPanel with rowsXcols GridLayout to hold the DiePanels
      JPanel innerPanel = new JPanel();
      innerPanel.setLayout(new GridLayout(rows, cols, 1, 1));
      innerPanel.setBackground(BACKGROUNDCOLOR);

      // Create Individual DiePanels, and add them
      theDice = new DiePanel[rows][cols];
      for (int row = 0; row < rows; row++) {
        for (int col = 0; col < cols; col++) {
          theDice[row][col] = new DiePanel();

          innerPanel.add(theDice[row][col]);
        }
      }
      innerPanel.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, BACKGROUNDCOLOR));
      this.add(innerPanel);
    }
 public void reset_labelState() {
   for (int i = 2; i < 12; i++) {
     labels[i].setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, Color.BLUE));
     label_state.put(labels[i], 0);
   }
 }