// Initialize Board public void init() { // Create cells and handlers cells = new JTextField[gameBoard.boardSize * gameBoard.boardSize + 1]; // Redraw Panel boardPanel.removeAll(); boardPanel.setLayout(new GridLayout(gameBoard.boardSize, gameBoard.boardSize)); // Set layout JTextFilter TextFilter = new JTextFilter(3); JTextDocumentListener JTextDocFilter = new JTextDocumentListener(); for (int i = 1; i <= gameBoard.boardSize * gameBoard.boardSize; i++) { cells[i] = new JTextField(); ((AbstractDocument) cells[i].getDocument()).setDocumentFilter(TextFilter); ((AbstractDocument) cells[i].getDocument()).addDocumentListener(JTextDocFilter); ((AbstractDocument) cells[i].getDocument()).putProperty("index", i); cells[i].setHorizontalAlignment(JTextField.CENTER); cells[i].setFont(new Font("Agency FB", Font.BOLD, 24)); // Add elements to the grid content pane boardPanel.add(cells[i]); } // Initialize booleans gameOver = false; // Clear Board for (int i = 1; i <= (gameBoard.boardSize * gameBoard.boardSize); i++) { String ch = Integer.toString(this.gameBoard.cells[i]); char chr = '-'; if (ch.compareTo("0") == 0 || ch == Character.toString(chr)) { cells[i].setText(""); } else { cells[i].setText(ch); cells[i].setBackground(Color.lightGray); } } // gameBoard.out(); setVisible(true); this.boardPanel.repaint(); this.gameTimer.reset(); jButtonSOLVE.setEnabled(true); }
/** Initializes this dialog properly */ private void completeInitialization() { // title of archives list jPanel1.setBorder( new javax.swing.border.TitledBorder( new javax.swing.border.EtchedBorder(), NbBundle.getBundle(HistoryModel.class).getString("CTL_Archives"))); historyData = JarPackagerOption.singleton().historyData(); historyList.setModel(historyData); updateControlStates(); // testing JarContent jc = new JarContent(); jc.filteredContent(); }
public void setUpProperties() { // <Begin_setUpProperties> // <UserCode_Begin_Bean_Top> // this.setModal(true); setResizable(false); // <UserCode_End_Bean_Top> try { JTable1.setRowHeight(22); JTable1.setModel(ViewTableModel); JTable1.setGridColor(new Color(-1)); } catch (Exception ex) { showStatus( resourceBundle.getString("Exception while setting properties for bean ") + JTable1, ex); } // <UserCode_Begin_Bean_JTable1> // <UserCode_End_Bean_JTable1> try { JPanel3.setBorder(new javax.swing.border.TitledBorder(resourceBundle.getString(""))); } catch (Exception ex) { showStatus( resourceBundle.getString("Exception while setting properties for bean ") + JPanel3, ex); } // <UserCode_Begin_Bean_JPanel3> // <UserCode_End_Bean_JPanel3> try { JButton1.setFont(new Font("Dialog", 0, 12)); JButton1.setText(resourceBundle.getString("Add")); } catch (Exception ex) { showStatus( resourceBundle.getString("Exception while setting properties for bean ") + JButton1, ex); } // <UserCode_Begin_Bean_JButton1> JButton1.setMnemonic('A'); // <UserCode_End_Bean_JButton1> try { JButton2.setFont(new Font("Dialog", 0, 13)); JButton2.setText(resourceBundle.getString("Edit")); } catch (Exception ex) { showStatus( resourceBundle.getString("Exception while setting properties for bean ") + JButton2, ex); } // <UserCode_Begin_Bean_JButton2> JButton2.setMnemonic('E'); // <UserCode_End_Bean_JButton2> try { JButton3.setFont(new Font("Dialog", 0, 13)); JButton3.setText(resourceBundle.getString("Delete")); } catch (Exception ex) { showStatus( resourceBundle.getString("Exception while setting properties for bean ") + JButton3, ex); } // <UserCode_Begin_Bean_JButton3> JButton3.setMnemonic('D'); // <UserCode_End_Bean_JButton3> try { closeButton.setFont(new Font("Dialog", 0, 13)); closeButton.setText(resourceBundle.getString("Close")); } catch (Exception ex) { showStatus( resourceBundle.getString("Exception while setting properties for bean ") + closeButton, ex); } // <UserCode_Begin_Bean_closeButton> // <UserCode_End_Bean_closeButton> // <UserCode_Begin_Bean_JPanel5> // JPanel5.setVisible(false); // <UserCode_End_Bean_JPanel5> try { JLabel1.setFont(new Font("Dialog", 0, 12)); JLabel1.setForeground(new Color(-16764109)); JLabel1.setText( resourceBundle.getString( "Use the following list to add , edit a View , its Properties and authorized Operations")); } catch (Exception ex) { showStatus( resourceBundle.getString("Exception while setting properties for bean ") + JLabel1, ex); } // <UserCode_Begin_Bean_JLabel1> // <UserCode_End_Bean_JLabel1> // <UserCode_Begin_Bean_ViewTableModel> ViewTableModel.setDataVector( new Object[0][0], new String[] {resourceBundle.getString("Views List")}); // <UserCode_End_Bean_ViewTableModel> JPanel5.setPreferredSize( new Dimension( JPanel5.getPreferredSize().width + 22, JPanel5.getPreferredSize().height + 38)); closeButton.setPreferredSize( new Dimension( closeButton.getPreferredSize().width + 8, closeButton.getPreferredSize().height + 0)); JButton3.setPreferredSize( new Dimension( JButton3.getPreferredSize().width + 32, JButton3.getPreferredSize().height + 0)); JButton2.setPreferredSize( new Dimension( JButton2.getPreferredSize().width + 45, JButton2.getPreferredSize().height + 0)); JButton1.setPreferredSize( new Dimension( JButton1.getPreferredSize().width + 47, JButton1.getPreferredSize().height + 2)); JPanel2.setPreferredSize( new Dimension( JPanel2.getPreferredSize().width + 10, JPanel2.getPreferredSize().height + 26)); JLabel2.setPreferredSize( new Dimension( JLabel2.getPreferredSize().width + 124, JLabel2.getPreferredSize().height + 72)); JPanel6.setPreferredSize( new Dimension( JPanel6.getPreferredSize().width + 10, JPanel6.getPreferredSize().height + 114)); JPanel1.setPreferredSize( new Dimension( JPanel1.getPreferredSize().width + 39, JPanel1.getPreferredSize().height + 38)); // <End_setUpProperties> JPanel1.setBorder( new javax.swing.border.TitledBorder(resourceBundle.getString("View Settings"))); JPanel5.setBorder( new javax.swing.border.TitledBorder( resourceBundle.getString("Views Properties and Operations"))); }
public void setUpGUI(Container container) { // <Begin_setUpGUI_Container> container.add(Top, BorderLayout.CENTER); Top.setLayout(new BorderLayout(5, 5)); Top.add(JPanel1, BorderLayout.CENTER); JPanel1.setLayout(new BorderLayout(5, 5)); JPanel1.add(JScrollPane1, BorderLayout.CENTER); JScrollPane1.getViewport().add(JTable1); JPanel1.add(JPanel6, BorderLayout.WEST); JPanel6.setLayout(new BorderLayout(5, 5)); JPanel6.add(JLabel2, BorderLayout.CENTER); Top.add(JPanel2, BorderLayout.SOUTH); JPanel2.setLayout(new GridLayout(1, 1, 5, 5)); JPanel2.add(JPanel3); JPanel3.setLayout(new FlowLayout(2, 5, 5)); JPanel3.add(JButton1); JPanel3.add(JButton2); JPanel3.add(JButton3); JPanel3.add(closeButton); Top.add(JPanel5, BorderLayout.NORTH); JPanel5.setLayout(new GridLayout(2, 1, 5, 5)); JPanel5.add(JLabel1); // <End_setUpGUI_Container> }
public static void processBrRequisitionFile( java.io.File filePortrait2Process, biz.systempartners.claims.ClaimsViewer claimsViewer, java.util.Vector invoiceVector, java.util.Vector filesVector) { biz.systempartners.claims.XMLClaimFile xmlClaimFile = new biz.systempartners.claims.XMLClaimFile(); xmlClaimFile.processFile(filePortrait2Process); javax.swing.JTable tempInvoiceTable; java.util.Vector headerInvoiceVector = new java.util.Vector(1, 1); headerInvoiceVector.addElement("Invoice No."); // claimsTable = new javax.swing.JTable(5,4); // claimsTable = claimsViewer.getInvoiceTable(); claimsTable = xmlClaimFile.xmlClaim.getInvoiceTable(); invoiceTable = claimsViewer.getInvoiceListTable(); javax.swing.JPanel claimsViewerPanel = claimsViewer.getClaimsViewerPanel(); javax.swing.JScrollPane jScrollPane11 = claimsViewer.getScrollPane(); javax.swing.JScrollPane invoiceScrollPane = claimsViewer.getInvoiceListScrollPane(); invoiceVector = claimsViewer.getInvoiceVector(); java.util.Vector invoiceChildVector = new java.util.Vector(1, 1); javax.swing.JTextField patientNo = claimsViewer.getPatientNo(); javax.swing.JTextField patientName = claimsViewer.getPatientName(); javax.swing.JTextField schemeMemberNo = claimsViewer.getSchemeMemberNo(); javax.swing.JTextField schemeName = claimsViewer.getSchemeName(); javax.swing.JTextField schemePayer = claimsViewer.getSchemePayer(); javax.swing.JTextField accountNo = claimsViewer.getAccountNo(); javax.swing.JTextField invoiceNo = claimsViewer.getInvoiceNo(); javax.swing.JTextField healthCareProvider = claimsViewer.getHealthCareProvider(); jScrollPane11.setViewportView(claimsTable); if (claimsViewer.isShowing()) { claimsViewer.validate(); } else { claimsViewer.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH); claimsViewer.setVisible(true); } claimsViewer.invalidate(); // try { // try { // java.io.FileInputStream requisFileIOStream = new // java.io.FileInputStream(filePortrait2Process); // java.io.ObjectInputStream requisObjInStream = new // java.io.ObjectInputStream(requisFileIOStream); // javax.swing.table.JTableHeader claimsTableHeader = // (javax.swing.table.JTableHeader)requisObjInStream.readObject(); // requisTable = (javax.swing.JTable)requisObjInStream.readObject(); // String invoiceNoString = (java.lang.String)requisObjInStream.readObject(); String invoiceNoString = xmlClaimFile.xmlClaim.getInvoiceNumber(); invoiceNo.setText(invoiceNoString); // patientNo.setText((java.lang.String)requisObjInStream.readObject()); patientNo.setText(xmlClaimFile.xmlClaim.getPatientNumber()); System.out.println( "PATIENT NUMBER : " + xmlClaimFile.xmlClaim.getPatientNumber() + " " + xmlClaimFile.xmlClaim.getPatientName() + " " + xmlClaimFile.xmlClaim.getSchemeName()); // patientName.setText((java.lang.String)requisObjInStream.readObject()); patientName.setText(xmlClaimFile.xmlClaim.getPatientName()); // schemeMemberNo.setText((java.lang.String)requisObjInStream.readObject()); schemeMemberNo.setText(xmlClaimFile.xmlClaim.getSchemeMemberNumber()); // schemeName.setText((java.lang.String)requisObjInStream.readObject()); schemeName.setText(xmlClaimFile.xmlClaim.getSchemeName()); // schemePayer.setText((java.lang.String)requisObjInStream.readObject()); schemePayer.setText(xmlClaimFile.xmlClaim.getSchemePayer()); // accountNo.setText((java.lang.String)requisObjInStream.readObject()); accountNo.setText(xmlClaimFile.xmlClaim.getAccountNumber()); healthCareProvider.setText(xmlClaimFile.xmlClaim.getHealthCareProvider()); tempInvoiceTable = new javax.swing.JTable(invoiceVector, headerInvoiceVector); invoiceChildVector.add(invoiceNoString); invoiceChildVector.add(filePortrait2Process.getPath()); if (filesVector == null) { filesVector = new java.util.Vector(1, 1); } filesVector.add(filePortrait2Process.getAbsolutePath()); claimsViewer.filesVector = filesVector; if (invoiceVector == null) { invoiceVector = new java.util.Vector(1, 1); } invoiceVector.add(invoiceChildVector); /* invoiceNo.setText(invoiceNoString); invoiceChildVector.add(invoiceNoString); invoiceChildVector.add(filePortrait2Process.getPath()); filesVector.add(filePortrait2Process.getAbsolutePath()); // System.out.println("Child Cector Size ="+invoiceChildVector.size()); // System.out.println("File saved in child vector ="+filePortrait2Process.getPath()); invoiceVector.add(invoiceChildVector); // for (int j = 0; j < invoiceChildVector.capacity(); j++) { // System.out.println("Child entry ["+invoiceChildVector.elementAt(j)+"]"); // } patientNo.setText((java.lang.String)requisObjInStream.readObject()); patientName.setText((java.lang.String)requisObjInStream.readObject()); schemeMemberNo.setText((java.lang.String)requisObjInStream.readObject()); schemeName.setText((java.lang.String)requisObjInStream.readObject()); schemePayer.setText((java.lang.String)requisObjInStream.readObject()); accountNo.setText((java.lang.String)requisObjInStream.readObject()); */ tempInvoiceTable = new javax.swing.JTable(invoiceVector, headerInvoiceVector); System.out.println("Starting to populate tables ..."); /** * for (int i = 0; i < requisTable.getModel().getRowCount(); i++) { * * <p>for (int j = 0; j < requisTable.getModel().getColumnCount(); j++){ * * <p>if (requisTable.getValueAt(i,0) != null) { * * <p>claimsTable.setValueAt(requisTable.getValueAt(i,j), i, j); * * <p>System.out.println(requisTable.getValueAt(i,j)); } } } */ for (int i = 0; i < tempInvoiceTable.getModel().getRowCount(); i++) { for (int j = 0; j < tempInvoiceTable.getModel().getColumnCount(); j++) { if (tempInvoiceTable.getValueAt(i, 0) != null) { invoiceTable.setValueAt(tempInvoiceTable.getValueAt(i, j), i, j); System.out.println("Invoices : " + tempInvoiceTable.getValueAt(i, j)); System.out.println(tempInvoiceTable.getValueAt(i, j)); } } } // claimsTable.setModel(requisTable.getModel()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 100.0; claimsViewerPanel.removeAll(); claimsViewerPanel.add(jScrollPane11, gridBagConstraints); invoiceScrollPane.setViewportView(invoiceTable); jScrollPane11.setViewportView(claimsTable); claimsViewerPanel.validate(); for (int i = 0; i < invoiceVector.size(); i++) { java.util.Vector childVector = (java.util.Vector) invoiceVector.elementAt(i); for (int j = 0; j < childVector.size(); j++) { // System.out.println("Child entry at ---- !!! ["+j+"] is // ["+childVector.elementAt(j)+"]"); File file2SelectedInvoice; file2SelectedInvoice = new java.io.File(childVector.elementAt(j).toString()); System.out.println("Selected File ---- !!!!! [" + file2SelectedInvoice.getPath() + "]"); } // for (int j = 0; j < childVector.size(); j++) { // if (childVector.elementAt(0).toString().equalsIgnoreCase(invoiceNo)) { // } // } } // } catch(java.lang.ClassNotFoundException cnfExec) { // javax.swing.JOptionPane.showMessageDialog(new java.awt.Frame(), cnfExec.getMessage()); // } // } catch(java.io.IOException ioExec) { // javax.swing.JOptionPane.showMessageDialog(new java.awt.Frame(), ioExec.getMessage()); // } }
public void setUpProperties() throws Exception { // <Begin_setUpProperties> try { Top.setBackground(new Color(-1)); } catch (Exception ex) { showStatus(NmsClientUtil.GetString("Exception while setting properties for bean ") + Top, ex); } setResizable(false); try { JPanel1.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + JPanel1, ex); } try { RouterBtn.setFocusPainted(false); RouterBtn.setIcon( NmsClientUtil.getImageIcon( applet.getDocumentBase() + "../images/router_new1.png")); // No Internationalisation RouterBtn.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + RouterBtn, ex); } try { eight.setOpaque(true); eight.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + eight, ex); } eight.setVisible(false); try { one.setOpaque(true); one.setToolTipText(""); // No Internationalisation one.setBackground(new Color(-1)); } catch (Exception ex) { showStatus(NmsClientUtil.GetString("Exception while setting properties for bean ") + one, ex); } one.setVisible(false); try { six.setBackground(new Color(-1)); } catch (Exception ex) { showStatus(NmsClientUtil.GetString("Exception while setting properties for bean ") + six, ex); } six.setVisible(false); try { three.setOpaque(true); three.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + three, ex); } three.setVisible(false); try { four.setOpaque(true); four.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + four, ex); } four.setVisible(false); try { seven.setOpaque(true); seven.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + seven, ex); } seven.setVisible(false); try { two.setBackground(new Color(-1)); } catch (Exception ex) { showStatus(NmsClientUtil.GetString("Exception while setting properties for bean ") + two, ex); } two.setVisible(false); try { ten.setBackground(new Color(-1)); } catch (Exception ex) { showStatus(NmsClientUtil.GetString("Exception while setting properties for bean ") + ten, ex); } ten.setVisible(false); try { five.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + five, ex); } five.setVisible(false); try { nine.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + nine, ex); } nine.setVisible(false); try { JPanel2.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + JPanel2, ex); } try { JPanel3.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + JPanel3, ex); } try { JLabel1.setBackground(new Color(-1)); JLabel1.setHorizontalTextPosition(0); JLabel1.setHorizontalAlignment(0); JLabel1.setText(NmsClientUtil.GetString("Router details")); JLabel1.setFont(new Font("Dialog", 1, 14)); // No Internationalisation } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + JLabel1, ex); } try { JPanel4.setBackground(new Color(-1)); java.lang.String[] JPanel4cardAndClassNames_array = new java.lang.String[2]; JPanel4cardAndClassNames_array[0] = "router=com.adventnet.nms.examples.routermap.RouterDetails"; // No Internationalisation JPanel4cardAndClassNames_array[1] = "inter=com.adventnet.nms.examples.routermap.IFDetails"; // No Internationalisation JPanel4.setCardAndClassNames(JPanel4cardAndClassNames_array); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + JPanel4, ex); } try { JPanel5.setBackground(new Color(-1)); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + JPanel5, ex); } try { RefreshBtn.setText(NmsClientUtil.GetString("Refresh")); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + RefreshBtn, ex); } try { CloseBtn.setText(NmsClientUtil.GetString("Close")); } catch (Exception ex) { showStatus( NmsClientUtil.GetString("Exception while setting properties for bean ") + CloseBtn, ex); } CloseBtn.setPreferredSize( new Dimension( CloseBtn.getPreferredSize().width + 12, CloseBtn.getPreferredSize().height + 0)); JPanel5.setPreferredSize( new Dimension( JPanel5.getPreferredSize().width + 229, JPanel5.getPreferredSize().height + 4)); JPanel4.setPreferredSize( new Dimension( JPanel4.getPreferredSize().width + 507, JPanel4.getPreferredSize().height + 293)); JLabel1.setPreferredSize( new Dimension( JLabel1.getPreferredSize().width + 132, JLabel1.getPreferredSize().height + 8)); JPanel3.setPreferredSize( new Dimension( JPanel3.getPreferredSize().width + 168, JPanel3.getPreferredSize().height + 6)); // <End_setUpProperties> }
public void setUpGUI(Container container) throws Exception { // <Begin_setUpGUI_Container> container.add(Top, BorderLayout.CENTER); Top.setLayout(null); JPanel1.setBounds(0, 0, 225, 415); Top.add(JPanel1); JPanel1.setLayout(null); RouterBtn.setBounds(60, 95, 110, 165); JPanel1.add(RouterBtn); eight.setBounds(170, 155, 45, 45); JPanel1.add(eight); one.setBounds(170, 105, 45, 45); JPanel1.add(one); six.setBounds(65, 40, 45, 55); JPanel1.add(six); three.setBounds(15, 105, 45, 45); JPanel1.add(three); four.setBounds(15, 205, 45, 45); JPanel1.add(four); seven.setBounds(15, 155, 45, 45); JPanel1.add(seven); two.setBounds(170, 205, 45, 45); JPanel1.add(two); ten.setBounds(120, 260, 45, 55); JPanel1.add(ten); five.setBounds(65, 260, 45, 55); JPanel1.add(five); nine.setBounds(120, 40, 45, 55); JPanel1.add(nine); JPanel2.setBounds(220, 0, 455, 415); Top.add(JPanel2); JPanel2.setLayout(new BorderLayout(5, 5)); JPanel2.add(JPanel3, BorderLayout.NORTH); JPanel3.setLayout(new FlowLayout(1, 5, 5)); JPanel3.add(JLabel1); JPanel2.add(JPanel4, BorderLayout.CENTER); JPanel4.setLayout(new CardLayout(5, 5)); JPanel2.add(JPanel5, BorderLayout.SOUTH); JPanel5.setLayout(new FlowLayout(2, 5, 5)); JPanel5.add(RefreshBtn); JPanel5.add(CloseBtn); // <End_setUpGUI_Container> }
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())); }
private void jButtonSOLVEActionPerformed(java.awt.event.ActionEvent evt) throws IOException { System.out.println("solving"); // DEBUG // BufferedReader in = new BufferedReader(new // FileReader("C:\\Users\\Rainer\\Desktop\\2013 FALL\\CAP 4621 - Artificial // Intelligence\\Project\\InitialBoard.txt")); // // try{ // in = new BufferedReader(new FileReader("C:\\Users\\Rainer\\Desktop\\2013 // FALL\\CAP 4621 - Artificial Intelligence\\Project\\InitialBoard.txt")); // // }catch (FileNotFoundException e){ // System.out.println(e.getCause()); // System.out.println("Error loading initial board"); // } // // int [] boardRows = new int [15]; // // //---------------- // String text = in.readLine(); // // StringTokenizer tokenizer = new StringTokenizer(text," "); // // int boardSize = 0; // while (tokenizer.hasMoreElements()){ // boardRows[boardSize] = Integer.parseInt(tokenizer.nextToken()); // boardSize++; // } // // int []newBoard = new int[boardSize*boardSize+1]; // System.arraycopy(boardRows, 0, newBoard, 1, boardSize); // // int index = 0; // while (in.ready()) { // index++; // text = in.readLine(); // // tokenizer = new StringTokenizer(text," "); // int pos = 0; // while (tokenizer.hasMoreElements()){ // pos++; // newBoard[index*boardSize+pos] = // Integer.parseInt(tokenizer.nextToken()); // } // } // // this.jFrameFileChooser.setVisible(false); // // this.boardPanel.s // // gameInitialBoard = new Board(newBoard, boardSize); // gameBoard = new Board(newBoard, boardSize); // init(); // // END DEBUG long startTime = System.nanoTime(); this.gameBoard.solveBoard(); long endTime = System.nanoTime(); double time = (endTime - startTime) / 100000000.0; System.out.println("Excecution time: " + time + " seconds"); // jPanelSolvedBoard jPanelSolvedBoard.removeAll(); jPanelSolvedBoard.setLayout( new GridLayout(gameBoard.boardSize, gameBoard.boardSize)); // Set layout solvedCells = new JTextField[gameBoard.boardSize * gameBoard.boardSize + 1]; for (int i = 1; i <= gameBoard.boardSize * gameBoard.boardSize; i++) { solvedCells[i] = new JTextField(); solvedCells[i].setHorizontalAlignment(JTextField.CENTER); solvedCells[i].setFont(new Font("Agency FB", Font.BOLD, 24)); // Add elements to the grid content pane jPanelSolvedBoard.add(solvedCells[i]); String ch = Integer.toString(this.gameBoard.cells[i]); solvedCells[i].setText(ch); solvedCells[i].setEditable(false); } // gameBoard.out(); jPanelSolvedBoard.setVisible(true); this.jPanelSolvedBoard.repaint(); this.jFrameSolvedBoard.setVisible(true); this.jFrameSolvedBoard.pack(); // }