redho home | products | services

Programming Forums


Community for Java, PHP, Perl C, ASP and Python programmers
Sunday 09 December 2018 21:17

Ask your IT question here

Making a window pane pop up in a Java program?



 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Programming Forums -> JAVA programming forum
View previous topic :: View next topic  
Author Message
Montar
Guest Programmer




Soooooo, I'm just starting out in a Java programming class and our first assignment was to create some simple programs to add, subtract, multiply, and divide two integers (which I was able to figure out from one of his handouts and a lot of googling - don't laugh at my frankencode below).
Anyway, the way I have the programs set up right now, (ssing JCreator), I input my numbers in the "General Output" section at the bottom of the screen. My professor had showed us how to make windows pop up in class though (using the JOptionPane.showMessageDialog deal), and I thought it would be fun if I could make it possible to input my numbers for adding and subtracting, etc... pop up in those windows so the user could input them in a less ghetto fashion.
So does anyone know a way to do this, or can you point me in the direction to find out? I've googled it, but I can't seem to find what I'm trying to do. I'm sure its incredibly basic, I'm just brand new, don't know a thing, and don't know what the hell to try.
Here's the code I've got so far for an addition program (it works but like I said, I want windows to pop up). Thanks for any info, and if anyone is a game programmer and you wanna share what you did to get to that point, please let me know cuz that's my goal!


import java.io.*; //needed to access input stream class
import java.util.Scanner;

public class XYAdd

{

public static void main (String [] args)

throws java.io.IOException
{
Scanner input = new Scanner (System.in);

int x; //first number to add
int y; //second number to add
int Total; //sum of x and y
String s1;
//set up the basic input stream

System.out.println ("Enter x");
x = input.nextInt(); //read first number from user
//using the scanner class
System.out.println ("Enter y");
y = input.nextInt(); //read second number from user

Total = x + y; //add numbers

System.out.printf ("Total is %d\n", Total); //display total
}
}

Reply with quote
 
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Programming Forums -> JAVA programming forum


Dubai Forums - Expat Help | Vegan Forum | Java Programming | 3d Design Resources | 3d Forum | 3D Jobs | 3D Textures | Paris Forum | Europe Forum
Dubai Classifieds | Dubai Property | Jobs in Dubai | Free London Classifieds | Jobs in London UK

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

© 2018 RedHo