Java JOptionPane Text Unreadable
May 17, 2014
When I use this code
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.
View Replies
ADVERTISEMENT
Jul 16, 2014
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.
public void readFile()throws IOException {
BufferedReader inputStream = null;
FileInputStream fis=null;
InputStreamReader isr = null;
//Blank workbook
XSSFWorkbook workbook = new XSSFWorkbook();
[Code] .....
View Replies
View Related
Aug 17, 2014
In javaFX 2.0 how can a message (i.e. JOptionPane in java) is displayed? Example code.
View Replies
View Related
Jan 27, 2013
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 …
@RequestMapping(value = "/mymethod", method = RequestMethod.GET)
public void refreshOrders(final HttpServletResponse response) throws IOException
{
execute(response, myWorker);
}
private void execute(final HttpServletResponse response,
[Code] ....
I set my buffer size to be 1K but that doesn't do anything.
View Replies
View Related
Feb 25, 2014
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"};
[Code] .....
View Replies
View Related
Aug 27, 2014
I Can't run this simple program
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)"
View Replies
View Related
May 13, 2015
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 is the code..
package KOSAR2;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
[Code] .....
View Replies
View Related
May 27, 2014
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();
[code].....
View Replies
View Related
Feb 13, 2015
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();
[Code] .......
View Replies
View Related
Sep 9, 2014
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:
import javax.swing.JOptionPane;
import java.util.*;
import java.text.DecimalFormat;
import java.util.StringTokenizer;
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;
[code]....
View Replies
View Related
Jul 14, 2014
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).
View Replies
View Related
Dec 24, 2014
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?
View Replies
View Related
Jul 1, 2014
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.
View Replies
View Related
May 8, 2014
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?
View Replies
View Related
Apr 21, 2014
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.
View Replies
View Related
Feb 16, 2015
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;
[Code] ....
View Replies
View Related
Sep 1, 2014
i have this source code...
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!
View Replies
View Related
Nov 25, 2014
For some reason the two JOptionPane message boxes at the end of my code don't seem to open when I run the program.
package assg2.kevin;
import java.awt.HeadlessException;
import javax.swing.*;
import java.util.Arrays;
import java.util.Random;
public class Assg2Kevin {
[Code] ....
View Replies
View Related
Jun 14, 2014
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) {
[code]....
View Replies
View Related
Apr 28, 2014
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);
[code]...
View Replies
View Related
Aug 11, 2014
I am wondering why , when I click on the "Add Student" button on the GUI,the message dialog is not popping up.
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
[Code] ......
View Replies
View Related
May 19, 2014
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'.
View Replies
View Related
Oct 5, 2014
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;
[Code] .....
View Replies
View Related
Jul 1, 2014
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.
View Replies
View Related
Feb 9, 2014
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;
[code]....
View Replies
View Related
Mar 8, 2015
SalesMan receives 200$ a week plus 9% of commission on the items he had sold that week
item 1 = 5.00
item 2 = 10.00
item 3 = 1.00
item 4 = 25.00
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;
[Code] .....
View Replies
View Related