How can I put this into a popup window?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Blue1244
    New Member
    • Aug 2013
    • 39

    How can I put this into a popup window?

    How can I get this to work? I have the popup window where it pops up but I'm using Netbeans and the data I want in the popup box isn't in there.. it is in the netbeans runner thing. By the way don't judge the look of this code I except all criticism, but I'm only 13.
    Code:
    package FunctionSolver;
    import java.awt.Canvas;
    import java.util.Scanner;
    import javax.swing.JFrame;
    public class Main extends Canvas {
        
        public static final int WIDTH = 800;
        public static final int HEIGHT = 600;
        public static final String TITLE = "Linear Equation Solver";
    
      
        public static void main(String[] args) 
        {
            JFrame frame = new JFrame();
            frame.pack();
            frame.setTitle (TITLE);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(WIDTH, HEIGHT);
            frame.setLocationRelativeTo(null);
            frame.setResizable(false);
            frame.setVisible(true);
            
            
            
            
            System.out.println("This solves both positive and negative functions.");
            System.out.println("This is a function solver(only linear equations)");
            System.out.println("Max of three variables.");
            System.out.println("When righting fractions only use decimals like let's say you want 1/4 it needs to be .25 Thank you.");
         Scanner input;
         input = new Scanner(System.in);
         System.out.println("What Is Your Coefficient?");
         double coef = input.nextDouble();
         System.out.println("What is your constant?");
         double constant = input.nextDouble();
         System.out.println("What is your x variables?");
         double a = input.nextDouble();
         double b = input.nextDouble();
         double c = input.nextDouble();
         if(constant<=0)
         {
         System.out.println("FUNCTION: = f(x) = " + coef + "x" + constant );
         System.out.println();
         }
         else
         {
         System.out.println("FUNCTION: = f(x) = " + coef + "x + " + constant );
         System.out.println();   
         }
         System.out.println("x Variables:");
         System.out.println();
         if(constant<=0)
         {
         System.out.println("function 1 -->f(x) = " + coef + "(" + a + ")" + constant);
         System.out.println();
         System.out.println("function 2 -->f(x) = " + coef + "(" + b + ")" + constant);
         System.out.println();
         System.out.println("function 3 -->f(x) = " + coef + "(" + c + ")" + constant);
         System.out.println();   
         }
         else
         {
         System.out.println("function 1 -->f(x) = " + coef + "(" + a + ")" + " + " + constant);
         System.out.println();
         System.out.println("function 2 -->f(x) = " + coef + "(" + b + ")" + " + " + constant);
         System.out.println();
         System.out.println("function 3 -->f(x) = " + coef + "(" + c + ")" + " + " + constant);
         System.out.println();
         }
         double one;
         one = coef * a + constant;
         double two;
         two = coef * b + constant;
         double three;
         three = coef * c + constant;
         System.out.println("ANSWER:");
         System.out.println();
         System.out.println("Function 1 answer--> " + one);
         System.out.println();
         System.out.println("Function 2 answer--> " + two);
         System.out.println();
         System.out.println("Function 3 answer--> " + three);
         System.out.println();
         System.out.println("Graph");
         System.out.println();
         System.out.println("Should look like this");
         System.out.println("x | y");
         System.out.println();
         System.out.println(a +" | " + one);
         System.out.println();
         System.out.println(b +" | " + two);
         System.out.println();
         System.out.println(c +" | " + three);
         System.out.println();
         System.out.println("The slope is: " + coef + "(remember the slope is understood over one.)");
         System.out.println("The y-intercept is: " + constant);
        }
    }
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    System.in and System.out are the standard in- and output; which is normally the console which called it or the "runner thing" in the IDE. So the program is doing what it is being asked to do.

    I would recommend doing the Swing Tutorials provided by Oracle, they're a great way of learning how to use Swing (which is what you're doing to create that window). Especially the section Using Text Components should be helpful in your situation.

    By the way, I think it's great you're programming at 13. It's a valuable skill and everybody who does it had to start somewhere. :-)

    Comment

    • Blue1244
      New Member
      • Aug 2013
      • 39

      #3
      Thank you for the help, My mom knows I do this and wants to tell my FBLA teacher (Future Business Leaders of America)She thinks that they can help me get a job in the area I want to go in, witch you can guess, coding :). This program i'm making is to solve linear functions if you haven't figured that out already xD.

      Comment

      • Blue1244
        New Member
        • Aug 2013
        • 39

        #4
        Btw I just started the day I made this...

        Comment

        • Nepomuk
          Recognized Expert Specialist
          • Aug 2007
          • 3111

          #5
          Well, there's a lot to learn without a doubt but coding is almost certainly going to be a very valuable skill for a very long time. There are plenty of tutorials out there and good books too which will help you learn these skills and of course if you need help you can always ask here on bytes.com. :-)

          Comment

          Working...