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 was trying to read an article from here : [URL] ..... I was doing the same example but loop is not ending. Thread is struck at CalculateThreadDemo run method. If i mentioned System.out.println then it got terminated else infinite loop continues. I don't understand this.
code:
BlockedThreadDemo public class BlockedThreadDemo extends Thread { private boolean isFinished = false; BlockedThreadDemo(String name) { super(name);
[Code] ....
Without commenting the statement:
597222 597223 597224 597225 isFinished: true main thread is dead 597226 CalculateThread is finished.
i: = 49i: = 13i: = 10 BlockedThreadDemo is finished.
Ask user to enter a name alphabet by alphabet, and print d whole word as output,,,,,, use while loop?Since i am new to JAVA..i have no clue on how to begin?
I'm supposed to add characters to a stack and pop them once the adjacent delimiter is read in from a text file. Moreover, program is supposed to print out the incoming text from the file, but stop when the applicable delimiter is not on top of the stack. As in, a '[' doesn't have a ']'.
I've got the program so it can pop and add to the stack correctly, and stops adding at the correct time, but I cant seem to get it to stop printing. I know a switch statement method in another class seems obvious, but I was trying to practice nested loops.
This is the main program:
import java.io.*; import java.util.Scanner; import java.io.IOException; import java.util.Stack; public class DelimiterChecker { public static void main(String [] args) throws IOException {
My issue is that when I run my search, it does find a goal. However, when I try and print the route using my print route method, it just gets stuck in a loop of printing the same two nodes. What is wrong with My A* implementation?
I am trying to write a loop that calculates the distance traveled (distance = speed * time). It should use the loop to calc how far the vehicle traveled for each hour of time. My program asks for hours and then mph but its not calculating time * speed. Here is my code.
public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter Hours Traveled "); int hoursTraveled = input.nextInt(); System.out.println("Enter MPH "); int mph = input.nextInt();
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)"
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 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!
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.
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'.