import javax.swing.*;
public class Swag {
public static void main ( String[] args) {
String name = JOptionPane.showInputDialog("What is your name?");
String input = JOptionPane.showInputDialog("How old are you?");
int age = Integer.parseInt(input);
System.out.print(" Hello, " +name);
System.out.println("Next year you'll be " +(age+1));
}
}
And run it, it ends up looking like thisH1765.png I'm running windows 8, the latest x64 JDK, no type of custom font or anything that I know of. I've run this through eclipse, CMD, and uninstalled and reinstalled Java. I tried using another example of JOptionPane usage from a site and running it, still looks the same.
When I am trying to read data from BufferedReader and writing into excel using FileOutputStream object with POI APIs then i am getting the data in excel file in bad formats. you can check the log file and excel file attached for more information.
Here my problem is I cannot use BufferedWriter in place of FileOutputStream because POI class XSSFWorkbook only have one write method and we can only pass FileOutputStream class object there.
I'm using JBoss 7.1.1.Final. I'm writing a Spring 3.1.1.RELEASE web application and have a massive amount (~5MB) of text output to send to the browser. I would like the browser to display the output as it is generated, but right now, the browser only displays everything after the servlet's doGet method completes. Here's my method …
Is there anyway I can write a do while statement for this program. I haven't seen anyway to do it anywhere.
Java Code:
import javax.swing.JOptionPane; public class History { public static void main(String[] args) { //First Question: What is the capital of Mexico? String[] question1 = {"Mexico City", "Paris" //The choseable answers are made using String ,"Washington D.C", "Tokyo"};
import java.util.Scanner; import javax.swing.JOptionpane; public class Project { public static void main(String[] args) { Scanner input = new Scanner(System.in);
[code]...
This is the Error that i get in console!"Exception in thread "main" java.lang.Error: Unresolved compilation problem: JOptionPane cannot be resolved at Project.main(Project.java:10)"
This is the code that I wrote but I have two problem with two buttons one of them ... I want to delete the selected text inside the text Area which represented as b[8] and the other button that I want to select parts of the texts which represented as b[0]....
Here's My code to create multiple JTextfields in a Single Option Pane.
My goal is simple.
Take some input from the user and then store it a TEXT File.
package printer; import java.awt.Toolkit; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import javax.swing.*; public class Database { JTextField name = new JTextField(); JTextField roll = new JTextField();
I am writing a program that has to do with ciphers and cipher shifts. The program itself works fine, but I am having trouble printing out the answers to JOptionPane. I know the basics of JOptionPane, but my problem is this:
Majority of my program takes place in a for loop, and resolves the cipher (it is a basic cipher program) 1 digit at a time. So, only the last DIGIT (I don't know how to convert a digit to a CHAR in JOptionPane) is printed to JOptionPane. Here is my code:
public static void main(String[] args) { String cipher = JOptionPane.showInputDialog(null, "Please enter a sentence or word that you wish to encode or decode. This program uses " + " a basic cipher shift."); int answer = 0; String upperCase = cipher.toUpperCase(); char[] cipherArray = cipher.toCharArray();
I am supposed to be doing a class assignment that calculates the area of a triangle and outputs with JOptionPane. I was able to fix some errors, but it's uncovering more errors.Here is my code:
public class Area { public static void main (String [] args) { double a, b, c; //Input sides of triangle double x; //Perimeter of triangle double area; //Area of triangle StringTokenizer st;
Just wondering if there was a way to change a JOptionPane's display message dependent on the button the user is hovering over. I.e.: Hover option1, shows one message; hover option2, shows a different message, etc.. but within the same JOptionPane (not showing a new one).
import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import javax.swing.ImageIcon; import javax.swing.JOptionPane; public class Main
[Code] ....
I cant custom my own icon. There is no error. But the image that I tried to show in the joptionpane is not showing. What should i do?
I am a beginner in Java and I am currently learning about JOption pane.Using Strings I am accepting an input from the user and by using the Interer.ParseInt(variable) option I am able to multiply this two strings using the code below.
String Length; Length = JOptionPane.showInputDialog("Enter the Length"); String Breadth; Breadth = JOptionPane.showInputDialog("Enter the Breadth"); System.out.println(" Area is " + (Integer.parseInt(Breadth) * Integer.parseInt(Length))); System.exit(0);
How Do I make my code accept Decimal values. E.g. My Code should accept 10.02 as Length and 20.42 as Breadth and give the product a Decimal.
Is it possible to make it so that when the popup box comes up I will only be able to click on the box? For example, I would be browsing the internet while the program is running and then the box pops up and I am forced to answer the question before I can click on anything else. If it is possible, how do I do it?
I am quite familiar with using JOptionPane and its various displayXDialog() methods and reasonably familiar with changing fonts.
I have a JOptionPane.displayMessageDialog() that is working fine but I decided to make the font larger.
I found an example from which I coded:
Font font = UIManager.getFont("OptionPane.font"); UIManager.put("OptionPane.font", new Font(font.getName(), font.getStyle(), 24)); font = UIManager.getFont("OptionPane.font"); JOptionPane.showMessageDialog(this, "Welcome to Mover", "About Mover", -1); // no icon
After the UIManager.getFont() call after the UIManager.put() call, font shows the new font size of 24, but the showMessageDialog() dialog still has the default font.
And yes I understand that, when this works, it will affect every JOptionPane in my program.
I also tried:
Font font = UIManager.getFont("OptionPane.font"); JOptionPane message = new JOptionPane("Welcome to Mover", JOptionPane.INFORMATION_MESSAGE); JDialog dlg = message.createDialog("About Mover");
[Code] ....
This gave me a dialog with the default font and an unwanted icon.
So I tried
// both Font font = UIManager.getFont("Dialog.font"); // and Font font = UIManager.getFont("JDialog.font");
and planned to use that font in my setFont() call but font was null.
I have to make an application called miles to meters that converts miles to meters that asks for user input through joption pane and the output can be eather system.out.println or joption pane, I found the code i need but it uses buffered reader for input not joption pane. Here is the source code
import java.io.*; import java.util.*; class MetersToMiles{ public static void main (String[] args)throws Exception{ // 1 meters = 0.00062137119 miles;
import java.util.Scanner; //I had to use scanner in this program because I had to create objects that were in the Scanner class, such as in row 16. * This program confirms a password typed into a * * console window * */ public class Homework1 { public static void main(String[] args) { //Needs to add a scanner to the program to continue on Scanner keyboard = new Scanner(System.in);
[code]....
Now I need to create a second version of this program that uses JOptionPane to get the inputs from the user and show the output!
My assignment is to create an array list and compare the total salary of two salespeople. I'm wondering if I can use JOptionPane to select an existing sales person from the list and print their information.
I am not having any trouble with the calculations and comparisons, but I am finding limited resources on "searching" for a specific person with JOptionPane.
Here's what I have so far.
public class SalesPeople { String personName; double annualSalary; double salesAmount; double percentComission; public SalesPeople(String xPersonName, double xAnnualSalary, double xSalesAmount, double xPercentComission) {
how to have an application restart if the user inputs an incorrect integer in a JOptionPane question? I know how to do it with the Scanner class but nothing I do seems to work. This is the beginning of my code:
import javax.swing.JOptionPane; public class Pay { public static void main(String[] args) { String level = JOptionPane.showInputDialog("Please select your skill level: 1, 2, or 3"); int levelPick = Integer.parseInt(level);
I am making a simple dice game and am using JOptionPane for my input, however, all input has to be a String. I need to be able to input an integer. 'note, I am using java JDK'.
I am working on allowing a user to enter an ID # using JOptionPane. If the ID is valid, then it will display the ID#, student name, and GPA. If it is not valid, then the window should pop up again to allow the user to enter a valid ID. I have managed to get that far.
I am struggling with once a valid ID # is entered, how do I get the loop to stop? I have tried several different ways, but the code below is the most recent one, and it is still not working!
import javax.swing.*; public class StudentIDArray { public static void main(String[] args) { String enteredID; int idNumber; int x = 0;
Using JOptionPane, I want to display in one window:
1: *** 2: ***** etc
where 1 is the element of the array, and the * are a percentage calculated in a loop. My variables are all being input fine, but the output is 100+ windows:
1:
* * *
2: *
The CLI way would be with print() and println(), but I'm having a tough getting it to be visual.
It works to the point that the user inputs "c" "s" or "r" then it does nothing else ? I can get it to run in my terminal window but when I try to get the JoptionPane windows to work it freezes up.
import java.util.*; // For Scanner import java.lang.String.*; // For toUpperCase() import javax.swing.JOptionPane; // for cute lil java windows public class CaculateAreaOpt { // Declare all variables needed for program public static Scanner in = new Scanner(System.in); public final static double radius = 3.14;
My code : (((I honestly dont know how to loop it... it must ask "What item did you purchase, and have the user input the number of item they purchased THAN looped back to ask again what item did they purchase untill they hit -1 to exit the loop))
import javax.swing.JOptionPane; public class ControlStructure{ public static void main(String [] args){ double item1 = 5.00;//item 1 price int quan1 = 0; double total1 = 0;