By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.

How can I put this into a popup window?

Blue1244
P: 39
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.
Expand|Select|Wrap|Line Numbers
  1. package FunctionSolver;
  2. import java.awt.Canvas;
  3. import java.util.Scanner;
  4. import javax.swing.JFrame;
  5. public class Main extends Canvas {
  6.  
  7.     public static final int WIDTH = 800;
  8.     public static final int HEIGHT = 600;
  9.     public static final String TITLE = "Linear Equation Solver";
  10.  
  11.  
  12.     public static void main(String[] args) 
  13.     {
  14.         JFrame frame = new JFrame();
  15.         frame.pack();
  16.         frame.setTitle (TITLE);
  17.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  18.         frame.setSize(WIDTH, HEIGHT);
  19.         frame.setLocationRelativeTo(null);
  20.         frame.setResizable(false);
  21.         frame.setVisible(true);
  22.  
  23.  
  24.  
  25.  
  26.         System.out.println("This solves both positive and negative functions.");
  27.         System.out.println("This is a function solver(only linear equations)");
  28.         System.out.println("Max of three variables.");
  29.         System.out.println("When righting fractions only use decimals like let's say you want 1/4 it needs to be .25 Thank you.");
  30.      Scanner input;
  31.      input = new Scanner(System.in);
  32.      System.out.println("What Is Your Coefficient?");
  33.      double coef = input.nextDouble();
  34.      System.out.println("What is your constant?");
  35.      double constant = input.nextDouble();
  36.      System.out.println("What is your x variables?");
  37.      double a = input.nextDouble();
  38.      double b = input.nextDouble();
  39.      double c = input.nextDouble();
  40.      if(constant<=0)
  41.      {
  42.      System.out.println("FUNCTION: = f(x) = " + coef + "x" + constant );
  43.      System.out.println();
  44.      }
  45.      else
  46.      {
  47.      System.out.println("FUNCTION: = f(x) = " + coef + "x + " + constant );
  48.      System.out.println();   
  49.      }
  50.      System.out.println("x Variables:");
  51.      System.out.println();
  52.      if(constant<=0)
  53.      {
  54.      System.out.println("function 1 -->f(x) = " + coef + "(" + a + ")" + constant);
  55.      System.out.println();
  56.      System.out.println("function 2 -->f(x) = " + coef + "(" + b + ")" + constant);
  57.      System.out.println();
  58.      System.out.println("function 3 -->f(x) = " + coef + "(" + c + ")" + constant);
  59.      System.out.println();   
  60.      }
  61.      else
  62.      {
  63.      System.out.println("function 1 -->f(x) = " + coef + "(" + a + ")" + " + " + constant);
  64.      System.out.println();
  65.      System.out.println("function 2 -->f(x) = " + coef + "(" + b + ")" + " + " + constant);
  66.      System.out.println();
  67.      System.out.println("function 3 -->f(x) = " + coef + "(" + c + ")" + " + " + constant);
  68.      System.out.println();
  69.      }
  70.      double one;
  71.      one = coef * a + constant;
  72.      double two;
  73.      two = coef * b + constant;
  74.      double three;
  75.      three = coef * c + constant;
  76.      System.out.println("ANSWER:");
  77.      System.out.println();
  78.      System.out.println("Function 1 answer--> " + one);
  79.      System.out.println();
  80.      System.out.println("Function 2 answer--> " + two);
  81.      System.out.println();
  82.      System.out.println("Function 3 answer--> " + three);
  83.      System.out.println();
  84.      System.out.println("Graph");
  85.      System.out.println();
  86.      System.out.println("Should look like this");
  87.      System.out.println("x | y");
  88.      System.out.println();
  89.      System.out.println(a +" | " + one);
  90.      System.out.println();
  91.      System.out.println(b +" | " + two);
  92.      System.out.println();
  93.      System.out.println(c +" | " + three);
  94.      System.out.println();
  95.      System.out.println("The slope is: " + coef + "(remember the slope is understood over one.)");
  96.      System.out.println("The y-intercept is: " + constant);
  97.     }
  98. }
  99.  
  100.  
  101.  
Sep 25 '13 #1

✓ answered by Nepomuk

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. :-)

Share this Question
Share on Google+
4 Replies


Nepomuk
Expert 2.5K+
P: 3,112
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. :-)
Sep 25 '13 #2

Blue1244
P: 39
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.
Sep 25 '13 #3

Blue1244
P: 39
Btw I just started the day I made this...
Sep 25 '13 #4

Nepomuk
Expert 2.5K+
P: 3,112
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. :-)
Sep 26 '13 #5

Post your reply

Sign in to post your reply or Sign up for a free account.