import java.awt.Font; import javax.swing.*; public class Interface extends javax.swing.JFrame { /** * */ private static final long serialVersionUID = 1L; /** Creates new form Driver * @throws Exception */ public Interface() throws Exception { initComponents(); } // private void initComponents() throws Exception { jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextPane1 = new javax.swing.JTextPane(); jLabel2 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); jTextPane2 = new javax.swing.JTextPane(); jScrollPane3 = new javax.swing.JScrollPane(); jTextPane3 = new javax.swing.JTextPane(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jScrollPane4 = new javax.swing.JScrollPane(); jTextPane4 = new javax.swing.JTextPane(); jLabel5 = new javax.swing.JLabel(); jScrollPane5 = new javax.swing.JScrollPane(); jTextPane5 = new javax.swing.JTextPane(); jLabel6 = new javax.swing.JLabel(); jScrollPane6 = new javax.swing.JScrollPane(); jTextPane6 = new javax.swing.JTextPane(); jLabel7 = new javax.swing.JLabel(); jScrollPane7 = new javax.swing.JScrollPane(); jTextPane7 = new javax.swing.JTextPane(); jScrollPane8 = new javax.swing.JScrollPane(); jTextPane8 = new javax.swing.JTextPane(); jLabel8 = new javax.swing.JLabel(); jScrollPane9 = new javax.swing.JScrollPane(); jTextPane9 = new javax.swing.JTextPane(); jLabel9 = new javax.swing.JLabel(); jScrollPane10 = new javax.swing.JScrollPane(); jTextPane10 = new javax.swing.JTextPane(); jLabel10 = new javax.swing.JLabel(); jScrollPane11 = new javax.swing.JScrollPane(); jTextPane11 = new javax.swing.JTextPane(); jLabel11 = new javax.swing.JLabel(); jScrollPane12 = new javax.swing.JScrollPane(); jTextPane12 = new javax.swing.JTextPane(); jLabel12 = new javax.swing.JLabel(); jScrollPane13 = new javax.swing.JScrollPane(); jTextPane13 = new javax.swing.JTextPane(); jLabel13 = new javax.swing.JLabel(); jScrollPane14 = new javax.swing.JScrollPane(); jTextPane14 = new javax.swing.JTextPane(); jLabel14 = new javax.swing.JLabel(); jScrollPane15 = new javax.swing.JScrollPane(); jTextPane15 = new javax.swing.JTextPane(); jLabel15 = new javax.swing.JLabel(); jScrollPane16 = new javax.swing.JScrollPane(); totalNodeCountTextPane = new javax.swing.JTextPane(); jLabel16 = new javax.swing.JLabel(); jScrollPane17 = new javax.swing.JScrollPane(); resultTextPane = new javax.swing.JTextPane(); jLabel17 = new javax.swing.JLabel(); jLabel18 = new javax.swing.JLabel(); userInputField = new javax.swing.JTextField(); enterButton = new javax.swing.JButton(); jLabel19 = new javax.swing.JLabel(); jScrollPane18 = new javax.swing.JScrollPane(); outputTextArea = new javax.swing.JTextArea(); functionComboBox = new javax.swing.JComboBox(); outputComboBox = new javax.swing.JComboBox(); sortRadioButton = new javax.swing.JRadioButton(); jLabel20 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Caroline Word Graph - When Only The Very Best Will Do"); sortRadioButton.setSelected(false); resultTextPane.setContentType("text/html"); totalNodeCountTextPane.setContentType("text/html"); jTextPane1.setContentType("text/html"); jTextPane2.setContentType("text/html"); jTextPane3.setContentType("text/html"); jTextPane4.setContentType("text/html"); jTextPane5.setContentType("text/html"); jTextPane6.setContentType("text/html"); jTextPane7.setContentType("text/html"); jTextPane8.setContentType("text/html"); jTextPane9.setContentType("text/html"); jTextPane10.setContentType("text/html"); jTextPane11.setContentType("text/html"); jTextPane12.setContentType("text/html"); jTextPane13.setContentType("text/html"); jTextPane14.setContentType("text/html"); jTextPane15.setContentType("text/html"); functionComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Anagram", "Search" })); functionComboBox.setKeySelectionManager(null); functionComboBox.setSelectedItem("Search"); outputComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Boolean", "Hash" })); outputComboBox.setKeySelectionManager(null); outputComboBox.setSelectedItem("Boolean"); outputTextArea.setFont(new Font("Courier", Font.PLAIN, 12)); thisCwg = new Cwg(); nodePaneFillers = new String[MAX]; theNodePanes = new JTextPane[MAX]; theNodePanes[0] = jTextPane1; theNodePanes[1] = jTextPane2; theNodePanes[2] = jTextPane3; theNodePanes[3] = jTextPane4; theNodePanes[4] = jTextPane5; theNodePanes[5] = jTextPane6; theNodePanes[6] = jTextPane7; theNodePanes[7] = jTextPane8; theNodePanes[8] = jTextPane9; theNodePanes[9] = jTextPane10; theNodePanes[10] = jTextPane11; theNodePanes[11] = jTextPane12; theNodePanes[12] = jTextPane13; theNodePanes[13] = jTextPane14; theNodePanes[14] = jTextPane15; userInputField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { userInputFieldActionPerformed(evt); } }); enterButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { enterButtonActionPerformed(evt); } }); outputComboBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { outputComboBoxActionPerformed(evt); } }); functionComboBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { functionComboBoxActionPerformed(evt); } }); sortRadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { sortRadioButtonActionPerformed(evt); } }); jLabel1.setText(" Root"); jTextPane1.setEditable(false); jScrollPane1.setViewportView(jTextPane1); jLabel2.setText(" N02:"); jTextPane2.setEditable(false); jScrollPane2.setViewportView(jTextPane2); jTextPane3.setEditable(false); jScrollPane3.setViewportView(jTextPane3); jLabel3.setText(" N03:"); jLabel4.setText(" N04:"); jTextPane4.setEditable(false); jScrollPane4.setViewportView(jTextPane4); jLabel5.setText(" N05:"); jTextPane5.setEditable(false); jScrollPane5.setViewportView(jTextPane5); jLabel6.setText(" N06:"); jTextPane6.setEditable(false); jScrollPane6.setViewportView(jTextPane6); jLabel7.setText(" N07:"); jTextPane7.setEditable(false); jScrollPane7.setViewportView(jTextPane7); jTextPane8.setEditable(false); jScrollPane8.setViewportView(jTextPane8); jLabel8.setText(" N08:"); jTextPane9.setEditable(false); jScrollPane9.setViewportView(jTextPane9); jLabel9.setText(" N09:"); jTextPane10.setEditable(false); jScrollPane10.setViewportView(jTextPane10); jLabel10.setText(" N10:"); jTextPane11.setEditable(false); jScrollPane11.setViewportView(jTextPane11); jLabel11.setText(" N11:"); jTextPane12.setEditable(false); jScrollPane12.setViewportView(jTextPane12); jLabel12.setText(" N12:"); jTextPane13.setEditable(false); jScrollPane13.setViewportView(jTextPane13); jLabel13.setText(" N13:"); jTextPane14.setEditable(false); jScrollPane14.setViewportView(jTextPane14); jLabel14.setText(" N14:"); jTextPane15.setEditable(false); jScrollPane15.setViewportView(jTextPane15); jLabel15.setText(" N15:"); totalNodeCountTextPane.setEditable(false); jScrollPane16.setViewportView(totalNodeCountTextPane); jLabel16.setText(" Total Nodes Visited:"); jLabel18.setText(" Input String:"); enterButton.setText("Enter"); jLabel17.setText(" Result:"); resultTextPane.setEditable(false); jScrollPane17.setViewportView(resultTextPane); jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel19.setText((char)0X2193 + " Output " + (char)0X2193); outputTextArea.setColumns(20); outputTextArea.setEditable(false); outputTextArea.setRows(5); jScrollPane18.setViewportView(outputTextArea); sortRadioButton.setText("Alphabetical Sort"); jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel20.setText("'?' = Wildcard Character"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addComponent(jLabel17) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane17)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addComponent(jLabel16) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane16)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel4) .addComponent(jLabel5) .addComponent(jLabel6) .addComponent(jLabel7) .addComponent(jLabel8) .addComponent(jLabel9) .addComponent(jLabel10) .addComponent(jLabel11) .addComponent(jLabel12) .addComponent(jLabel13) .addComponent(jLabel14) .addComponent(jLabel15)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jScrollPane15) .addComponent(jScrollPane14) .addComponent(jScrollPane13) .addComponent(jScrollPane12) .addComponent(jScrollPane11) .addComponent(jScrollPane10) .addComponent(jScrollPane9) .addComponent(jScrollPane8) .addComponent(jScrollPane7) .addComponent(jScrollPane6) .addComponent(jScrollPane5) .addComponent(jScrollPane4) .addComponent(jScrollPane3) .addComponent(jScrollPane2) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jScrollPane18) .addGroup(layout.createSequentialGroup() .addComponent(functionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(outputComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(sortRadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel18) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(userInputField, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(enterButton, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(22, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE) .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(userInputField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(enterButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(sortRadioButton) .addComponent(jLabel20)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(functionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(outputComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(5, 5, 5))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane10, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane13, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane14, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane15, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane16, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane17, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE))) .addComponent(jScrollPane18, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)) .addContainerGap()) ); pack(); }// /** * @param args the command line arguments */ public static void main(String[] args) throws Exception{ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { new Interface().setVisible(true); userInputField.requestFocusInWindow(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } // Variables declaration - do not modify private static final int MAX = 15; private static final int SET_TO_BOOLEAN = 0; private static final int SET_TO_HASH = 1; private static int outputComboBoxState = 0; private static final int SET_TO_ANAGRAM = 0; private static final int SET_TO_SEARCH = 1; private static int functionComboBoxState = 1; private static final int SET_TO_INPUT_ORDER = 0; private static final int SET_TO_SORT = 1; private static int sortRadioButtonState = 0; private static Cwg thisCwg; private static String[] nodePaneFillers; private static javax.swing.JTextPane[] theNodePanes; private static boolean[] searchResult = { false }; private static int[] nodeCounter = { 0 }; private static int[] nodeCounterArray = new int[MAX]; private static int[] hashReturn = { 0 }; private static int[] wordCount = { 0 }; private javax.swing.JButton enterButton; private static javax.swing.JComboBox functionComboBox; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; private javax.swing.JLabel jLabel17; private javax.swing.JLabel jLabel18; private javax.swing.JLabel jLabel19; private javax.swing.JLabel jLabel20; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane10; private javax.swing.JScrollPane jScrollPane11; private javax.swing.JScrollPane jScrollPane12; private javax.swing.JScrollPane jScrollPane13; private javax.swing.JScrollPane jScrollPane14; private javax.swing.JScrollPane jScrollPane15; private javax.swing.JScrollPane jScrollPane16; private javax.swing.JScrollPane jScrollPane17; private static javax.swing.JScrollPane jScrollPane18; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JScrollPane jScrollPane4; private javax.swing.JScrollPane jScrollPane5; private javax.swing.JScrollPane jScrollPane6; private javax.swing.JScrollPane jScrollPane7; private javax.swing.JScrollPane jScrollPane8; private javax.swing.JScrollPane jScrollPane9; private javax.swing.JTextPane jTextPane1; private javax.swing.JTextPane jTextPane10; private javax.swing.JTextPane jTextPane11; private javax.swing.JTextPane jTextPane12; private javax.swing.JTextPane jTextPane13; private javax.swing.JTextPane jTextPane14; private javax.swing.JTextPane jTextPane15; private javax.swing.JTextPane jTextPane2; private javax.swing.JTextPane jTextPane3; private javax.swing.JTextPane jTextPane4; private javax.swing.JTextPane jTextPane5; private javax.swing.JTextPane jTextPane6; private javax.swing.JTextPane jTextPane7; private javax.swing.JTextPane jTextPane8; private javax.swing.JTextPane jTextPane9; private static javax.swing.JComboBox outputComboBox; private static javax.swing.JTextArea outputTextArea; private static javax.swing.JTextPane resultTextPane; private static javax.swing.JRadioButton sortRadioButton; private static javax.swing.JTextPane totalNodeCountTextPane; private static javax.swing.JTextField userInputField; // End of variables declaration private static void userInputFieldActionPerformed(java.awt.event.ActionEvent evt) { String theInput = userInputField.getText(); if ( validateInput(theInput) ) { if ( outputComboBoxState == SET_TO_BOOLEAN ) { if ( functionComboBoxState == SET_TO_SEARCH ) { sortRadioButton.setSelected(false); sortRadioButtonState = SET_TO_INPUT_ORDER; if ( theInput.indexOf('?') == -1 ) { outputTextArea.setText(thisCwg.searchForString(theInput, nodePaneFillers, searchResult, nodeCounter)); totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); if ( searchResult[0] == true ) resultTextPane.setText("FOUND"); else resultTextPane.setText("LOST"); } else { wordCount[0] = 0; nodeCounter[0] = 0; for ( int x = 0; x < MAX; x++ ) nodeCounterArray[x] = 0; outputTextArea.setText(thisCwg.patternSearch(false, theInput, nodePaneFillers, wordCount, nodeCounterArray)); for ( int x = 0; x < MAX; x++ ) nodeCounter[0] += nodeCounterArray[x]; totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); resultTextPane.setText("| " + wordCount[0] + " | WORD PATTERNS"); outputTextArea.setCaretPosition(0); } } else { wordCount[0] = 0; nodeCounter[0] = 0; for ( int x = 0; x < MAX; x++ ) nodeCounterArray[x] = 0; outputTextArea.setText(thisCwg.booleanAnagram((sortRadioButtonState == SET_TO_SORT), theInput, nodePaneFillers, wordCount, nodeCounterArray)); for ( int x = 0; x < MAX; x++ ) nodeCounter[0] += nodeCounterArray[x]; totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); resultTextPane.setText("| " + wordCount[0] + " | WORD PATTERNS"); outputTextArea.setCaretPosition(0); } } else { if ( functionComboBoxState == SET_TO_SEARCH ) { sortRadioButton.setSelected(false); sortRadioButtonState = SET_TO_INPUT_ORDER; if ( theInput.indexOf('?') == -1 ) { outputTextArea.setText(thisCwg.hashString(theInput, nodePaneFillers, hashReturn, nodeCounter)); totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); if ( hashReturn[0] != 0 ) resultTextPane.setText("| " + hashReturn[0] + " | FOUND"); else resultTextPane.setText("| " + hashReturn[0] + " | LOST"); } else { wordCount[0] = 0; nodeCounter[0] = 0; for ( int x = 0; x < MAX; x++ ) nodeCounterArray[x] = 0; outputTextArea.setText(thisCwg.patternSearch(true, theInput, nodePaneFillers, wordCount, nodeCounterArray)); for ( int x = 0; x < MAX; x++ ) nodeCounter[0] += nodeCounterArray[x]; totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); resultTextPane.setText("| " + wordCount[0] + " | WORD PATTERNS"); outputTextArea.setCaretPosition(0); } } else { wordCount[0] = 0; nodeCounter[0] = 0; for ( int x = 0; x < MAX; x++ ) nodeCounterArray[x] = 0; outputTextArea.setText(thisCwg.hashAnagram((sortRadioButtonState == SET_TO_SORT), theInput, nodePaneFillers, wordCount, nodeCounterArray)); for ( int x = 0; x < MAX; x++ ) nodeCounter[0] += nodeCounterArray[x]; totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); resultTextPane.setText("| " + wordCount[0] + " | WORD PATTERNS"); outputTextArea.setCaretPosition(0); } } } else { outputTextArea.setText("\"" + theInput + "\" Invalid, try again."); resultTextPane.setText("BOGUS INPUT"); for (int x = 0; x < MAX; x++) nodePaneFillers[x] = ""; } for (int x = 0; x < MAX; x++) theNodePanes[x].setText(nodePaneFillers[x]); userInputField.selectAll(); } private static void enterButtonActionPerformed(java.awt.event.ActionEvent evt) { String theInput = userInputField.getText(); if ( validateInput(theInput) ) { if ( outputComboBoxState == SET_TO_BOOLEAN ) { if ( functionComboBoxState == SET_TO_SEARCH ) { sortRadioButton.setSelected(false); sortRadioButtonState = SET_TO_INPUT_ORDER; if ( theInput.indexOf('?') == -1 ) { outputTextArea.setText(thisCwg.searchForString(theInput, nodePaneFillers, searchResult, nodeCounter)); totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); if ( searchResult[0] == true ) resultTextPane.setText("FOUND"); else resultTextPane.setText("LOST"); } else { wordCount[0] = 0; nodeCounter[0] = 0; for ( int x = 0; x < MAX; x++ ) nodeCounterArray[x] = 0; outputTextArea.setText(thisCwg.patternSearch(false, theInput, nodePaneFillers, wordCount, nodeCounterArray)); for ( int x = 0; x < MAX; x++ ) nodeCounter[0] += nodeCounterArray[x]; totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); resultTextPane.setText("| " + wordCount[0] + " | WORD PATTERNS"); outputTextArea.setCaretPosition(0); } } else { wordCount[0] = 0; nodeCounter[0] = 0; for ( int x = 0; x < MAX; x++ ) nodeCounterArray[x] = 0; outputTextArea.setText(thisCwg.booleanAnagram((sortRadioButtonState == SET_TO_SORT), theInput, nodePaneFillers, wordCount, nodeCounterArray)); for ( int x = 0; x < MAX; x++ ) nodeCounter[0] += nodeCounterArray[x]; totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); resultTextPane.setText("| " + wordCount[0] + " | WORD PATTERNS"); outputTextArea.setCaretPosition(0); } } else { if ( functionComboBoxState == SET_TO_SEARCH ) { sortRadioButton.setSelected(false); sortRadioButtonState = SET_TO_INPUT_ORDER; if ( theInput.indexOf('?') == -1 ) { outputTextArea.setText(thisCwg.hashString(theInput, nodePaneFillers, hashReturn, nodeCounter)); totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); if ( hashReturn[0] != 0 ) resultTextPane.setText("| " + hashReturn[0] + " | FOUND"); else resultTextPane.setText("| " + hashReturn[0] + " | LOST"); } else { wordCount[0] = 0; nodeCounter[0] = 0; for ( int x = 0; x < MAX; x++ ) nodeCounterArray[x] = 0; outputTextArea.setText(thisCwg.patternSearch(true, theInput, nodePaneFillers, wordCount, nodeCounterArray)); for ( int x = 0; x < MAX; x++ ) nodeCounter[0] += nodeCounterArray[x]; totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); resultTextPane.setText("| " + wordCount[0] + " | WORD PATTERNS"); outputTextArea.setCaretPosition(0); } } else { wordCount[0] = 0; nodeCounter[0] = 0; for ( int x = 0; x < MAX; x++ ) nodeCounterArray[x] = 0; outputTextArea.setText(thisCwg.hashAnagram((sortRadioButtonState == SET_TO_SORT), theInput, nodePaneFillers, wordCount, nodeCounterArray)); for ( int x = 0; x < MAX; x++ ) nodeCounter[0] += nodeCounterArray[x]; totalNodeCountTextPane.setText("| " + nodeCounter[0] + " |"); resultTextPane.setText("| " + wordCount[0] + " | WORD PATTERNS"); outputTextArea.setCaretPosition(0); } } } else { outputTextArea.setText("\"" + theInput + "\" Invalid, try again."); resultTextPane.setText("BOGUS INPUT"); for (int x = 0; x < MAX; x++) nodePaneFillers[x] = ""; } for (int x = 0; x < MAX; x++) theNodePanes[x].setText(nodePaneFillers[x]); userInputField.requestFocusInWindow(); userInputField.selectAll(); } private static void outputComboBoxActionPerformed(java.awt.event.ActionEvent evt){ String outputReturn = new String((String)outputComboBox.getSelectedItem()); if ( outputReturn.equals("Boolean") ) outputComboBoxState = SET_TO_BOOLEAN; else outputComboBoxState = SET_TO_HASH; userInputField.requestFocusInWindow(); userInputField.selectAll(); } private static void functionComboBoxActionPerformed(java.awt.event.ActionEvent evt) { String functionReturn = new String((String)functionComboBox.getSelectedItem()); if ( functionReturn.equals("Anagram") ) functionComboBoxState = SET_TO_ANAGRAM; else functionComboBoxState = SET_TO_SEARCH; userInputField.requestFocusInWindow(); userInputField.selectAll(); } private static void sortRadioButtonActionPerformed(java.awt.event.ActionEvent evt){ if ( sortRadioButton.isSelected() ) sortRadioButtonState = SET_TO_SORT; else sortRadioButtonState = SET_TO_INPUT_ORDER; userInputField.requestFocusInWindow(); userInputField.selectAll(); } // Anagramming and pattern searching allows the '?' wildcard char to be input. private static boolean validateInput(String userInput){ if ( userInput.length() == 0 ) return false; char currentChar; for( int x = (userInput.length() - 1); x >= 0; x-- ){ currentChar = userInput.charAt(x); if ( currentChar >= 'A' && currentChar <= 'Z' ) continue; if ( currentChar >= 'a' && currentChar <= 'z' ) continue; if ( currentChar == '?' ) continue; return false; } return true; } }