Results 1 to 9 of 9
  1. #1
    Rahim2312 is offline Member
    Join Date
    Apr 2012
    Posts
    88
    Rep Power
    0

    Default CMD Prompt Equivelants to a GUI

    I know for a Command Promt I would use this line
    Java Code:
    System.out.println
    What would I use for a GUI?

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: CMD Prompt Equivelants to a GUI

    In GUI such as Swing you can use something like JLabel, JTextField, JTextArea, etc. It depends on how you design your GUI and the Swing components that you want to use.

  3. #3
    Rahim2312 is offline Member
    Join Date
    Apr 2012
    Posts
    88
    Rep Power
    0

    Default Re: CMD Prompt Equivelants to a GUI

    So what you are saying is that this:
    Java Code:
    System.out.print("This is the same");
    Would produce the same output as this:
    Java Code:
    JOptionPane.showMessageDialog(null, "This is the same");

  4. #4
    Rahim2312 is offline Member
    Join Date
    Apr 2012
    Posts
    88
    Rep Power
    0

    Default Re: CMD Prompt Equivelants to a GUI

    I am guessing not...because I switched all of the lines in my code to mirror the changes below, and it is still printing in a cmd window even tho there is NO code that says to print in a command window!!!???

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: CMD Prompt Equivelants to a GUI

    Quote Originally Posted by Rahim2312 View Post
    I am guessing not...because I switched all of the lines in my code to mirror the changes below, and it is still printing in a cmd window even tho there is NO code that says to print in a command window!!!???
    Show your code so we can see it for ourselves.

  6. #6
    Rahim2312 is offline Member
    Join Date
    Apr 2012
    Posts
    88
    Rep Power
    0

    Default Re: CMD Prompt Equivelants to a GUI

    Java Code:
    	public static void main(String args[]){
        	 int n,i,j,k;
    
            String rowcountNum;
            int rowcount;
            rowcountNum = JOptionPane.showInputDialog("Enter Number Please");
    
            //convert numbers from String to type in
            rowcount = Integer.parseInt(rowcountNum);
            n=rowcount;
        
    
          //System.out.println(n);
    	  JOptionPane.showMessageDialog(null, n);
    
          //System.out.println();
    	  JOptionPane.showMessageDialog();
    
         for (i = 1; i <= n/2; i++){
    
         	for (k = n; k > i; k--)
         	JOptionPane.showMessageDialog(null, " ");
    		//System.out.print(" ");
    
         	for (j =1; j <= i; j++)
    		JOptionPane.showMessageDialog(null, "*" + " ");
             //System.out.print("*" + " ");
    
    	   JOptionPane.showMessageDialog();
           //System.out.println();
    
         	}
    
         for (i = (n/2)+1; i > 0; i--){
    
         	for (k = n; k > i; k--)
         	  JOptionPane.showMessageDialog(null, " ");
    		  //System.out.print(" ");
    
         	for (j =1; j <= i; j++)
             JOptionPane.showMessageDialog(null, "*" + " ");
    		 //System.out.print("*" + " ");
    
           JOptionPane.showMessageDialog();
    	   //System.out.println();
    
         	}
    }
    }

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  8. #8
    Rahim2312 is offline Member
    Join Date
    Apr 2012
    Posts
    88
    Rep Power
    0

    Default Re: CMD Prompt Equivelants to a GUI

    Well it would def help if I was running the .java file where I made these changes! Sorry for wasting your time.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: CMD Prompt Equivelants to a GUI

    Quote Originally Posted by Rahim2312 View Post
    Well it would def help if I was running the .java file where I made these changes! Sorry for wasting your time.
    No problem. Sometimes it takes another set of eyes to help one see.

Similar Threads

  1. New Command prompt
    By jmga9 in forum New To Java
    Replies: 4
    Last Post: 11-10-2010, 02:53 AM
  2. Replies: 4
    Last Post: 03-25-2010, 05:47 PM
  3. Jcreator to DOS Prompt
    By arshesander in forum New To Java
    Replies: 5
    Last Post: 02-17-2010, 07:25 AM
  4. help me!!!! about command prompt..
    By kureikougaiji in forum New To Java
    Replies: 2
    Last Post: 11-13-2008, 07:15 PM
  5. input prompt
    By angelbaby21 in forum New To Java
    Replies: 8
    Last Post: 08-25-2008, 05:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •