473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can I put this into a popup window?

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

4 1338
Nepomuk
3,112 Expert 2GB
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
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
Btw I just started the day I made this...
Sep 25 '13 #4
Nepomuk
3,112 Expert 2GB
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

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

Similar topics

1
by: Noozer | last post by:
When using the WebBrowser control, is it possible to cause popup windows to appear within the WebBrowser control itself instead of a new window? This is what I've written in the NewWindow2 event,...
2
by: Mark | last post by:
The situtation is that I'm trying to ensure that certain functions are only called by functions that I want them to be called from. I have a popup window which has a function which calls a function...
4
by: Newbie | last post by:
Hello all~ I have got some questions about popup window, hope that someone can help me.. m(_ _)m~thx~ when a popup window appear, can I force users to focus on the popup window "ONLY" that...
6
by: veganeater | last post by:
Hi Everyone, I was wondering if there was a way to pass a variable to a popup window. The purpose is make it so when a user clicks on a specific region/link of the glossary page, a popup opens...
4
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a...
20
by: ruca | last post by:
Hi, DESCRIPTION: I'm developing an application that when I need to insert a date, I use 3 textbox's and one image button. This image button open's a small popup window with a calendar,...
7
by: anthony.turcotte | last post by:
Hi, I've looked for a solution to this problem on google, read posts in this newsgroup and I still haven't found anything that could help me. Here's the scenario. 1. User accesses...
1
by: Doug | last post by:
Hello, I create a popup window using document.createPopup() Is there anyway to add a script node into this popup? For example I'd like to add <script type="text/javascript"...
1
by: sbettadpur | last post by:
here i have an hyper link with emailid. if i click on hyperlink it has to popup a window with in that window i need to print selected hyper link text eg: hyperlink xx@example.com if i...
1
by: gudipati | last post by:
hi i am working on classic asp. i have strucked here. i am reading data from database(ms-access) . what my doubt is how can i show that reading data into popup window. can u pl give me...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.