Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: How to take my java application and run it with a GUI instead of the IDE

  1. #1
    Junior Member ElJefe's Avatar
    Join Date
    Oct 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question How to take my java application and run it with a GUI instead of the IDE


    Good Afternoon,
    I have recently written a simple application which does some calculations with numbers that have been inputted from the user. It works great on my computer through the IDE and Command Line. I would like to distribute this to work on a Windows formatted computer running Windows 7.

    Basic Concept:
    -I ask the user for information (numbers) some ints, some doubles
    -I apply calculations to the numbers and round them to the next int (if necessary)
    -Then I return the user a value
    -This is done 5 times, getting stored information on 5 different variables
    -I add those variables up and return the end result to the user.

    Need Clarification on:
    -I would like this application to run on others computers without the use of an IDE
    -I would like this application to have a way for the user to view my questions, and a text field to answer my questions with a submit button
    -I would like, once the calculations are complete. A way to display the results in order.

    Example:
    System.out.println("What is the value of Angle 1"):
    User-input: 105
    System.out.println("What is the value of Angle 2"):
    User-input: 101
    System.out.println("What is the value of Angle 3"):
    User-input: 102



    Angle 1 = 105
    Angle 2 = 101
    Angle 3 = 102

    Min Qudrant = 308

    *That was an example doing none of the calculations inside my program.
    If you have any experience with this or need more information or to see my code for helping purposes. Please feel free to e-mail


  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: How to take my java application and run it with a GUI instead of the IDE

    You have to pick one of many GUI libraries and create an application window for it.
    I would guess that the most widely used GUI library for java is Swing which is distributed by oracle.

    Google for Swing tutorials and learn some basics, then you can try to create your GUI frame.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 688 Times in 675 Posts

    Default Re: How to take my java application and run it with a GUI instead of the IDE

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    As for deploying your program so that it can be run by others, study up on 'java desktop deployment'.

    The IDE (Eclipse) is a programmer's tool. You don't need it to run your programs on your computer. You should understand that, so study up on that too. Look for 'run java app from command line' or similar.

  4. #4
    Junior Member ElJefe's Avatar
    Join Date
    Oct 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to take my java application and run it with a GUI instead of the IDE

    Would you mind if I set you what I have written? I did write this using Eclipse running on Ubuntu 14.04.

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 688 Times in 675 Posts

    Default Re: How to take my java application and run it with a GUI instead of the IDE

    If you need help with your code, post it and ask questions. That will be more useful than sending it to somebody at this forum.

  6. #6
    Junior Member ElJefe's Avatar
    Join Date
    Oct 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to take my java application and run it with a GUI instead of the IDE

    Good Afternoon,
    So yesterday I realized that I might have been completely vague and left a lot for misinterpretation. I will describe my program, show the code and then try to give an example of that I am trying to accomplish.

    My Program:
    I am trying to make an interactive program to get information on angles from the user (I am an artillery Training Instructor on Camp Pendleton and am trying to make some peoples lives much safer and easier). This program grabs numbers, either in (int) form or (double) form, I have created the formulas to convert their information into an Angle. After 5 difference calculation I finalize their equation by adding up all 5 angles to give them (the user) a very important and specific number to apply to their safety measurements.

    My Code: (and critiques to syntax or format will be very helpful, I am very new to java)
    /* This is going to be a skeleton program to produce
    * an application for calculating XO's Min QE within
    * a windows (toughbook) for Artillerymen
    * Written by: Sgt Morgan, Robert
    * Date Start: Oct 7, 2014    Date Finish:
    * Copywrite will be pending until finished
    */
     
    import java.util.*;
     
    public class XoMinQe 
    {	
    	public static void main(String[] args) 
    	{
     
    		// ****Greeting and PREP****
    		System.out.print("Together we are going to ");
    		System.out.println("calculate XO's Min QE.\n");
     
    		// going to have user press "enter"
    		Scanner keyIn = new Scanner(System.in);
    		System.out.println("Press the ENTER key to continue");
    		keyIn.nextLine();
     
    			// ****ANGLE 1****
    			// Declaring Angle 1 from user
    			double angle1;
     
    			// going to have user input followed by "enter"
    			Scanner in = new Scanner(System.in);
     
    			// This is going to get the total for Angle 1
    			System.out.print("Enter the Site to Crest information from the");
    			stem.out.println(" Section Chief Report and press Enter.");
     
    			// Applying value from user to angleOne variable
    			angle1 = in.nextDouble();
     
    			// Angle 1 round up *if required*
    			System.out.println("The Value of Angle 1 is " + (int) Math.ceil(angle1));
    		        int angleOne = (int) Math.ceil(angle1);
     
    			System.out.println("\n");   //I do not know how to get proper spacing any other way
     
    			  // ****ANGLE 2****
    			  // Getting the Vertical Clearance *Unarmed/Armed VT* from User
    			  System.out.print("What is the vertical clearance for your firing area?\n");
     
    			  // Applying value from user to vertical clearance variable
    			  int verticalClearance = in.nextInt();
     
    			  // Getting the PCR value from user
    			  System.out.print("\n What is the Piece to Crest Range (PCR) for that weapon?\n");
    			  System.out.println("*Hint* You can get it from the Section Chief Report");
     
    			  // Applying PCR to variable
    			  double pieceToCrestRange = in.nextDouble();
     
    			  // Expressing PCR in thousandth
    			  double pcrExpression = (pieceToCrestRange / 1000);
     
    			  // Going to calculate vertclear/(pcr/1000)
    			  double angle2 = (verticalClearance / pcrExpression) * 1.0186;
     
    			  // Rounding up Angle 2 to final number
    			  System.out.println("\n The Value of Angle 2 is "+ (int) Math.ceil(angle2));
    			  int angleTwo = (int) Math.ceil(angle2);
     
    			    // ****ANGLE 3****
    			    // Getting the Site Factor = Angle 1 + Angle 2
    			    int siteFactor = angleOne + angleTwo;
     
    			    // Declaring variable for Complementary Angle
    			    System.out.println("\n Enter the Complementary Angle from the TFT, Table G.\n");
    			    double compAngle = in.nextDouble();
     
    			    // Calculating for Angle 3
    			    double angle3 = (siteFactor * compAngle);
     
    			    // Rounding up Angle 3 for final number
    			    System.out.println("The Value of Angle 3 is " + (int) Math.ceil(angle3));
    			    int angleThree = (int) Math.ceil(angle3);
     
    			    System.out.println("\n");      //Same issue here with formatting
     
    			    // ****ANGLE 4****
    			    // This is going to get value of Angle 4 from user
    			    System.out.println("What is the TFT Value for that Charge and PCR (TFT, Table F, Col. 2)?\n");
    				      double tftValue = in.nextDouble();
     
    	       		    // Rounding up Angle 4 for final number
    	       		    int angleFour = (int) Math.ceil(tftValue);
    		 	    System.out.println("The Value of Angle 4 is " + angleFour);
     
    				// ****Angle 5****
    				// This is going to get the value for number of forks
    				System.out.println("\n Enter the number of Forks (TFT, Table F)\n");
    		                int forks = in.nextInt();
     
    				// Calculating for final result of Angle 5
    				int angleFive = (forks * 2);
    				System.out.println("The Value of Angle 5 is " + angleFive);
     
    				// Calculating End MIN QE for Gun ___
    				int minQE = (angleOne + angleTwo + angleThree + angleFour + angleFive);
     
     
     
    		                // ****MIN QE****
    				System.out.println("\n The MIN QE for this Gun is " + minQE);
     
    	}
     
     
    }

    Basic Concept of Look and Feel:
    What I was hoping to learn was how to take this code and implement it into a user interface. a small box which will expand as the answers are generated.

    EXAMPLE:
    Window Name: XO Min QE Calculator (Min)(Max)(Close)<--- buttons


    My questions show up here from the above statements.

    Text Box------------------------- (Calculate)<---- Button

    The Value of Angle 1 is ______

    Each time the press a button a new "the vale of angle # _____ shows up extending the window until all 5 angles are computer and then finally showing the user their final product on the bottom of all the calculated data.
    If anyone can help, I would appreciate it, if you cant or there is no way to do this please let me know. I am willing to clean up this code as much as possible as well. Any and all "lessons to be learned" will be greatly appreciated
    *this is no homework, this is my own project to help my fellow Marines and Artillerymen alike.

    Thank you[COLOR="Silver"]
    Last edited by ElJefe; October 9th, 2014 at 12:32 PM. Reason: Copy of a Copy

  7. #7
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: How to take my java application and run it with a GUI instead of the IDE

    As I said before, look up some tutorials for GUI libraries. Which one you take is up to you but I would recommend Swing for something as simple as this.
    You will need to read a few tutorials first but after that it should become quite simple to make your GUI. After all, your program is quite simple so it shouldnt become very complicated to link your program logic and the GUI together.

  8. #8
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 688 Times in 675 Posts

    Default Re: How to take my java application and run it with a GUI instead of the IDE

    If you decide on Swing (and why not), then the Oracle Swing Tutorials are a good place to start. Ignore their bias towards using the Netbeans GUIBuilder and learn to code the GUIs by hand.

  9. The Following User Says Thank You to GregBrannon For This Useful Post:

    ElJefe (October 9th, 2014)

Similar Threads

  1. Replies: 0
    Last Post: January 15th, 2013, 08:59 PM
  2. Re: Pls Help me run bank java application
    By Harshal Soni in forum Object Oriented Programming
    Replies: 2
    Last Post: September 25th, 2012, 10:15 AM
  3. Java application works fine in IDE but not in windows
    By japonce in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 20th, 2012, 09:14 PM
  4. how to run any installed application through my java application??
    By sgsamanthjain in forum Java Theory & Questions
    Replies: 1
    Last Post: April 1st, 2011, 09:17 AM
  5. Pls Help me run bank java application
    By chukster in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 20th, 2010, 08:28 PM

Tags for this Thread