Hello good day to all...
is there anyone can help or suggest me how my code work successfully.

Actually the code was working well, but i wanted to change it`s content to GUI form.
the program description was the user must input a word/String and shuffle/scramble the word that the user inputted and shows the possible output of the program to GUI form.
Collaborating with the LinkedList data structure...

import java.util.LinkedList;
	import java.io.*;
	import javax.swing.JOptionPane;


	public class ScrambleWord {

			    public static void main(String args[]) throws IOException{
			    	
			    	
			    	
			    	LinkedList<String> scrambleWordList = new LinkedList<String>();
			    	
			        String str;
			    
			        JOptionPane.showMessageDialog(null, "Welcome to the Program");
			        
			        System.out.println("Enter a Word:");
			        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			        str=br.readLine();
			        System.out.println("Permutations are :");
			        permute("", str);
			        
			        scrambleWordList.add(str);
			        System.out.println("\nThe First Word in the Scramble List is \t \b"+scrambleWordList.getFirst());
			      
			   
			    }

			  public static void permute(String beginningString, String endingString) {
			    if (endingString.length() <= 1)
			      System.out.println(beginningString + endingString);
			    else
			      for (int i = 0; i < endingString.length(); i++) {
			        try {
			          String newString = endingString.substring(0, i) + endingString.substring(i + 1);

			          permute(beginningString + endingString.charAt(i), newString);
			        } catch (StringIndexOutOfBoundsException exception) {
			          exception.printStackTrace();
			        }
			        
			        
			      }
			  }
		}

Recommended Answers

All 3 Replies

For a simple gui: a text field for input, a textarea for output and a button.
User enters text, presses button, output displayed in text area.

i tried it sir, but the code in the permutation method does not associate with the GUI..

You could change your permute method to return the permuted Strings, rather than being void. Then you will be able to call it from your GUI and display the results it returns.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.