コード例 #1
0
  public void setUpConnections() {
    // <Begin_setUpConnections>

    JButton2_JButton2_conn1 JButton2_JButton2_conn11 = new JButton2_JButton2_conn1();
    JButton2.addActionListener(JButton2_JButton2_conn11);
    JButton3_JButton3_conn1 JButton3_JButton3_conn11 = new JButton3_JButton3_conn1();
    JButton3.addActionListener(JButton3_JButton3_conn11);
    closeButton_closeButton_conn1 closeButton_closeButton_conn11 =
        new closeButton_closeButton_conn1();
    closeButton.addActionListener(closeButton_closeButton_conn11);
    JButton1_JButton1_conn1 JButton1_JButton1_conn11 = new JButton1_JButton1_conn1();
    JButton1.addActionListener(JButton1_JButton1_conn11);

    // <End_setUpConnections>
  }
コード例 #2
0
  public void setUpConnections() throws Exception {

    // <Begin_setUpConnections>

    nine_nine_conn1 nine_nine_conn11 = new nine_nine_conn1();
    nine.addMouseListener(nine_nine_conn11);
    six_six_conn1 six_six_conn11 = new six_six_conn1();
    six.addMouseListener(six_six_conn11);
    eight_eight_conn1 eight_eight_conn11 = new eight_eight_conn1();
    eight.addMouseListener(eight_eight_conn11);
    one_one_conn1 one_one_conn11 = new one_one_conn1();
    one.addMouseListener(one_one_conn11);
    four_four_conn1 four_four_conn11 = new four_four_conn1();
    four.addMouseListener(four_four_conn11);
    ten_ten_conn1 ten_ten_conn11 = new ten_ten_conn1();
    ten.addMouseListener(ten_ten_conn11);
    two_two_conn1 two_two_conn11 = new two_two_conn1();
    two.addMouseListener(two_two_conn11);
    three_three_conn2 three_three_conn21 = new three_three_conn2();
    three.addMouseListener(three_three_conn21);
    seven_seven_conn1 seven_seven_conn11 = new seven_seven_conn1();
    seven.addMouseListener(seven_seven_conn11);
    five_five_conn1 five_five_conn11 = new five_five_conn1();
    five.addMouseListener(five_five_conn11);
    RouterBtn_RouterBtn_conn2 RouterBtn_RouterBtn_conn21 = new RouterBtn_RouterBtn_conn2();
    RouterBtn.addMouseListener(RouterBtn_RouterBtn_conn21);
    CloseBtn_CloseBtn_conn1 CloseBtn_CloseBtn_conn11 = new CloseBtn_CloseBtn_conn1();
    CloseBtn.addActionListener(CloseBtn_CloseBtn_conn11);
    RouterBtn_RouterBtn_conn1 RouterBtn_RouterBtn_conn11 = new RouterBtn_RouterBtn_conn1();
    RouterBtn.addActionListener(RouterBtn_RouterBtn_conn11);
    // <End_setUpConnections>
    RefreshBtn.setActionCommand("refresh"); // No Internationalisation
    RefreshBtn.addActionListener(this);
    NmsClientUtil.centerWindow(this);
    addWindowListener(this);
  }
コード例 #3
0
ファイル: NumbrixGUI.java プロジェクト: rainerlg90/Numbrix
  public NumbrixGUI() throws ParseException { // Board gameBoard) throws ParseException{

    // Board
    this.gameBoard = new Board();

    // Container
    setTitle(TITLE);
    setSize(WIDTH, HEIGHT);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    // About Frame
    jFrameAbout = new javax.swing.JFrame();
    jFrameAbout.setResizable(false);
    jFrameAbout.setPreferredSize(new Dimension(500, 300));

    jTextAreaAbout = new javax.swing.JTextArea();
    jTextAreaAbout.setBackground(new java.awt.Color(240, 240, 240));
    jTextAreaAbout.setColumns(20);
    jTextAreaAbout.setRows(10);
    jTextAreaAbout.setText(
        "\t\tNumbrix Version 1\n\nClass Project for Artificial Intelligence course.\nUniversity of Florida\nCISE\n\n\n\n\nby Rainer Ledesma\nhttp://www.cise.ufl.edu/~rledesma/\n");
    jTextAreaAbout.setFont(new java.awt.Font("Agency FB", 1, 20)); // NOI18N
    jTextAreaAbout.setEditable(false);
    jTextAreaAbout.setPreferredSize(new Dimension(500, 300));

    javax.swing.GroupLayout jFrameAboutLayout =
        new javax.swing.GroupLayout(jFrameAbout.getContentPane());
    jFrameAbout.getContentPane().setLayout(jFrameAboutLayout);
    jFrameAboutLayout.setHorizontalGroup(
        jFrameAboutLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jFrameAboutLayout
                    .createSequentialGroup()
                    .addGap(11, 11, 11)
                    .addComponent(
                        jTextAreaAbout,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    jFrameAboutLayout.setVerticalGroup(
        jFrameAboutLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jFrameAboutLayout
                    .createSequentialGroup()
                    .addGap(0, 16, Short.MAX_VALUE)
                    .addComponent(
                        jTextAreaAbout,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        267,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 17, Short.MAX_VALUE)));
    //

    // Instructions Frame
    jFrameInstructions = new javax.swing.JFrame();
    jFrameInstructions.setResizable(false);
    jFrameInstructions.setPreferredSize(new Dimension(500, 300));

    jTextAreaInstructions = new javax.swing.JTextArea();
    jTextAreaInstructions.setBackground(new java.awt.Color(240, 240, 240));
    jTextAreaInstructions.setColumns(20);
    jTextAreaInstructions.setRows(10);
    jTextAreaInstructions.setText(
        "\t\tNumbrix\n"
            + "The object of Numbrix is to fill the board with sequence of consecutive \n"
            + "numbers from 1 to the maximun cell count. The numbers must fillow a \n"
            + "horizontal or vertical path (no diagonals)\n");
    jTextAreaInstructions.setFont(new java.awt.Font("Agency FB", 1, 20)); // NOI18N
    jTextAreaInstructions.setEditable(false);
    jTextAreaInstructions.setPreferredSize(new Dimension(500, 300));

    javax.swing.GroupLayout jFrameInstructionsLayout =
        new javax.swing.GroupLayout(jFrameInstructions.getContentPane());
    jFrameInstructions.getContentPane().setLayout(jFrameInstructionsLayout);
    jFrameInstructionsLayout.setHorizontalGroup(
        jFrameInstructionsLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jFrameInstructionsLayout
                    .createSequentialGroup()
                    .addGap(11, 11, 11)
                    .addComponent(
                        jTextAreaInstructions,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    jFrameInstructionsLayout.setVerticalGroup(
        jFrameInstructionsLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jFrameInstructionsLayout
                    .createSequentialGroup()
                    .addGap(0, 16, Short.MAX_VALUE)
                    .addComponent(
                        jTextAreaInstructions,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        267,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 17, Short.MAX_VALUE)));
    //

    // File Chooser
    jFrameFileChooser = new javax.swing.JFrame();
    jFileChooser = new javax.swing.JFileChooser();
    jFileChooser.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            try {
              jFileChooserActionPerformed(evt);
            } catch (Exception ex) {
              JOptionPane.showMessageDialog(frame, "File Exception");
            }
          }
        });

    javax.swing.GroupLayout jFrameFileChooserLayout =
        new javax.swing.GroupLayout(jFrameFileChooser.getContentPane());
    jFrameFileChooser.getContentPane().setLayout(jFrameFileChooserLayout);
    jFrameFileChooserLayout.setHorizontalGroup(
        jFrameFileChooserLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 618, Short.MAX_VALUE)
            .addGroup(
                jFrameFileChooserLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(
                        jFrameFileChooserLayout
                            .createSequentialGroup()
                            .addGap(18, 18, 18)
                            .addComponent(
                                jFileChooser,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addGap(18, 18, 18))));
    jFrameFileChooserLayout.setVerticalGroup(
        jFrameFileChooserLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 456, Short.MAX_VALUE)
            .addGroup(
                jFrameFileChooserLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(
                        jFrameFileChooserLayout
                            .createSequentialGroup()
                            .addGap(27, 27, 27)
                            .addComponent(
                                jFileChooser,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addGap(32, 32, 32))));
    //

    // SidePanel
    jPanelSideBar = new javax.swing.JPanel();
    jButtonRESET = new javax.swing.JButton();
    jButtonSOLVE = new javax.swing.JButton();
    jButtonNEWGAME = new javax.swing.JButton();
    jLabelTIMER = new javax.swing.JLabel();
    jButtonPAUSE = new javax.swing.JButton();

    jButtonRESET.setText("RESET");
    jButtonRESET.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonRESETActionPerformed(evt);
          }
        });
    jButtonSOLVE.setText("SOLVE");
    jButtonSOLVE.setEnabled(false);
    jButtonSOLVE.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            try {
              jButtonSOLVEActionPerformed(evt);
            } catch (IOException ex) {
              Logger.getLogger(NumbrixGUI.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });
    jButtonNEWGAME.setText("NEW GAME");
    jButtonNEWGAME.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonNEWGAMEActionPerformed(evt);
          }
        });
    jLabelTIMER.setText("TIMER");
    jLabelTIMER.setFont(new java.awt.Font("Agency FB", 1, 18));
    jButtonPAUSE.setText("PAUSE");
    jButtonPAUSE.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonPAUSEActionPerformed(evt);
          }
        });
    jLabelClock = new javax.swing.JLabel();
    jLabelClock.setFont(new java.awt.Font("Agency FB", 1, 24)); // NOI18N
    jLabelClock.setText("10 : 99 : 60");

    javax.swing.GroupLayout jPanelSideBarLayout = new javax.swing.GroupLayout(jPanelSideBar);
    jPanelSideBar.setLayout(jPanelSideBarLayout);
    jPanelSideBarLayout.setHorizontalGroup(
        jPanelSideBarLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanelSideBarLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        jPanelSideBarLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                jButtonRESET,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                jButtonSOLVE,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                jButtonNEWGAME,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                136,
                                Short.MAX_VALUE)
                            .addComponent(
                                jButtonPAUSE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addGroup(
                                jPanelSideBarLayout
                                    .createSequentialGroup()
                                    .addGroup(
                                        jPanelSideBarLayout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabelTIMER)
                                            .addComponent(
                                                jLabelClock,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                97,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(0, 0, Short.MAX_VALUE)))
                    .addContainerGap()));
    jPanelSideBarLayout.setVerticalGroup(
        jPanelSideBarLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                jPanelSideBarLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabelTIMER)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        jLabelClock,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        32,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jButtonPAUSE)
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED, 229, Short.MAX_VALUE)
                    .addComponent(jButtonNEWGAME)
                    .addGap(18, 18, 18)
                    .addComponent(jButtonRESET)
                    .addGap(18, 18, 18)
                    .addComponent(jButtonSOLVE)
                    .addContainerGap()));
    ////////

    // Menu
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItemNewGame = new javax.swing.JMenuItem();
    jMenuItemExit = new javax.swing.JMenuItem();
    jMenu2 = new javax.swing.JMenu();
    jMenuItemInstructions = new javax.swing.JMenuItem();
    jMenuItemAbout = new javax.swing.JMenuItem();

    jMenu1.setText("File");
    jMenu2.setText("Edit");

    jMenuItemNewGame.setText("New Game");
    jMenuItemExit.setText("Exit");
    jMenuItemInstructions.setText("Instructions");
    jMenuItemAbout.setText("About Numbrix");

    jMenuBar1.add(jMenu1);
    jMenuBar1.add(jMenu2);
    jMenu1.add(jMenuItemNewGame);
    jMenu1.add(jMenuItemExit);
    jMenu2.add(jMenuItemInstructions);
    jMenu2.add(jMenuItemAbout);

    setJMenuBar(jMenuBar1);

    jMenuItemNewGame.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemNewGameActionPerformed(evt);
          }
        });
    jMenuItemExit.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemExitActionPerformed(evt);
          }
        });
    jMenuItemInstructions.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemInstructionsActionPerformed(evt);
          }
        });
    jMenuItemAbout.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemAboutActionPerformed(evt);
          }
        });
    //

    // SolvedBoardPanel
    jPanelSolvedBoard = new javax.swing.JPanel();
    jPanelSolvedBoard.setBackground(new java.awt.Color(255, 255, 255));

    // Solved Board Frame
    jFrameSolvedBoard = new javax.swing.JFrame();
    jFrameSolvedBoard.setTitle("Numbrix Solution");
    javax.swing.GroupLayout jFrameSolvedBoardLayout =
        new javax.swing.GroupLayout(jFrameSolvedBoard.getContentPane());
    jFrameSolvedBoard.getContentPane().setLayout(jFrameSolvedBoardLayout);
    jFrameSolvedBoardLayout.setHorizontalGroup(
        jFrameSolvedBoardLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
            .addGroup(
                jFrameSolvedBoardLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(
                        jPanelSolvedBoard,
                        javax.swing.GroupLayout.Alignment.TRAILING,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        400,
                        Short.MAX_VALUE)));
    jFrameSolvedBoardLayout.setVerticalGroup(
        jFrameSolvedBoardLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
            .addGroup(
                jFrameSolvedBoardLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(
                        jPanelSolvedBoard,
                        javax.swing.GroupLayout.Alignment.TRAILING,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        300,
                        Short.MAX_VALUE)));

    // BoardPanel
    boardPanel = new javax.swing.JPanel();
    boardPanel.setBackground(new java.awt.Color(255, 255, 255));
    // Clock
    gameTimer = new GameTimer(jLabelClock);
    this.gameTimer.start();
    this.gameTimer.run();

    // Initialize
    // init();

    // Container Layout
    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()
                    .addContainerGap()
                    .addComponent(
                        boardPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE)
                    .addGap(18, 18, 18)
                    .addComponent(
                        jPanelSideBar,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(
                                boardPanel,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                jPanelSideBar,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addContainerGap()));
  }